RFR: 8270554: Shenandoah: Optimize heap scan loop
Roman Kennke
rkennke at openjdk.java.net
Thu Jul 15 14:44:21 UTC 2021
This is a fall-out from Lilliput. I noticed that in the heap scan loop, we load the size of objects in the size-based object scanner, even though all of the object closures already load the size, or at least in some cases, the Klass* which is necessary to determine the size. We can optimize that by making the scan loop co-operate with the closures. In other words, this changes the loop to avoid double-loading the Klass* in most cases in the size-based part of the scan loop.
Note: the motivation in Lilliput is not performance, but correctness, because there loading the Klass* means loading the header, and this needs to be done carefully because of concurrent evacuation and concurrent locking code both messing with the header, and thus depends a lot on the actual closures to do it correctly.
Implementation notes:
- SH::evacuate_object() has been changed so that it can return both the forwardee and the size. I opted to return the size as return-value because otherwise I'd have to null check an incoming pointer in the cases when we're not interested in the size. The way it is done, it can simply be ignored (and optimized-out) by the compiler.
- I added a do_object_size() variant to all affected iterators. I tried to do it with templates, but could not figure out how to please the compiler.
- While I was at it, I marked all do_object() methods as 'inline'.
- I ran some benchmarks. I think I see consistent but small improvements in evac and update-refs times, but it's not large enough to say that it is a definite improvement.
Testing:
- [x] hotspot_gc_shenandoah
- [ ] tier1 (+UseShenandoahGC)
- [x] specjvm testing
-------------
Commit messages:
- 8270554: Shenandoah: Optimize heap scan loop
Changes: https://git.openjdk.java.net/jdk/pull/4797/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=4797&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8270554
Stats: 92 lines in 10 files changed: 59 ins; 3 del; 30 mod
Patch: https://git.openjdk.java.net/jdk/pull/4797.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/4797/head:pull/4797
PR: https://git.openjdk.java.net/jdk/pull/4797
More information about the shenandoah-dev
mailing list