RFR: 8291641: Optimize StackTraceElement.toString() [v2]
David Schlosnagle
duke at openjdk.org
Tue Aug 2 13:47:41 UTC 2022
On Tue, 2 Aug 2022 05:29:38 GMT, Quan Anh Mai <duke at openjdk.org> wrote:
>> David Schlosnagle has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Address comments
>
> Since constructing a `String` from a `StringBuilder` requires an array copy anyway, you don't need to be exact in the capacity of the builder and overshooting is fine. This can simplify the length calculation a lot. Thanks.
Good call @merykitty , I updated with my take on simplifying the length estimate, let me know if that reads better.
JMH as of https://github.com/openjdk/jdk/pull/9665/commits/d3774a69b1e6f316ff8b4af257fb2e95e5c4c3dd for comparison to previous, so still a ~50% improvement over existing state on my x64 test environment (`Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz`).
Benchmark Mode Cnt Score Error Units
StackTraceElementBench.printStackTrace avgt 15 144011.319 ± 959.263 ns/op
StackTraceElementBench.toString avgt 15 67.874 ± 0.485 ns/op
-------------
PR: https://git.openjdk.org/jdk/pull/9665
More information about the core-libs-dev
mailing list