Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/3377813.3381368acmconferencesArticle/Chapter ViewAbstractPublication PagesicseConference Proceedingsconference-collections
research-article

Escape from escape analysis of Golang

Published: 18 September 2020 Publication History

Abstract

Escape analysis is widely used to determine the scope of variables, and is an effective way to optimize memory usage. However, the escape analysis algorithm can hardly reach 100% accurate, mistakes of which can lead to a waste of heap memory. It is challenging to ensure the correctness of programs for memory optimization.
In this paper, we propose an escape analysis optimization approach for Go programming language (Golang), aiming to save heap memory usage of programs. First, we compile the source code to capture information of escaped variables. Then, we change the code so that some of these variables can bypass Golang's escape analysis mechanism, thereby saving heap memory usage and reducing the pressure of memory garbage collection. Next, we present a verification method to validate the correctness of programs, and evaluate the effect of memory optimization. We implement the approach to an automatic tool and make it open-source1. For evaluation, we apply our approach to 10 open-source projects. For the optimized Golang code, the heap allocation is reduced by 8.88% in average, and the heap usage is reduced by 8.78% in average. Time consumption is reduced by 9.48% in average, while the cumulative time of GC pause is reduced by 5.64% in average. We also apply our approach to 16 industrial projects in Bytedance Technology. Our approach successfully finds 452 optimized cases which are confirmed by developers.

References

[1]
William A Arbaugh, Nick Louis Petroni Jr, Timothy Jon Fraser, and Jesus Maria Molina-Terriza. 2015. Method and system for monitoring system memory integrity. (Feb. 10 2015). US Patent 8,955,104.
[2]
David Bernstein. 2014. Containers and cloud: From lxc to docker to kubernetes. IEEE Cloud Computing 1, 3 (2014), 81--84.
[3]
Bruno Blanchet. 1998. Escape analysis: Correctness proof, implementation and experimental results. In Proceedings of the 25th ACM SIGPLAN-SIGACT symposium on Principles of programming languages. ACM, 25--37.
[4]
Bruno Blanchet. 1999. Escape analysis for object-oriented languages: application to Java. In Acm Sigplan Notices, Vol. 34. ACM, 20--34.
[5]
Bruno Blanchet. 2003. Escape analysis for Java TM: Theory and practice. ACM Transactions on Programming Languages and Systems (TOPLAS) 25, 6 (2003), 713--775.
[6]
Chien-Wen Chen and Che-Yueh Kuo. 2019. Memory management method, memory control circuit unit and memory storage device. (Jan. 10 2019). US Patent App. 15/690,286.
[7]
Jong-Deok Choi, Manish Gupta, Mauricio Serrano, Vugranam C Sreedhar, and Sam Midkiff. 1999. Escape analysis for Java. Acm Sigplan Notices 34, 10 (1999), 1--19.
[8]
Jong-Deok Choi, Manish Gupta, Mauricio J Serrano, Vugranam C Sreedhar, and Samuel P Midkiff. 2003. Stack allocation and synchronization optimizations for Java using escape analysis. ACM Transactions on Programming Languages and Systems (TOPLAS) 25, 6 (2003), 876--910.
[9]
Alan Deutsch. 1989. On determining lifetime and aliasing of dynamically allocated data in higher-order functional specifications. In Proceedings of the 17th ACM SIGPLAN-SIGACT symposium on Principles of programming languages. ACM, 157--168.
[10]
Alain Deutsch. 1997. On the complexity of escape analysis. In Proceedings of the 24th ACM SIGPLAN-SIGACT symposium on Principles of programming languages. ACM, 358--371.
[11]
Wei Feng, Xiaohua Shi, and Wenru Wang. 2018. Eliminating object reference checks by escape analysis on real-time Java virtual machine. Cluster Computing (2018), 1--12.
[12]
Golang. cited 2019. Golang: Compiler Optimizations. https://github.com/golang/go/wiki/CompilerOptimizations. (cited 2019).
[13]
Benjamin Goldberg and Young Gil Park. 1990. Higher order escape analysis: optimizing stack allocation in functional program implementations. In European Symposium on Programming. Springer, 152--160.
[14]
John Hannan. 1998. A type-based escape analysis for functional languages. Journal of functional programming 8, 3 (1998), 239--273.
[15]
Patricia M Hill and Fausto Spoto. 2002. A foundation of escape analysis. In International Conference on Algebraic Methodology and Software Technology. Springer, 380--395.
[16]
Jeff Huang. 2016. Scalable thread sharing analysis. In Proceedings of the 38th International Conference on Software Engineering. ACM, 1097--1108.
[17]
Richard Jones and Rafael Lins. 1996. Garbage collection: algorithms for automatic dynamic memory management. Vol. 208. Wiley Chichester.
[18]
Thomas Kotzmann and Hanspeter Mössenböck. 2005. Escape analysis in the context of dynamic compilation and deoptimization. In Proceedings of the 1st ACM/USENIX international conference on Virtual execution environments. ACM, 111--120.
[19]
Young Gil Park and Benjamin Goldberg. 1992. Escape analysis on lists. In ACM SIGPLAN Notices, Vol. 27. ACM, 116--127.
[20]
Alexandru Salcianu and Martin Rinard. 2001. Pointer and escape analysis for multithreaded programs. ACM SIGPLAN Notices 36, 7 (2001), 12--23.
[21]
Yulei Sui, Peng Di, and Jingling Xue. 2016. Sparse flow-sensitive pointer analysis for multithreaded programs. In Proceedings of the 2016 International Symposium on Code Generation and Optimization. ACM, 160--170.
[22]
Yan Mei Tang and Pierre Jouvelot. 1992. Control-Flow Effects for Escape Analysis. In WSA. 313--321.
[23]
Frédéric Vivien and Martin Rinard. 2001. Incrementalized pointer and escape analysis. In PLDI. Citeseer, 35--46.
[24]
John Whaley and Martin Rinard. 1999. Compositional pointer and escape analysis for Java programs. ACM Sigplan Notices 34, 10 (1999), 187--206.
[25]
Paul R Wilson. 1992. Uniprocessor garbage collection techniques. In Memory Management. Springer, 1--42.

Cited By

View all
  • (2024)Golang Defect Detection based on Value Flow Analysis2024 9th International Conference on Electronic Technology and Information Science (ICETIS)10.1109/ICETIS61828.2024.10593695(358-363)Online publication date: 17-May-2024

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
ICSE-SEIP '20: Proceedings of the ACM/IEEE 42nd International Conference on Software Engineering: Software Engineering in Practice
June 2020
258 pages
ISBN:9781450371230
DOI:10.1145/3377813
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]

Sponsors

In-Cooperation

  • KIISE: Korean Institute of Information Scientists and Engineers
  • IEEE CS

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 18 September 2020

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. Go programming language
  2. code generation
  3. escape analysis
  4. memory optimization

Qualifiers

  • Research-article

Funding Sources

  • KLISS
  • BNRist

Conference

ICSE '20
Sponsor:

Upcoming Conference

ICSE 2025

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)40
  • Downloads (Last 6 weeks)3
Reflects downloads up to 30 Aug 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Golang Defect Detection based on Value Flow Analysis2024 9th International Conference on Electronic Technology and Information Science (ICETIS)10.1109/ICETIS61828.2024.10593695(358-363)Online publication date: 17-May-2024

View Options

Get Access

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media