Advertisement

Fully persistent arrays for efficient incremental updates and voluminous reads

Conference paper
  • 387 Downloads
Part of the Lecture Notes in Computer Science book series (LNCS, volume 582)

Abstract

The array update problem in a purely functional language is the following: once an array is updated, both the original array and the newly updated one must be preserved to maintain referential transparency. We devise a very simple, fully persistent data structure to tackle this problem such that
  • each incremental update costs O(1) worst-case time,

  • a voluminous sequence of r reads cost in total O(r) amortized time, and

  • the data structure use O(n + u) space, where n is the size of the array and u is the total number of updates. A sequence of r reads is voluminous if r is Ω(n) and the sequence of arrays being read forms a path of length O(r) in the version tree. A voluminous sequence of reads may be mixed with updates without affecting either the performance of reads or updates.

An immediate consequence of the above result is that if a functional program is single-threaded, then the data structure provides a simple and efficient implementation of functional arrays. This result is not new. What is new is that many multi-threaded functional array applications also exhibit the incremental updates/voluminous reads execution pattern. Those applications can also be efficiently implemented by the proposed data structure.

A comparison of our method to previous approaches to the array update problem is briefly discussed. Empirical results have been collected to measure the effectiveness of the proposed data structure.

Keywords

Root Node Read Sequence Read Operation Current Environment Version Tree 
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.

References

  1. [1]
    12th Annual ACM Symposium on Principles of Programming Languages. A.C.M., January 1985. New Orleans, Louisiana, U.S.A.Google Scholar
  2. [2]
    Functional Programming Languages and Computer Architecture. A.C.M./Addison-Wesley, September 1989. Imperial College, London, U.K.Google Scholar
  3. [3]
    Proceedings of the 1990 ACM Conference on Lisp and Functional Programming. A.C.M., June 1990. Nice, France.Google Scholar
  4. [4]
    18th Annual ACM Symposium on Principles of Programming Languages. A.C.M., January 1991. Orlando, Florida, U.S.A.Google Scholar
  5. [5]
    Proceedings of the Symposium on Partial Evaluation and and Semantics-Based Program Manipulation. A.C.M., June 1991. New Haven, Connecticut, U.S.A. Also appears as SIG-PLAN Notices, 26(9), September 1991.Google Scholar
  6. [6]
    Annika Aasa, Sören Holmström, and Christina Nilsson. An efficiency comparison of some representations of purely functional arrays. BIT, 28(3):490–503, 1988.Google Scholar
  7. [7]
    Henry G. Baker, Jr. Shallow binding in Lisp 1.5. Communications of the ACM, 21(7):565–569, July 1978.Google Scholar
  8. [8]
    Henry G. Baker. Shallow binding makes functional arrays fast. SIGPLAN Notices, 26(8):145–147, August 1991.Google Scholar
  9. [9]
    Adrienne Gael Bloss. Path Analysis and the Optimization of Non-Strict Functional Languages. PhD thesis, Department of Computer Science, Yale University, May 1989. Also appears as report YALEU/DCS/RR-704.Google Scholar
  10. [10]
    Adrienne Bloss. Update analysis and the efficient implementation of functional aggregates. pages 26–38. In [2]Google Scholar
  11. [11]
    Frank Dehne, Jörg-Rüdiger Sack, and Nicola Santoro, editors. Algorithms and Data Structures. Ottawa, Canada, August 1989. Lecture Notes in Computer Science, Volume 382, Springer-Verlag.Google Scholar
  12. [12]
    Paul F. Dietz. Fully persistent arrays. pages 67–74. In [11].Google Scholar
  13. [13]
    James R. Driscoll, Neil Sarnak, Daniel D. Sleator, and Robert E. Tarjan. Making data structures persistent. Journal of Computer and System Sciences, 38(1):86–124, February 1989.Google Scholar
  14. [14]
    Juan C. Guzmán and Paul Hudak. Single-threaded polymorphic lambda calculus. In Proceedings of 5th Annual IEEE Symposium on Logic in Computer Science, pages 333–343. I.E.E.E., June 1990.Google Scholar
  15. [15]
    Sören Holmström. How to handle large data structures in functional languages. In Proceedings of the SERC Chalmers Workshop on Declarative Programming Languages. University College London, 1983.Google Scholar
  16. [16]
    Paul Hudak and Adrienne Bloss. The aggregate update problem in functional programming systems. pages 300–314. In [1].Google Scholar
  17. [17]
    Paul Hudak, Simon Peyton Jones, and Philip Wadler, editors. Report on the Programming Language Haskell — A Non-Strict, Purely Functional Language, Version 1.1. August 1991. Available from Yale University and University of Glasgow.Google Scholar
  18. [18]
    John Hughes. An efficient implementation of purely functional arrays. Technical report, Department of Computer Sciences, Chalmers University of Technology, 1985.Google Scholar
  19. [19]
    Martin Odersky. How to make destructive updates less destructive. pages 25–36. In [4].Google Scholar
  20. [20]
    Paul Walton Purdom, Jr. and Cynthia A. Brown. The Analysis of Algorithms. Holt, Rinehart and Winston, 1985.Google Scholar
  21. [21]
    David A. Schmidt. Detecting global variables in denotational specifications. ACM Transactions on Programming Languages and Systems, 7(2):299–310, April 1985.Google Scholar
  22. [22]
    J. T. Schwartz. Optimization of very high level languages — i. value transmission and its corollaries. Computer Languages, 1(2):161–194, June 1975.Google Scholar
  23. [23]
    J. T. Schwartz. Optimization of very high level languages — ii. deducing relationships of inclusion and membership. Computer Languages, 1(3):197–218, September 1975.Google Scholar
  24. [24]
    Robert Endre Tarjan. Amortized computational complexity. SIAM Journal on Algebraic and Discrete Methods, 6(2):306–318, April 1985.Google Scholar
  25. [25]
    Philip Wadler. Comprehending monads. pages 61–78. In [3].Google Scholar
  26. [26]
    Philip Wadler. Is there a use for linear logic? pages 255–273. In [5], 26(9), September 1991.Google Scholar
  27. [27]
    Stephen Warshall. A theorem on boolean matrices. Journal of the Association for Computing Machinery, 9(1):11–12, January 1962.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1992

Authors and Affiliations

  1. 1.Department of Computer Science Courant Institute of Mathematical SciencesNew York UniversityNew YorkUSA

Personalised recommendations