Abstract
Purely functional data structures stored inside a mutable variable provide an excellent concurrent data structure—obviously correct, cheap to create, and supporting snapshots. They are not, however, scalable. We provide a way to retain the benefits of these pure-in-a-box data structures while dynamically converting to a more scalable lock-free data structure under contention. Our solution scales to any pair of pure and lock-free container types with key/value set semantics, while retaining lock-freedom. We demonstrate the principle in action on two very different platforms: first in the Glasgow Haskell Compiler and second in Java. To this end we extend GHC to support lock-free data structures and introduce a new approach for safe CAS in a lazy language.
- S. Adams. Functional pearls efficient setsa balancing act. Journal of functional programming, 3(04):553–561, 1993.Google Scholar
- S. Bauman, C. F. Bolz, R. Hirschfeld, V. Krilichev, T. Pape, J. Siek, and S. Tobin-Hochstadt. Pycket: A tracing jit for a functional language.Google Scholar
- C. F. Bolz, L. Diekmann, and L. Tratt. Storage strategies for collections in dynamically typed languages. SIGPLAN Not., 48(10):167– 182, Oct. 2013. ISSN 0362-1340.. URL http://doi.acm.org/ 10.1145/2544173.2509531. Google Scholar
Digital Library
- J. Cieslewicz, K. A. Ross, K. Satsumi, Y. Ye, and Q. Processing. Automatic contention detection and amelioration for data-intensive operations. In In SIGMOD, 2010. Google Scholar
Digital Library
- T. H. Cormen, C. Stein, R. L. Rivest, and C. E. Leiserson. Introduction to Algorithms. McGraw-Hill Higher Education, 2nd edition, 2001. ISBN 0070131511. Google Scholar
Digital Library
- K. Fraser. Practical lock-freedom. PhD thesis, University of Cambridge, 2004.Google Scholar
- A. Gill and G. Hutton. The worker/wrapper transformation. J. Funct. Program., 19(2):227–251, Mar. 2009. ISSN 0956-7968. Google Scholar
Digital Library
- . URL http://dx.doi.org/10.1017/S0956796809007175.Google Scholar
- J. N. Gray, R. A. Lorie, and G. R. Putzolu. Granularity of locks in a shared data base. In Proceedings of the 1st International Conference on Very Large Data Bases, VLDB ’75, pages 428–451, New York, NY, USA, 1975. ACM. ISBN 978-1-4503-3920-9.. URL http: //doi.acm.org/10.1145/1282480.1282513. Google Scholar
Digital Library
- D. Hendler, N. Shavit, and L. Yerushalmi. A scalable lock-free stack algorithm. In Proceedings of the Sixteenth Annual ACM Symposium on Parallelism in Algorithms and Architectures, SPAA ’04, pages 206– 215, New York, NY, USA, 2004. ACM. ISBN 1-58113-840-7.. URL http://doi.acm.org/10.1145/1007912.1007944. Google Scholar
Digital Library
- M. Herlihy, Y. Lev, V. Luchangco, and N. Shavit. A provably correct scalable concurrent skip list. In Conference On Principles of Distributed Systems (OPODIS). Citeseer, 2006.Google Scholar
- M. P. Herlihy and J. M. Wing. Linearizability: A correctness condition for concurrent objects. ACM Trans. Program. Lang. Syst., 12(3):463– 492, July 1990. ISSN 0164-0925.. URL http://doi.acm.org/ 10.1145/78969.78972. Google Scholar
Digital Library
- M. Letia, N. M. Preguic¸a, and M. Shapiro. Crdts: Consistency without concurrency control. CoRR, abs/0907.0929, 2009. URL http:// arxiv.org/abs/0907.0929.Google Scholar
- S. Marlow and S. P. Jones. Making a fast curry: Push/enter vs. eval/apply for higher-order languages. J. Funct. Program., 16(4-5): 415–449, July 2006. ISSN 0956-7968.. URL http://dx.doi. org/10.1017/S0956796806005995. Google Scholar
Digital Library
- S. Marlow and S. Peyton Jones. Multicore garbage collection with local heaps. In ACM SIGPLAN Notices, volume 46, pages 21–32. ACM, 2011. Google Scholar
Digital Library
- S. Marlow, S. Peyton Jones, and S. Singh. Runtime support for multicore haskell. SIGPLAN Not., 44(9):65–78, Aug. 2009. ISSN 0362-1340. Google Scholar
Digital Library
- . URL http://doi.acm.org/10.1145/1631687.Google Scholar
- 1596563.Google Scholar
- J. Nievergelt and E. M. Reingold. Binary search trees of bounded balance. SIAM journal on Computing, 2(1):33–43, 1973.Google Scholar
- S. Peyton Jones, A. Gordon, and S. Finne. Concurrent haskell. In Proceedings of the 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL ’96, pages 295–308, New York, NY, USA, 1996. ACM. ISBN 0-89791-769-3.. URL http: //doi.acm.org/10.1145/237721.237794. Google Scholar
Digital Library
- O. Shalev and N. Shavit. Split-ordered lists: Lock-free extensible hash tables. J. ACM, 53(3):379–405, May 2006. ISSN 0004-5411.. URL http://doi.acm.org/10.1145/1147954.1147958. Google Scholar
Cross Ref
- N. Shavit. Data structures in the multicore age. Commun. ACM, 54: 76–84, Mar. 2011. ISSN 0001-0782.. URL http://doi.acm.org/ 10.1145/1897852.1897873. Google Scholar
Digital Library
- N. Shavit and D. Touitou. Elimination trees and the construction of pools and stacks: Preliminary version. In Proceedings of the Seventh Annual ACM Symposium on Parallel Algorithms and Architectures, SPAA ’95, pages 54–63, New York, NY, USA, 1995. ACM. ISBN 0-89791-717-0.. URL http://doi.acm.org/10.1145/215399. Google Scholar
Digital Library
- 215419.Google Scholar
- H. Sundell, A. Gidenstam, M. Papatriantafilou, and P. Tsigas. A lockfree algorithm for concurrent bags. In Proceedings of the 23rd ACM symposium on Parallelism in algorithms and architectures, SPAA ’11, pages 335–344, New York, NY, USA, 2011. ACM. ISBN 978-1- 4503-0743-7.. URL http://doi.acm.org/10.1145/1989493. Google Scholar
Digital Library
- 1989550.Google Scholar
- G. Taubenfeld. Contention-sensitive data structures and algorithms. In Proceedings of the 23rd International Conference on Distributed Computing, DISC’09, pages 157–171, Berlin, Heidelberg, 2009. Springer-Verlag. ISBN 3-642-04354-2, 978-3-642-04354-3. URL http://dl.acm.org/citation.cfm?id=1813164.1813186. Google Scholar
Digital Library
- G. Xu. Coco: Sound and adaptive replacement of java collections. In Proceedings of the 27th European Conference on Object-Oriented Programming, ECOOP’13, pages 1–26, Berlin, Heidelberg, 2013. Springer-Verlag. ISBN 978-3-642-39037-1.. URL http://dx.doi. org/10.1007/978-3-642-39038-8_1. Google Scholar
Digital Library
- Q. Zhao, D. Koh, S. Raza, D. Bruening, W.-F. Wong, and S. Amarasinghe. Dynamic cache contention detection in multi-threaded applications. In Proceedings of the 7th ACM SIGPLAN/SIGOPS International Conference on Virtual Execution Environments, VEE ’11, pages 27– 38, New York, NY, USA, 2011. ACM. ISBN 978-1-4503-0687-4.. URL http://doi.acm.org/10.1145/1952682.1952688. Google Scholar
Digital Library
Index Terms
Adaptive lock-free maps: purely-functional to scalable
Recommendations
Adaptive lock-free maps: purely-functional to scalable
ICFP 2015: Proceedings of the 20th ACM SIGPLAN International Conference on Functional ProgrammingPurely functional data structures stored inside a mutable variable provide an excellent concurrent data structure—obviously correct, cheap to create, and supporting snapshots. They are not, however, scalable. We provide a way to retain the benefits of ...
Adaptive lock-free data structures in Haskell: a general method for concurrent implementation swapping
Haskell 2017: Proceedings of the 10th ACM SIGPLAN International Symposium on HaskellA key part of implementing high-level languages is providing built- in and default data structures. Yet selecting good defaults is hard. A mutable data structure’s workload is not known in advance, and it may shift over its lifetime—e.g., between read-...
Adaptive lock-free data structures in Haskell: a general method for concurrent implementation swapping
Haskell '17A key part of implementing high-level languages is providing built- in and default data structures. Yet selecting good defaults is hard. A mutable data structure’s workload is not known in advance, and it may shift over its lifetime—e.g., between read-...






Comments