Create behalf of lingjun.cg@alibaba-inc.com
Description:
Run the following JMH test case in Linux with 8C32G, it shows the poor performance
of DecimalFormat.forma() when compare to jdk11.
the result with jdk 11:
Benchmark Mode Cnt Score Error Units
JmhDecimalFormat.testFormatOnly avgt 50 364.214 ? 1.191 ns/op
JmhDecimalFormat.testNewAndFormat avgt 50 658.699 ? 2.311 ns/op
JmhDecimalFormat.testNewOnly avgt 50 248.300 ? 5.158 ns/op
the result with current jdk:
Benchmark Mode Cnt Score Error Units
JmhDecimalFormat.testFormatOnly avgt 50 642.099 ? 1.253 ns/op
JmhDecimalFormat.testNewAndFormat avgt 50 989.307 ? 3.676 ns/op
JmhDecimalFormat.testNewOnly avgt 50 303.381 ? 5.252 ns/op
With the perf and asyncprofiler's help,
The poor performacne of DecimalFormat.format() due to the removed BiasedLocking.
We can see many hottest atomic instructions.
0.34% 0x00007fe26c3ce6eb: mov %r11d,0xec(%rsp)
0x00007fe26c3ce6f3: movzwl %r11w,%r11d ;*i2c {reexecute=0 rethrow=0 return_oop=0}
; - java.text.DecimalFormat::subformat@847 (line 2079)
0.13% 0x00007fe26c3ce6f7: mov %r11d,0x20(%rsp)
0.02% 0x00007fe26c3ce6fc: mov 0x68(%rsp),%r11
0.17% 0x00007fe26c3ce701: lea 0xc0(%rsp),%rbx
0x00007fe26c3ce709: mov (%r11),%rax
0.40% 0x00007fe26c3ce70c: test $0x2,%al
╭ 0x00007fe26c3ce70e: jne 0x00007fe26c3ce737
0.21% │ 0x00007fe26c3ce714: or $0x1,%rax
│ 0x00007fe26c3ce718: mov %rax,(%rbx)
0.32% │ 0x00007fe26c3ce71b: lock cmpxchg %rbx,(%r11)
4.35% │ 0x00007fe26c3ce720: je 0x00007fe26c3ce75d ; {no_reloc}
│ 0x00007fe26c3ce726: sub %rsp,%rax
│ 0x00007fe26c3ce729: and $0xfffffffffffff007,%rax
│ 0x00007fe26c3ce72f: mov %rax,(%rbx)
│ 0x00007fe26c3ce732: jmpq 0x00007fe26c3ce75b
↘ 0x00007fe26c3ce737: mov %rax,%r10
0x00007fe26c3ce73a: xor %rax,%rax
0x00007fe26c3ce73d: lock cmpxchg %r15,0x3e(%r10)
0x00007fe26c3ce743: movq $0x3,(%rbx)
0x00007fe26c3ce74a: je 0x00007fe26c3ce75d
0x00007fe26c3ce74c: cmp %rax,%r15
Description:
Run the following JMH test case in Linux with 8C32G, it shows the poor performance
of DecimalFormat.forma() when compare to jdk11.
the result with jdk 11:
Benchmark Mode Cnt Score Error Units
JmhDecimalFormat.testFormatOnly avgt 50 364.214 ? 1.191 ns/op
JmhDecimalFormat.testNewAndFormat avgt 50 658.699 ? 2.311 ns/op
JmhDecimalFormat.testNewOnly avgt 50 248.300 ? 5.158 ns/op
the result with current jdk:
Benchmark Mode Cnt Score Error Units
JmhDecimalFormat.testFormatOnly avgt 50 642.099 ? 1.253 ns/op
JmhDecimalFormat.testNewAndFormat avgt 50 989.307 ? 3.676 ns/op
JmhDecimalFormat.testNewOnly avgt 50 303.381 ? 5.252 ns/op
With the perf and asyncprofiler's help,
The poor performacne of DecimalFormat.format() due to the removed BiasedLocking.
We can see many hottest atomic instructions.
0.34% 0x00007fe26c3ce6eb: mov %r11d,0xec(%rsp)
0x00007fe26c3ce6f3: movzwl %r11w,%r11d ;*i2c {reexecute=0 rethrow=0 return_oop=0}
; - java.text.DecimalFormat::subformat@847 (line 2079)
0.13% 0x00007fe26c3ce6f7: mov %r11d,0x20(%rsp)
0.02% 0x00007fe26c3ce6fc: mov 0x68(%rsp),%r11
0.17% 0x00007fe26c3ce701: lea 0xc0(%rsp),%rbx
0x00007fe26c3ce709: mov (%r11),%rax
0.40% 0x00007fe26c3ce70c: test $0x2,%al
╭ 0x00007fe26c3ce70e: jne 0x00007fe26c3ce737
0.21% │ 0x00007fe26c3ce714: or $0x1,%rax
│ 0x00007fe26c3ce718: mov %rax,(%rbx)
0.32% │ 0x00007fe26c3ce71b: lock cmpxchg %rbx,(%r11)
4.35% │ 0x00007fe26c3ce720: je 0x00007fe26c3ce75d ; {no_reloc}
│ 0x00007fe26c3ce726: sub %rsp,%rax
│ 0x00007fe26c3ce729: and $0xfffffffffffff007,%rax
│ 0x00007fe26c3ce72f: mov %rax,(%rbx)
│ 0x00007fe26c3ce732: jmpq 0x00007fe26c3ce75b
↘ 0x00007fe26c3ce737: mov %rax,%r10
0x00007fe26c3ce73a: xor %rax,%rax
0x00007fe26c3ce73d: lock cmpxchg %r15,0x3e(%r10)
0x00007fe26c3ce743: movq $0x3,(%rbx)
0x00007fe26c3ce74a: je 0x00007fe26c3ce75d
0x00007fe26c3ce74c: cmp %rax,%r15
- csr for
-
JDK-8335834 Use StringBuilder internally for java.text.Format.* formatting
-
- Closed
-
- relates to
-
JDK-8313205 Modernize java.text.Format with StringBuilder
-
- Closed
-
- links to
-
Commit(master) openjdk/jdk/4da99158
-
Review(master) openjdk/jdk/19513