[11u] RFR: 8260030: Improve stringStream buffer handling

Thomas Stüfe thomas.stuefe at gmail.com
Tue May 11 05:41:38 UTC 2021


Hi all,

I would like to downport the following patch:

https://bugs.openjdk.java.net/browse/JDK-8260030
Original patch: https://github.com/openjdk/jdk/commit/d066f2b0.diff
Original review: https://github.com/openjdk/jdk/pull/2160

This patch greatly reduces the number of malloc/free calls done when
printing small strings to stringStream: In debug, malloc calls from
stringStream ~211000 -> 53000. In a release VM, they drop even further,
~85000 down to just about a 1000 calls. It does so by providing
stringStream with a small, in-object array as a backing buffer for small
streams, and only switches to C-Heap when this buffer is exhausted, which
most of the time won't happen.

This also provides code parity with upstream, making future fixes easier to
downport.

The patch does not apply cleanly, since 8238358 (JEP 371: Hidden Classes)
changed stringStream::as_string(), adding the option to return the stream
content in C-heap and not as resource area. The differences are limited to
that function and superficial.

The 11u patch:
http://cr.openjdk.java.net/~stuefe/webrevs/backports/8260030-improve-stringStream-buffer-handling-11u

The patch has been cooking in our internal systems for several weeks now.

Thank you!

Thomas


More information about the hotspot-runtime-dev mailing list