RFR: 8355636: Speed up Throwable::printStackTrace by reducing object allocation [v5]
Shaojin Wen
swen at openjdk.org
Sat Apr 26 11:30:30 UTC 2025
> In the Throwable::printStackTrace method, StringBuilder is created multiple times to build String. By sharing StringBuilder to build String, object allocation and copying are reduced.
>
> In the scenario without suppressed and ourCause, unused IdentityHashMap is not created.
>
> Through these optimizations, the performance of `new Exception().printStackTrace()` can be improved by about 10%.
Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision:
fix windows lineSeparator
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/24864/files
- new: https://git.openjdk.org/jdk/pull/24864/files/e40726c1..d5e9e413
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=24864&range=04
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=24864&range=03-04
Stats: 42 lines in 1 file changed: 2 ins; 0 del; 40 mod
Patch: https://git.openjdk.org/jdk/pull/24864.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/24864/head:pull/24864
PR: https://git.openjdk.org/jdk/pull/24864
More information about the core-libs-dev
mailing list