JDK-8178351 : Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2017-04-09
  • Updated: 2019-06-20
  • Resolved: 2018-01-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11
11 b01Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
We have a start-up benchmark that shows the various is_in_shared_space functions cost more than 1% of total elapsed time.

After JDK-8072061, all the shared regions are contiguous so we should be able to simplify these functions to a small number of pointer comparisons.
Comments
This is a code-cleanup task and the code is already integrated. Closing this RFE as verified.
16-03-2018

http://cr.openjdk.java.net/~iklam/jdk11/8178351-simplify-is-shared.v01/ # perf stat -r 1000 ./old/bin/java -Xshare:on -cp foo.jar Foo > /dev/null Performance counter stats for './old/bin/java -Xshare:on -cp foo.jar Foo' (1000 runs): 68.547196 task-clock # 1.423 CPUs utilized ( +- 0.04% ) 451 context-switches # 0.007 M/sec ( +- 0.16% ) 47 cpu-migrations # 0.681 K/sec ( +- 0.26% ) 7,135 page-faults # 0.104 M/sec ( +- 0.01% ) 187,757,752 cycles # 2.739 GHz ( +- 0.03% ) <not supported> stalled-cycles-frontend <not supported> stalled-cycles-backend 183,315,229 instructions # 0.98 insns per cycle ( +- 0.04% ) 35,002,982 branches # 510.641 M/sec ( +- 0.04% ) 1,284,891 branch-misses # 3.67% of all branches ( +- 0.05% ) 0.048169533 seconds time elapsed ( +- 0.11% ) # perf stat -r 1000 ./new/bin/java -Xshare:on -cp foo.jar Foo > /dev/null Performance counter stats for './new/bin/java -Xshare:on -cp foo.jar Foo' (1000 runs): 67.811890 task-clock # 1.428 CPUs utilized ( +- 0.04% ) 451 context-switches # 0.007 M/sec ( +- 0.11% ) 47 cpu-migrations # 0.700 K/sec ( +- 0.25% ) 7,127 page-faults # 0.105 M/sec ( +- 0.01% ) 185,770,302 cycles # 2.739 GHz ( +- 0.03% ) <not supported> stalled-cycles-frontend <not supported> stalled-cycles-backend 181,578,561 instructions # 0.98 insns per cycle ( +- 0.04% ) 34,567,106 branches # 509.750 M/sec ( +- 0.04% ) 1,276,807 branch-misses # 3.69% of all branches ( +- 0.05% ) 0.047497524 seconds time elapsed ( +- 0.09% )
16-01-2018

JDK-8183001 inlined is_string_region, reducing the startup overheads. We should remeasure if further improvements to is_in_shared_space can be had by further simplifying the code in this area.
16-10-2017

It seems a large part of this cost is because MetaspaceShared::is_string_region isn't inlined into FileMap call sites, which would allow the compiler to do the optimization for us. By moving it to metaspaceShared.hpp the method is inlined and number of instructions retired in MetaspaceObj::is_shared drops from 2505K to 926K on a minimal HW program with CDS enabled: diff -r 39af4129f70b src/share/vm/memory/metaspaceShared.cpp --- a/src/share/vm/memory/metaspaceShared.cpp Fri May 19 11:22:47 2017 +0200 +++ b/src/share/vm/memory/metaspaceShared.cpp Mon May 22 15:11:23 2017 +0200 @@ -1216,11 +1216,6 @@ return UseSharedSpaces && FileMapInfo::current_info()->is_in_shared_region(p, idx); } -bool MetaspaceShared::is_string_region(int idx) { - return (idx >= MetaspaceShared::first_string && - idx < MetaspaceShared::first_string + MetaspaceShared::max_strings); -} - void MetaspaceShared::print_shared_spaces() { if (UseSharedSpaces) { FileMapInfo::current_info()->print_shared_spaces(); diff -r 39af4129f70b src/share/vm/memory/metaspaceShared.hpp --- a/src/share/vm/memory/metaspaceShared.hpp Fri May 19 11:22:47 2017 +0200 +++ b/src/share/vm/memory/metaspaceShared.hpp Mon May 22 15:11:23 2017 +0200 @@ -172,7 +172,10 @@ // Return true if given address is in the shared region corresponding to the idx static bool is_in_shared_region(const void* p, int idx) NOT_CDS_RETURN_(false); - static bool is_string_region(int idx) NOT_CDS_RETURN_(false); + static bool is_string_region(int idx) { + CDS_ONLY(return (idx >= first_string && idx < first_string + max_strings)); + NOT_CDS(return false); + } static intptr_t* allocate_cpp_vtable_clones(intptr_t* top, intptr_t* end); static intptr_t* clone_cpp_vtables(intptr_t* p);
22-05-2017

startup :-)
03-05-2017

Did you mean to label this one with 'start' or 'startup'?
09-04-2017