skip to main content
10.1145/1852761.1852775acmotherconferencesArticle/Chapter ViewAbstractPublication PagespppjConference Proceedingsconference-collections
research-article

Memoization of methods using software transactional memory to track internal state dependencies

Published:15 September 2010Publication History

ABSTRACT

Memoization is a well-known technique for improving the performance of a program, but it has been confined mostly to functional programming, where no mutable state or side-effects exist.

Most object-oriented programs, however, are built around objects with an internal state that is mutable over the course of the program. Therefore, the execution of methods often depends on the internal state of some objects or produces side-effects, thus making the application of memoization impractical for object-oriented programs in general.

In this paper, we propose an extended memoization approach that builds on the support provided by a Software Transactional Memory (STM) to identify both internal state dependencies and side-effects, hence removing many of the limitations of traditional memoization.

We describe the Automatic Transaction-Oriented Memoization (ATOM) system, a thread-safe implementation of our memoization model that requires minimal learning effort from programmers, while offering a simple and customizable interface.

Additionally, we describe a memoization advisory system that collects per-method performance statistics with the ultimate goal of aiding programmers in their task of choosing which methods are profitable to memoize.

We argue that ATOM is the first memoization system adequate to the unique characteristics of object-oriented programs and we show how memoization can be implemented almost for free in systems that use an STM, presenting the reasons why this synergy can be particularly useful in transactional contexts.

We show the usefulness of memoizing object-oriented programs by applying memoization to the STMBench7 benchmark, a standard benchmark developed for evaluating STM> implementations. The memoized version of the benchmark shows up to a 14-fold increase in the throughput for a read-dominated workload.

References

  1. }}U. A. Acar, G. E. Blelloch, and R. Harper. Adaptive functional programming. ACM Trans. Program. Lang. Syst., 28(6):990--1034, 2006. ISSN 0164-0925. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. }}I. Anjo and J. Cachopo. Jaspex: Speculative parallel execution of Java applications. Proc. of the Simpósio de Informática (INFO-RUM) (Lisbon, Portugal, 2009.Google ScholarGoogle Scholar
  3. }}E. Bruneton, R. Lenglet, and T. Coupaye. ASM: a code manipulation tool to implement adaptable systems. Adaptable and extensible component systems, 2002.Google ScholarGoogle Scholar
  4. }}J. Cachopo and A. Rito-Silva. Versioned boxes as the basis for memory transactions. Science of Computer Programming, 63(2): 172--185, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. }}A. Demers, T. Reps, and T. Teitelbaum. Incremental evaluation for attribute grammars with application to syntax-directed editors. In POPL '81: Proceedings of the 8th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 105--116, New York, NY, USA, 1981. ACM. ISBN 0-89791-029-X. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. }}C. Franke, Y. Niu, and D. Zinn. Automated Discovery of Functional Aspects in Imperative Programs.Google ScholarGoogle Scholar
  7. }}R. Guerraoui, M. Kapalka, and J. Vitek. STMBench7: A Benchmark for Software Transactional Memory. ACM SIGOPS Operating Systems Review, 41(3):315--324, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. }}M. Hall and J. Mayeld. Improving the performance of AI software: Payoffs and pitfalls in using automatic memoization. In Proceedings of the Sixth International Symposium on Artificial Intelligence, pages 178--184, 1993.Google ScholarGoogle Scholar
  9. }}J. Manson, W. Pugh, and S. V. Adve. The Java memory model. In POPL '05: Proceedings of the 32nd ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 378--391, New York, NY, USA, 2005. ACM. ISBN 1-58113-830-X. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. }}P. McNamee and M. Hall. Developing a tool for memoizing functions in C++. ACM SIGPLAN Notices, 33(8):17--22, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. }}D. Michie. Memo functions and machine learning. Nature, 218(1): 19--22, 1968.Google ScholarGoogle ScholarCross RefCross Ref
  12. }}H. Rito. ATOM: Automatic Transaction-Oriented Memoization. Master's thesis, Technical University of Lisbon, October 2009. https://dspace.ist.utl.pt/bitstream/2295/569235/1/dissertacao.pdf.Google ScholarGoogle Scholar
  13. }}A. Rountev. Precise Identification of Side-Effect-Free Methods in Java. In ICSM '04: Proceedings of the 20th IEEE International Conference on Software Maintenance, pages 82--91, Washington, DC, USA, 2004. IEEE Computer Society. ISBN 0-7695-2213-0. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. }}N. Shavit and D. Touitou. Software transactional memory. In Proceedings of the fourteenth annual ACM symposium on Principles of distributed computing, pages 204--213. ACM Press New York, NY, USA, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. }}H. Xu, C. Pickett, and C. Verbrugge. Dynamic purity analysis for Java programs. In Proceedings of the 7th ACM SIGPLAN-SIGSOFT workshop on Program analysis for software tools and engineering, pages 75--82. ACM Press New York, NY, USA, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. }}L. Ziarek and S. Jagannathan. Memoizing multi-threaded transactions. In Workshop on Declarative Aspects of Multicore Programming, 2008.Google ScholarGoogle Scholar

Index Terms

  1. Memoization of methods using software transactional memory to track internal state dependencies

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • Published in

      cover image ACM Other conferences
      PPPJ '10: Proceedings of the 8th International Conference on the Principles and Practice of Programming in Java
      September 2010
      173 pages
      ISBN:9781450302692
      DOI:10.1145/1852761

      Copyright © 2010 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 15 September 2010

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article

      Acceptance Rates

      Overall Acceptance Rate29of58submissions,50%

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader