JDK-8178350 : klassVtable and klassItable should be ValueObj
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2017-04-09
  • Updated: 2017-08-25
  • Resolved: 2017-04-25
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 10
10 b21Fixed
Related Reports
Relates :  
Relates :  
Description
We have a start-up benchmark that shows Klass::vtable() was called 32458 times, and cost about 2~3% of a elapsed time of 720 ms.

klassVtable* Klass::vtable() const {
  return new klassVtable(const_cast<Klass*>(this), start_of_vtable(), vtable_length() / vtableEntry::size());
}

Because the THREAD is not known here, in order to allocate from resource, we need to call Thread::current(), which is expensive.

klassVtable is a fixed-size object with only 4 fields. It should be changed to a ValueObj and passed around as a plain old struct:

klassVtable Klass::vtable() const {
  return klassVtable(const_cast<Klass*>(this), start_of_vtable(), vtable_length() / vtableEntry::size());
}

A similar optimization can be done to InstanceKlass::itable() to avoid resource allocation there.

Comments
Preliminary test of fixing both klassVtable and klassItable show the following improvement: config 1: 715.64 ms -> 693.29 ms (3.12% improvement) config 2: 707.76 ms -> 694.43 ms (1.88% improvement)
12-04-2017