-
Notifications
You must be signed in to change notification settings - Fork 540
Commit 88ef8cf
committed
[Java] Attempt to optimise code with disabled access order checks.
Some JIT compilers are able to eliminate dead code within branches of
if-statements where the conditional is a static expression. Some JIT
compilers perform inlining to some degree and use heuristics, e.g.,
method size. It isn't clear whether code size metrics will be calculated
after dead code elimination is performed.
In this commit, I've moved the code that performs state transitions when
access order checks are enabled into separate methods that the
encoders/decoders call upon field accesses, e.g., the getter for a field
`xyz` might look like this:
```
int xyz()
{
if (ENABLED_ACCESS_ORDER_CHECKS)
{
onXyzAccessed();
}
// ...
}
```
This keeps the initial size of `xyz` smaller than when the code of
`onXyzAccessed()` is "inlined" by the code generator.
There is a lot of noise on my ThinkPad P14s, but benchmarks do show
improvements after this change.
Before:
```
$ java -jar -Dagrona.disable.bounds.checks=true -Dsbe.enable.access.order.checks=false ./sbe-benchmarks/build/libs/sbe-benchmarks.jar ".*Car.*" -bm thrpt -f 2 -i 3 -wi 2
\# JMH version: 1.36
\# VM version: JDK 1.8.0_302, OpenJDK 64-Bit Server VM, 25.302-b08
\# VM invoker: /home/zach/.asdf/installs/java/zulu-8.56.0.21/jre/bin/java
\# VM options: -Dagrona.disable.bounds.checks=true -Dsbe.enable.access.order.checks=false
...
Benchmark Mode Cnt Score Error Units
CarBenchmark.testDecode thrpt 6 18051405.792 ± 444296.898 ops/s
CarBenchmark.testEncode thrpt 6 11964827.418 ± 221996.747 ops/s
```
After:
```
$ java -jar -Dagrona.disable.bounds.checks=true -Dsbe.enable.access.order.checks=false ./sbe-benchmarks/build/libs/sbe-benchmarks.jar ".*Car.*" -bm thrpt -f 2 -i 3 -wi 2
\# JMH version: 1.36
\# VM version: JDK 1.8.0_302, OpenJDK 64-Bit Server VM, 25.302-b08
\# VM invoker: /home/zach/.asdf/installs/java/zulu-8.56.0.21/jre/bin/java
\# VM options: -Dagrona.disable.bounds.checks=true -Dsbe.enable.access.order.checks=false
...
Benchmark Mode Cnt Score Error Units
CarBenchmark.testDecode thrpt 6 18132922.415 ± 1964596.044 ops/s
CarBenchmark.testEncode thrpt 6 20018131.180 ± 671367.070 ops/s
```
Baseline (d2ec8f8):
```
$ java -jar -Dagrona.disable.bounds.checks=true -Dsbe.enable.access.order.checks=false ./sbe-benchmarks/build/libs/sbe-benchmarks.jar ".*Car.*" -bm thrpt -f 2 -i 3 -wi 2
\# JMH version: 1.36
\# VM version: JDK 1.8.0_302, OpenJDK 64-Bit Server VM, 25.302-b08
\# VM invoker: /home/zach/.asdf/installs/java/zulu-8.56.0.21/jre/bin/java
\# VM options: -Dagrona.disable.bounds.checks=true -Dsbe.enable.access.order.checks=false
...
Benchmark Mode Cnt Score Error Units
CarBenchmark.testDecode thrpt 6 19270366.357 ± 2618336.027 ops/s
CarBenchmark.testEncode thrpt 6 22519718.535 ± 794169.180 ops/s
```1 parent aaa73c1 commit 88ef8cfCopy full SHA for 88ef8cf
File tree
Expand file treeCollapse file tree
6 files changed
+934
-1295
lines changedFilter options
- sbe-tool/src
- main/java/uk/co/real_logic/sbe
- generation/java
- ir/generated
- test/java/uk/co/real_logic/sbe
Expand file treeCollapse file tree
6 files changed
+934
-1295
lines changed
0 commit comments