> This PR optimizes string concatenation in `URL::toExternalForm`. This method > is called by `URL:toString` and executes often enough to be noticed during > startup / classloading profiling. It was previously optimized in JDK 10 via > JDK-8193034, but we can do more. > > Key observations: > > * The current method concatenates concatenated strings. We can get away with > less by flattening and concatenating once per call. > * The current method does not take advantage of the fact that most URL > components are optional and several are commonly not present. We can > specialize for those cheaper common concatenations. > > This PR reduces runtime with 60% or more, depending on present URL > components. (Benchmark results in first comment). I also ran the benchmark > with compilation excluded and found no regressions for the interpreter case. > > Reviewers may find that the use of SSA-style local variables and the > optimizations makes the code less dense and more verbose. I opted to not try > to be clever and instead let the code "show its work" here. The code is more > bulky, but hopefully should be easy to read. I added some code comments, > happy to dial down those if requested. Feedback welcome! > > Performance refactoring, `noreg-perf`. `URL::toString` seems well tested by > current tests.
Eirik Bjørsnøs has updated the pull request incrementally with one additional commit since the last revision: Denser implementation of toExternalForm ------------- Changes: - all: https://git.openjdk.org/jdk/pull/30151/files - new: https://git.openjdk.org/jdk/pull/30151/files/d19db35a..8f6f7b13 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=30151&range=01 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=30151&range=00-01 Stats: 67 lines in 1 file changed: 1 ins; 44 del; 22 mod Patch: https://git.openjdk.org/jdk/pull/30151.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/30151/head:pull/30151 PR: https://git.openjdk.org/jdk/pull/30151
