skip to main content
research-article
Public Access

A program optimization for automatic database result caching

Published:01 January 2017Publication History
Skip Abstract Section

Abstract

Most popular Web applications rely on persistent databases based on languages like SQL for declarative specification of data models and the operations that read and modify them. As applications scale up in user base, they often face challenges responding quickly enough to the high volume of requests. A common aid is caching of database results in the application's memory space, taking advantage of program-specific knowledge of which caching schemes are sound and useful, embodied in handwritten modifications that make the program less maintainable. These modifications also require nontrivial reasoning about the read-write dependencies across operations. In this paper, we present a compiler optimization that automatically adds sound SQL caching to Web applications coded in the Ur/Web domain-specific functional language, with no modifications required to source code. We use a custom cache implementation that supports concurrent operations without compromising the transactional semantics of the database abstraction. Through experiments with microbenchmarks and production Ur/Web applications, we show that our optimization in many cases enables an easy doubling or more of an application's throughput, requiring nothing more than passing an extra command-line flag to the compiler.

References

  1. S. Abiteboul, R. Hull, and V. Vianu, editors. Foundations of Databases: The Logical Level. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 1st edition, 1995. ISBN 0201537710. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. U. A. Acar, A. Ahmed, and M. Blume. Imperative self-adjusting computation. In Proc. POPL, pages 309–322. ACM, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. M. M. Astrahan, M. W. Blasgen, D. D. Chamberlin, K. P. Eswaran, J. N. Gray, P. P. Griffiths, W. F. King, R. A. Lorie, P. R. McJones, J. W. Mehl, G. R. Putzolu, I. L. Traiger, B. W. Wade, and V. Watson. System R: Relational approach to database management. ACM Trans. Database Syst., 1(2):97–137, June 1976. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. E. Benson, A. Marcus, D. Karger, and S. Madden. Sync kit: a persistent clientside database caching toolkit for data intensive websites. In Proceedings of the 19th international conference on World wide web, pages 121–130. ACM, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. J. A. Blakeley, P.-A. Larson, and F. W. Tompa. Efficiently updating materialized views. In Proc. SIGMOD, pages 61–71. ACM, 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. J. A. Blakeley, N. Coburn, and P.-A. Larson. Updating derived relations: Detecting irrelevant and autonomously computable updates. ACM Trans. Database Syst., 14(3):369–400, Sept. 1989. ISSN 0362-5915. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. A. Cheung, S. Madden, O. Arden, and A. C. Myers. Automatic partitioning of database applications. Proc. VLDB Endow., 5(11):1471–1482, July 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. A. Cheung, A. Solar-Lezama, and S. Madden. Optimizing database-backed applications with query synthesis. In Proc. PLDI, pages 3–14. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. A. Cheung, S. Madden, and A. Solar-Lezama. Sloth: Being lazy is a virtue (when issuing database queries). In Proc. SIGMOD, pages 931–942. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. A. Chlipala. Static checking of dynamically-varying security policies in database-backed applications. In Proc. OSDI, pages 105–118, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. A. Chlipala. An optimizing compiler for a purely functional Web-application language. In Proc. ICFP, pages 10–21. ACM, 2015a. A. Chlipala. Ur/Web: A simple model for programming the Web. In Proc. POPL, pages 153–165. ACM, 2015b. S. Chong, J. Liu, A. C. Myers, X. Qi, K. Vikram, L. Zheng, and X. Zheng. Secure web applications via automatic partitioning. In Proc. SOSP, pages 31–44. ACM, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. E. F. Codd. Relational database: A practical foundation for productivity. Commun. ACM, 25(2):109–117, Feb. 1982. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. E. Cooper, S. Lindley, P. Wadler, and J. Yallop. Links: Web programming without tiers. In Proc. FMCO, pages 266–296, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. B. J. Corcoran, N. Swamy, and M. Hicks. Cross-tier, label-based security enforcement for web applications. In Proc. SIGMOD, pages 931–942. ACM, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. S. Dar, M. J. Franklin, B. T. J´onsson, D. Srivastava, and M. Tan. Semantic data caching and replacement. In Proc. VLDB, pages 330–341. Morgan Kaufmann Publishers Inc., 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. D. Detlefs, G. Nelson, and J. B. Saxe. Simplify: a theorem prover for program checking. Journal of the ACM, 52(3):365–473, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. J. Goldstein and P.-A. Larson. Optimizing queries using materialized views: A practical, scalable solution. In Proc. SIGMOD, pages 331–342. ACM, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. H. Guo, P.-A. Larson, R. Ramakrishnan, and J. Goldstein. Support for relaxed currency and consistency constraints in MTCache. In Proc. SIGMOD, pages 937–938. ACM, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. M. A. Hammer, U. A. Acar, and Y. Chen. CEAL: A C-based language for self-adjusting computation. In Proc. PLDI, pages 25–37. ACM, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Y. Klonatos, C. Koch, T. Rompf, and H. Chafi. Building efficient query engines in a high-level language. Proc. VLDB Endow., 7(10):853–864, June 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. P.-A. Larson and H. Z. Yang. Computing queries from derived relations. In Proc. VLDB, pages 259–269. VLDB Endowment, 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. W.-S. Li, K. S. Candan, W.-P. Hsiung, O. Po, D. Agrawal, Q. Luo, W.-K. W. Huang, Y. Akca, and C. Yilmaz. Cache portal: Technology for accelerating database-driven e-commerce web sites. In VLDB, pages 699–700, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. E. Meijer, B. Beckman, and G. Bierman. LINQ: Reconciling objects, relations and XML in the .NET framework. In Proc. SIGMOD, pages 706–706. ACM, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. A. Ohori and K. Ueno. Making Standard ML a practical database programming language. In Proc. ICFP, pages 307–319. ACM, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. D. R. K. Ports, A. T. Clements, I. Zhang, S. Madden, and B. Liskov. Transactional consistency and automatic management in an application data cache. In Proc. OSDI, pages 1–15. USENIX Association, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. K. Ramachandra and S. Sudarshan. Holistic optimization by prefetching query results. In Proc. SIGMOD, pages 133–144. ACM, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. G. Ramalingam and T. Reps. A categorized bibliography on incremental computation. In Proc. POPL, pages 502–510. ACM, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. T. Rompf and N. Amin. Functional pearl: A SQL to C compiler in 500 lines of code. In Proc. ICFP, pages 2–9. ACM, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. A. Shankar and R. Bod´ık. DITTO: Automatic incrementalization of data structure invariant checks (in Java). In Proc. PLDI, pages 310–319. ACM, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. D. Shasha, F. Llirbat, E. Simon, and P. Valduriez. Transaction chopping: Algorithms and performance studies. ACM Trans. Database Syst., 20(3): 325–363, Sept. 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. M. Stonebraker, G. Held, E. Wong, and P. Kreps. The design and implementation of INGRES. ACM Trans. Database Syst., 1(3):189–222, Sept. 1976. Google ScholarGoogle Scholar

Index Terms

  1. A program optimization for automatic database result caching

      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

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 52, Issue 1
        POPL '17
        January 2017
        901 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/3093333
        Issue’s Table of Contents
        • cover image ACM Conferences
          POPL '17: Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages
          January 2017
          901 pages
          ISBN:9781450346603
          DOI:10.1145/3009837

        Copyright © 2017 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 1 January 2017

        Check for updates

        Qualifiers

        • research-article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!