RFR: 8263038: Optimize String.format for simple specifiers

Claes Redestad redestad at openjdk.java.net
Thu Mar 4 17:46:56 UTC 2021


This patch optimizes String.format expressions that uses trivial specifiers. In the JDK, the most common variation of String.format is a variation of format("foo: %s", s), which gets a significant speed-up from this.

Various other cleanups and minor improvements reduce overhead further and ensure we get a small gain also for more complex format strings.

-------------

Commit messages:
 - Fix boundary condition
 - Add complex pattern micro
 - Harmonize micro to generate same length strings and mix trivial and non-trivial specifiers
 - Accidentally mutating Flags.NONE
 - Merge branch 'master' into format_opt
 - Fixes, cleanups, improvements
 - Consolidate slow path
 - Fix various edge cases
 - Improve Formatter for simple patterns

Changes: https://git.openjdk.java.net/jdk/pull/2830/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=2830&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8263038
  Stats: 265 lines in 2 files changed: 121 ins; 58 del; 86 mod
  Patch: https://git.openjdk.java.net/jdk/pull/2830.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/2830/head:pull/2830

PR: https://git.openjdk.java.net/jdk/pull/2830


More information about the core-libs-dev mailing list