JDK-8260030: Improve stringStream buffer handling #2160
stringStream objects are used as temporary string buffers a lot in hotspot. When investigating JDK-8259710, I found that a large majority of the stringStreams created never use the backing buffer fully; about 70% of all streams write less than 32 characters.
stringStream creates an backing buffer, C-heap allocated, with a default size of 256 characters. Some things could be improved:
This patch drastically reduces the number of malloc calls done from this class. The internal buffer size of 32byte seems a good cut-off. Running some unrelated test program (no tracing active), I see a reduction in the number of malloc calls from stringStream from ~211K malloc calls down to 53K (debug VM). In a release VM, it drops from ~85K down to about 1K. The reason is that
I also tweaked the associated gtest to test more thoroughly.
The text was updated successfully, but these errors were encountered:
@tstuefe This change now passes all automated pre-integration checks.
After integration, the commit message for the final commit will be:
At the time when this comment was updated there had been 35 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.
I rewrote stringStream::write somewhat:
@tstuefe Since your change was applied there have been 35 commits pushed to the
Your commit was automatically rebased without conflicts.
Pushed as commit d066f2b.