Thread-Safe Priority Queues in Haskell Based on Skiplists

  • Michael Lesniak
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7193)

Abstract

Although thread-safe priority queues are fundamental building blocks for many parallel algorithms, there are currently no scalable implementations available in Haskell. An efficient structure to implement priority queues is the skiplist, which is a multi-level linked list with shortcuts. We developed three thread-safe skiplist variants, based on locks, software transactional memory, and atomic compare-and-swap, respectively. In our benchmarks, the lock-based and compare-and-swap variants scaled about equally well, while the transactional variant was by several orders of magnitude slower.

Keywords

Parallel Algorithm Priority Queue Sparse Graph Successor Pointer Linked List 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction to Algorithms. MIT Press (2001)Google Scholar
  2. 2.
    Pugh, W.: Skip lists: a probabilistic alternative to balanced trees. Commun. ACM 33, 668–676 (1990)CrossRefGoogle Scholar
  3. 3.
    Fomitchev, M., Ruppert, E.: Lock-free linked lists and skip lists. In: Proceedings of the Twenty-Third Annual ACM Symposium on Principles of Distributed Computing, PODC 2004, pp. 50–59. ACM, New York (2004)CrossRefGoogle Scholar
  4. 4.
    Lotan, I., Shavit., N.: Skiplist-based concurrent priority queues. In: Proc. of the 14th International Parallel and Distributed Processing Symposium (IPDPS), pp. 263–268 (2000)Google Scholar
  5. 5.
    Sundell, H., Tsigas, P.: Fast and lock-free concurrent priority queues for multi-thread systems. J. Parallel Distrib. Comput. 65, 609–627 (2005)MATHCrossRefGoogle Scholar
  6. 6.
    Pugh, W.: Concurrent maintenance of skip lists. Technical report, College Park, MD, USA (1990)Google Scholar
  7. 7.
    Hunt, G.C., Michael, M.M., Parthasarathy, S., Scott, M.L.: An efficient algorithm for concurrent priority queue heaps. Inf. Process. Lett. 60, 151–157 (1996)MathSciNetMATHCrossRefGoogle Scholar
  8. 8.
    Kumar, V., Grama, A., Gupta, A., Karypis, G.: Introduction to parallel computing: design and analysis of algorithms. Benjamin-Cummings Publishing Co., Inc., Redwood City (1994)MATHGoogle Scholar
  9. 9.
    GitHub: repository with source code (available May 2011), http://github.com/mlesniak/haskell-priorityqueue
  10. 10.
    Jones, M.P.: Type Classes with Functional Dependencies. In: Smolka, G. (ed.) ESOP 2000. LNCS, vol. 1782, pp. 230–244. Springer, Heidelberg (2000)CrossRefGoogle Scholar
  11. 11.
    Jones, S.P., Gordon, A., Finne, S.: Concurrent haskell, pp. 295–308. ACM Press (1996)Google Scholar
  12. 12.
    Shavit, N., Touitou, D.: Software transactional memory. In: Proceedings of the Fourteenth Annual ACM Symposium on Principles of Distributed Computing, PODC 1995, pp. 204–213. ACM, New York (1995)CrossRefGoogle Scholar
  13. 13.
    Harris, T., Marlow, S., Peyton-Jones, S., Herlihy, M.: Composable memory transactions. In: PPoPP 2005: Proceedings of the Tenth ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming, pp. 48–60. ACM, New York (2005)CrossRefGoogle Scholar
  14. 14.
    Harris, T.L.: A Pragmatic Implementation of Non-blocking Linked-Lists. In: Welch, J.L. (ed.) DISC 2001. LNCS, vol. 2180, pp. 300–314. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  15. 15.
    Sulzmann, M., Lam, E.S., Marlow, S.: Comparing the performance of concurrent linked-list implementations in haskell (abstract only). SIGPLAN Not. 44, 9 (2009)CrossRefGoogle Scholar
  16. 16.
    Valois, J.D.: Lock-free linked lists using compare-and-swap. In: Proceedings of the Fourteenth Annual ACM Symposium on Principles of Distributed Computing, PODC 1995, pp. 214–222. ACM, New York (1995)CrossRefGoogle Scholar
  17. 17.
    Stolz, V., Huch, F.: Runtime verification of concurrent haskell programs. In: Proceedings of the Fourth Workshop on Runtime Verification, pp. 201–216. Elsevier Science Publishers (2004)Google Scholar
  18. 18.
    Papaefthymiou, M., Rodrigue, J.: Implementing parallel shortest-paths algorithms. In: Bhatt, S.N. (ed.) Parallel Algorithms. DIMACS Series in Discrete Mathematics and Theoretical Computer Science, vol. 30, pp. 59–68. American Mathematical Society (1997)Google Scholar
  19. 19.
    Subramanian, S.: Parallel and dynamic shortest-path algorithms for sparse graphs. Technical report, Providence, RI, USA (1995)Google Scholar
  20. 20.
    Claessen, K., Hughes, J.: Quickcheck: A lightweight tool for random testing of haskell programs. In: ICFP, pp. 268–279. ACM Press, New York (2000)CrossRefGoogle Scholar
  21. 21.
    Jones, D., Marlow, S., Singh, S.: Parallel performance tuning for haskell. In: Haskell 2009: Proceedings of the Second ACM SIGPLAN Symposium on Haskell. ACM (2009)Google Scholar
  22. 22.
    Dragicevic, K., Bauer, D.: A survey of concurrent priority queue algorithms. In: IPDPS, pp. 1–6. IEEE (2008)Google Scholar
  23. 23.
    Okasaki, C.: Purely functional data structures. Cambridge University Press, Cambridge (1998)CrossRefGoogle Scholar
  24. 24.
    O’Sullivan, B., Tibell, J.: Scalable i/o event handling for ghc. In: Proceedings of the Third ACM Haskell Symposium on Haskell 2010, pp. 103–108. ACM, New York (2010)CrossRefGoogle Scholar
  25. 25.
    Newton, R., Chen, C.P., Marlow, S.: Intel concurrent collections for haskell. Submitted to the Haskell Symposium 2010 (2010)Google Scholar
  26. 26.
    Chakravarty, M.M.T., Leshchinskiy, R., Jones, S.P., Keller, G., Marlow, S.: Data parallel haskell: a status report. In: Proceedings of the 2007 Workshop on Declarative Aspects of Multicore Programming, DAMP 2007, pp. 10–18. ACM, New York (2007)CrossRefGoogle Scholar
  27. 27.
    Marlow, S., Peyton Jones, S., Singh, S.: Runtime support for multicore haskell. SIGPLAN Not. 44(9), 65–78 (2009)CrossRefGoogle Scholar
  28. 28.
    Wicke, G.: The bits-atomic package on hackage, http://hackage.haskell.org/package/bits-atomic
  29. 29.

Copyright information

© Springer-Verlag Berlin Heidelberg 2012

Authors and Affiliations

  • Michael Lesniak
    • 1
  1. 1.Research Group Programming Languages / MethodologiesUniversity of KasselKasselGermany

Personalised recommendations