skip to main content
10.1145/1411732.1411747acmconferencesArticle/Chapter ViewAbstractPublication PagespppjConference Proceedingsconference-collections
research-article

Optimized strings for the Java HotSpot™ virtual machine

Published: 09 September 2008 Publication History

Abstract

In several Java VMs, strings consist of two separate objects: metadata like the string length are stored in the actual string object, while the string characters are stored in a character array. This separation causes an unnecessary overhead. Each string method must access both objects, which leads to a bad cache behavior and reduces the execution speed.
We propose to merge the character array with the string's metadata object at run time. This results in a new layout of strings with better cache performance, fewer field accesses, and less memory overhead. We implemented this optimization for Sun Microsystems' Java HotSpot™ VM, so that the optimization is performed automatically at run time and requires no actions on the part of the programmer. The original class String is transformed into the optimized version and the bytecodes of all methods that allocate string objects are rewritten. All these transformations are performed by the Java HotSpot™ VM when a class is loaded. Therefore, the time overhead of the transformations is negligible.
Benchmarks show a reduction of the average used memory after a full garbage collection and an improved performance. The performance of the SPECjbb2005 benchmark increases by 8%, and the average used memory after a full garbage collection is reduced by 19%. The peak performance of SPECjvm98 is improved by 8% on average, with a maximum speedup of 62%.

References

[1]
C. S. Ananian and M. Rinard. Data size optimizations for Java programs. In Proceedings of the ACM SIGPLAN Conference on Languages, Compilers, and Tools for Embedded Systems, pages 59--68. ACM Press, 2003.
[2]
S. M. Blackburn, R. Garner, C. Hoffman, A. M. Khan, K. S. McKinley, R. Bentzur, A. Diwan, D. Feinberg, D. Frampton, S. Z. Guyer, M. Hirzel, A. Hosking, M. Jump, H. Lee, J. E. B. Moss, A. Phansalkar, D. Stefanović, T. VanDrunen, D. von Dincklage, and B. Wiedermann. The DaCapo benchmarks: Java benchmarking development and analysis. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 169--190. ACM Press, 2006.
[3]
P. Boldi and S. Vigna. Mutable strings in Java: Design, implementation and lightweight text-search algorithms. Science of Computer Programming, 54(1):3--23, 2005.
[4]
G. Chen, M. Kandemir, and M. J. Irwin. Exploiting frequent field values in Java objects for reducing heap memory requirements. In Proceedings of the ACM/USENIX International Conference on Virtual Execution Environments, pages 68--78. ACM Press, 2005.
[5]
G. Chen, M. Kandemir, N. Vijaykrishnan, M. J. Irwin, B. Mathiske, and M. Wolczko. Heap compression for memory-constrained Java environments. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 282--301. ACM Press, 2003.
[6]
R. Cytron, J. Ferrante, B. K. Rosen, M. N. Wegman, and F. K. Zadeck. Efficiently computing static single assignment form and the control dependence graph. ACM Transactions on Programming Languages and Systems, 13(4):451--490, 1991.
[7]
J. Dolby and A. Chien. An automatic object inlining optimization and its evaluation. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 345--357. ACM Press, 2000.
[8]
J. Gosling, B. Joy, G. Steele, and G. Bracha. The Java#8482; Language Specification. Addison-Wesley, 3rd edition, 2005.
[9]
R. Griesemer and S. Mitrovic. A compiler for the Java HotSpot#8482; virtual machine. In L. Böszörményi, J. Gutknecht, and G. Pomberger, editors, The School of Niklaus Wirth: The Art of Simplicity, pages 133--152. dpunkt.verlag, 2000.
[10]
T. Kotzmann, C. Wimmer, H. Mössenböck, T. Rodriguez, K. Russell, and D. Cox. Design of the Java HotSpot#8482; client compiler for Java 6. ACM Transactions on Architecture and Code Optimization, 5(1):7, 2008.
[11]
T. Lindholm and F. Yellin. The Java#8482; Virtual Machine Specification. Addison-Wesley, 2nd edition, 1999.
[12]
M. Paleczny, C. Vick, and C. Click. The Java HotSpot#8482; server compiler. In Proceedings of the Java Virtual Machine Research and Technology Symposium, pages 1--12. USENIX, 2001.
[13]
K. Russell and D. Detlefs. Eliminating synchronization-related atomic operations with biased locking and bulk rebiasing. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, pages 263--272. ACM Press, 2006.
[14]
Standard Performance Evaluation Corporation. The SPECjvm98 Benchmarks, 1998. http://www.spec.org/jvm98/.
[15]
Standard Performance Evaluation Corporation. The SPECjbb2005 Benchmark, 2005. http://www.spec.org/jbb2005/.
[16]
Sun Microsystems, Inc. Java Platform, Standard Edition 7 Source Snapshot Releases, 2007. http://download.java.net/jdk7/.
[17]
Y. H. Tian. String concatenation optimization on Java bytecode. In Proceedings of the Conference on Programming Languages and Compilers, pages 945--951. CSREA Press, 2006.
[18]
R. Vallée-Rai, P. Co, E. Gagnon, L. Hendren, P. Lam, and V. Sundaresan. Soot - A Java optimization framework. In Proceedings of the Conference of the Centre for Advanced Studies on Collaborative Research, pages 125--135. IBM Press, 1999.
[19]
C. Wimmer and H. Mössenböck. Automatic feedback-directed object inlining in the Java HotSpot#8482; virtual machine. In Proceedings of the ACM/USENIX International Conference on Virtual Execution Environments, pages 12--21. ACM Press, 2007.
[20]
C. Wimmer and H. Mössenböck. Automatic array inlining in Java virtual machines. In Proceedings of the International Symposium on Code Generation and Optimization, pages 14--23. ACM Press, 2008.

Cited By

View all
  • (2021)Compiler-assisted object inlining with value fieldsProceedings of the 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation10.1145/3453483.3454034(128-141)Online publication date: 19-Jun-2021

Index Terms

  1. Optimized strings for the Java HotSpot™ virtual machine

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    PPPJ '08: Proceedings of the 6th international symposium on Principles and practice of programming in Java
    September 2008
    198 pages
    ISBN:9781605582238
    DOI:10.1145/1411732
    • Conference Chairs:
    • Luis Veiga,
    • Vasco Amaral
    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

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 09 September 2008

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. Java
    2. optimization
    3. performance
    4. string

    Qualifiers

    • Research-article

    Conference

    PPPJ08
    Sponsor:

    Acceptance Rates

    Overall Acceptance Rate 29 of 58 submissions, 50%

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)18
    • Downloads (Last 6 weeks)1
    Reflects downloads up to 07 Mar 2025

    Other Metrics

    Citations

    Cited By

    View all
    • (2021)Compiler-assisted object inlining with value fieldsProceedings of the 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation10.1145/3453483.3454034(128-141)Online publication date: 19-Jun-2021

    View Options

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Figures

    Tables

    Media

    Share

    Share

    Share this Publication link

    Share on social media