Skip to main navigation Skip to search Skip to main content

Compact and efficient strings for Java

Research output: Contribution to journalArticlepeer-review

Abstract

In several Java VMs, strings consist of two separate objects: metadata such as 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 an improved performance as well as a reduction of the memory usage. 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%.
Original languageEnglish
Pages (from-to)1077-1094
Number of pages18
JournalScience of Computer Programming
Volume75
Issue number11
DOIs
Publication statusPublished - Nov 2010

Fields of science

  • 102 Computer Sciences

JKU Focus areas

  • Computation in Informatics and Mathematics

Cite this