## Opportunity

JDK-836829 describes runtime overhead due to global megamorphism, which can be 
overcome by considering only local *morphism. This change eliminates the 
overhead from a sometimes ultra-hot method, Writer.append(CharSequence).

## Solution
The core change is moving from String.valueOf(Object) (with global profiling) 
to a method-local call to CharSequence.toString() (with local profiling and a 
clear optimization target, String). The included benchmark shows an improvement 
around 60% when passing a String (table below, benchmark in PR).

Should be backportable.

| input | pre-fix ns | post-fix ns | delta (ns) | delta (%) |
|---|---|---|---|---|
| string | 4.611 | 1.724 | −2.89 | −62.6% |


---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK 
Interim AI Policy](https://openjdk.org/legal/ai).

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

Commit messages:
 - 8385118: Writer.append(CharSequence) optimization

Changes: https://git.openjdk.org/jdk/pull/31224/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=31224&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8385118
  Stats: 116 lines in 2 files changed: 115 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/31224.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/31224/head:pull/31224

PR: https://git.openjdk.org/jdk/pull/31224

Reply via email to