Advertisement

Optimizing C Multithreaded Memory Management Using Thread-Local Storage

  • Yair Sade
  • Mooly Sagiv
  • Ran Shaham
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3443)

Abstract

Dynamic memory management in C programs can be rather costly. Multithreading introduces additional synchronization overhead of C memory management functions (malloc, free). In order to reduce this overhead, we extended Hoard — a state of the art memory allocator with the ability to allocate thread-local storage. Experimental results using the tool show runtime saving of up to 44% for a set of memory management benchmarks.

To allow transparent usage of thread-local storage, we develop a compile-time algorithm, which conservatively detects allocation sites that can be replaced by thread-local allocations. Our static analysis is sound, i.e., every detected thread-local storage is indeed so, although we may fail to identify opportunities for allocating thread-local storage. Technically, we reduce the problem of estimating thread-local storage to the problem of escape analysis and provide an efficient escape analysis for C. We solve the problem of escape analysis for C using existing points-to analysis algorithms. Our solution is parameterized by the points-to information. We empirically evaluated the solution with two different methods for computing points-to information. The usage of scalable points-to analysis algorithms and the fact that our reduction is efficient, guarantees that our static analysis technique is scalable.

Keywords

Memory Management Multithreaded Program Memory Allocator Dynamic Memory Allocation Dummy Block 
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.
    Apache http Server Project, Available at http://httpd.apache.org
  2. 2.
    Lea, D.: A Memory Allocator, Available at http://g.oswego.edu/dl/html/malloc.html
  3. 3.
    Microquill Inc., Available at http://www.microquill.com
  4. 4.
    openssl cryptographic library, Available at http://www.openssl.org
  5. 5.
    zlib compression library, Available at http://www.zlib.org
  6. 6.
    Aldrich, J., Sirer, E.G., Chambers, C., Eggers, S.J.: Comprehensive synchronization elimination for Java. Technical Report, University of Washington (October 2000)Google Scholar
  7. 7.
    Andersen, L.: Program Analysis and Specialization for the C Programming Language. PhD thesis, DIKU Univ. of Copenhagen., Copenhagen, Denmark (1994)Google Scholar
  8. 8.
    Berger, E.: Hoard: AScalable Memory Allocator for Multithreaded Applications. In: Architectural Support for Programming Languages and Operating Systems, Cambridge, Massachusetts, US, November 2000, pp. 117–128 (2000)Google Scholar
  9. 9.
    Berger, E.D., Zorn, B.G., McKinley, K.S.: Reconsidering Custom Memory Allocation. In: Conf. on Object-Oriented Prog. Syst., Lang. and Appl., Seattle, Washington, US, November 2002, pp. 1–12 (2002)Google Scholar
  10. 10.
    Blanchet, B.: Escape Analysis for Object Oriented Languages. Application to Java. In: Conf. on Object-Oriented Prog. Syst., Lang. and Appl., Denver, Colorado, US, November 1999, pp. 20–34 (1999)Google Scholar
  11. 11.
    Boehm, H.: Fast Multiprocessor Memory Allocation and Garbage Collection. Tech Report, HP Labs (December 2000)Google Scholar
  12. 12.
    Bogda, J., Hoelzle, U.: Removing unnecessary synchronization in Java. In: Conf. on Object-Oriented Prog. Syst., Lang. and Appl., Denver, Colorado, US, November 1999, pp. 35–46 (1999)Google Scholar
  13. 13.
    Choi, J., Gupta, M., Serrano, M., Sreedhar, V., Midkiff, S.: Escape Analysis for Java. In: Conf. on Object-Oriented Prog. Syst., Lang. and Appl., Denver, Colorado, US, November 1999, pp. 1–19 (1999)Google Scholar
  14. 14.
    Das, M.: Unification-based Pointer Analysis with Directional Assignments. In: SIGPLAN Conf. on Prog. Lang. Design and Impl., Vancouver, Canada, June 2000, vol. 35, pp. 35–46 (2000)Google Scholar
  15. 15.
    Das, M., Liblit, B., Fähndrich, M., Rehof, J.: Estimating the impact of scalable pointer analysis on optimization. In: Cousot, P. (ed.) SAS 2001. LNCS, vol. 2126, pp. 260–278. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  16. 16.
    Domani, T., Goldshtein, G., Kolodner, E.K., Lewis, E., Petrank, E., Sheinwald, D.: Thread-local heaps for java. In: Int. Symp. on Memory Management, Berlin, Germany, pp. 76–87 (2002)Google Scholar
  17. 17.
    Heintze, N.: Analysis of Large Code Bases: The Compile-Link-Analyse Model. Unpublished Report (November 1999)Google Scholar
  18. 18.
    Heintze, N., Tardieu, O.: Ultra-fast Aliasing Analysis using cla: A Million Lines of C Code in a Second. In: SIGPLAN Conf. on Prog. Lang. Design and Impl., Snowbird, Utah, US, May 2001, pp. 254–263 (2001)Google Scholar
  19. 19.
    Larson, P., Krishnan, M.: Memory Allocation for Long-running Server Applications. In: Int. Symp. on Memory Management, Vancouver, Canada, October 1998, pp. 176–185 (1998)Google Scholar
  20. 20.
    Lever, C., Boreham, D.: malloc() performance in a multithreaded linux environment. In: USENIX, the Advanced Computing System Association, San Diego, California, US (2000)Google Scholar
  21. 21.
    Michael, M.M.: Scalable Lock-Free Dynamic Memory Allocation. In: SIGPLAN Conf. on Prog. Lang. Design and Impl., Washington, US, June 2004, pp. 35–46 (2004)Google Scholar
  22. 22.
    Rinard, M.: Analysis of multithreaded programs. In: Static Analysis Symp., Paris, France, July 2001, pp. 1–19 (2001)Google Scholar
  23. 23.
    Ruf, E.: Effective Synchronization Removal for Java. In: SIGPLAN Conf. on Prog. Lang. Design and Impl., Vancouver, Canada, June 2000, pp. 208–218 (2000)Google Scholar
  24. 24.
    Rugina, R., Rinard, M.: Pointer Analysis for Multithreaded Programs. In: SIGPLAN Conf. on Prog. Lang. Design and Impl., Atlanta, Georgia, US, May 1999, pp. 77–90 (1999)Google Scholar
  25. 25.
    Sade, Y.: Optimizing C Multithreaded Memory Management Using Thread-Local Storage. Master’s thesis, Tel-Aviv University, Tel-Aviv, Israel (2004)Google Scholar
  26. 26.
    Salcianu, A., Rinard, M.: Pointer and Escape Analysis for Multithreaded Programs. In: Principles Practice of Parallel Programming, Atlanta, Georgia, US, June 2001, pp. 12–23 (2001)Google Scholar
  27. 27.
    Steensgaard, B.: Points-to Analysis in Almost Linear Time. In: Symp. on Princ. of Prog. Lang., St. Petersburg Beach, Florida, US, January 1996, pp. 32–41. ACM Press, New York (1996)Google Scholar
  28. 28.
    Steensgaard, B.: Thread-Specific Heaps for Multi-Threaded Programs. In: Int. Symp. on Memory Management, Minneapolis, Minnesota, US, October 2000, pp. 18–24 (2000)Google Scholar
  29. 29.
    Wilson, R.P., Lam, M.S.: Efficient Context-Sensitive Pointer Analysis for C Programs. In: SIGPLAN Conf. on Prog. Lang. Design and Impl., pp. 1–12 (1995)Google Scholar
  30. 30.
    Yang, S., Horwitz, S., Reps, T.: Pointer Analysis for Programs with Structures and Casting. In: SIGPLAN Conf. on Prog. Lang. Design and Impl., Atlanta, Georgia, US, May 1999, pp. 91–103 (1999)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2005

Authors and Affiliations

  • Yair Sade
    • 1
  • Mooly Sagiv
    • 1
  • Ran Shaham
    • 2
  1. 1.Tel-Aviv University 
  2. 2.IBM Haifa Laboratories 

Personalised recommendations