jdk
jdk copied to clipboard
8334230: Optimize C2 classes layout
Notes
Rearrange C2 class fields to optimize footprint.
Verification
- Ran tier2_compiler, hotspot_compiler, tier 1 & tier 2 tests.
- Ran pahole on 64 bit machine post re-ordering and verified that there are no holes / reduction in total bytes.
| Class | Size | Cachelines | Sum Members | Holes | Sum holes | Last Cacheline | Padding |
|---|---|---|---|---|---|---|---|
| ArrayPointer | 56 -> 48 | 1 -> 1 | 45 -> 0 | 2 -> 0 | 11 -> 0 | 56 bytes -> 48 | 0 -> 3 |
| CallJavaNode | 152 -> 144 | 3 -> 3 | 12 -> 0 | 1 -> 0 | 5 -> 0 | 24 bytes -> 16 | 7 -> 4 |
| C2Access | 56 -> 48 | 1-> 1 | 42 -> 0 | 1 -> 0 | 7 -> 0 | 56 bytes -> 48 | 7 -> 6 |
| VectorSet | 32 -> 24 | 1-> 1 | 24 -> 0 | 1 -> 0 | 8 -> 0 | 32 bytes -> 24 | 1 -> 1 |
class ArrayPointer {
const class Node * _pointer; /* 0 8 */
const class Node * _base; /* 8 8 */
const jlong _constant_offset; /* 16 8 */
const class Node * _int_offset; /* 24 8 */
const class GrowableArray<Node*> * _other_offsets; /* 32 8 */
const jint _int_offset_shift; /* 40 4 */
const bool _is_valid; /* 44 1 */
public:
/* size: 48, cachelines: 1, members: 7 */
/* padding: 3 */
/* last cacheline: 48 bytes */
};
class CallJavaNode : public CallNode {
public:
/* class CallNode <ancestor>; */ /* 0 128 */
protected:
/* --- cacheline 2 boundary (128 bytes) --- */
class ciMethod * _method; /* 128 8 */
bool _optimized_virtual; /* 136 1 */
bool _method_handle_invoke; /* 137 1 */
bool _override_symbolic_info; /* 138 1 */
bool _arg_escape; /* 139 1 */
public:
protected:
public:
/* size: 144, cachelines: 3, members: 6 */
/* padding: 4 */
/* last cacheline: 16 bytes */
/* BRAIN FART ALERT! 144 bytes != 12 (member bytes) + 0 (member bits) + 0 (byte holes) + 0 (bit holes), diff = 1024 bits */
};
class C2Access : public StackObj {
public:
/* class StackObj <ancestor>; */ /* 0 0 */
/* XXX last struct has 1 byte of padding */
int ()(void) * * _vptr.C2Access; /* 0 8 */
protected:
DecoratorSet _decorators; /* 8 8 */
class Node * _base; /* 16 8 */
class C2AccessValuePtr & _addr; /* 24 8 */
class Node * _raw_access; /* 32 8 */
enum BasicType _type; /* 40 1 */
uint8_t _barrier_data; /* 41 1 */
public:
protected:
public:
/* size: 48, cachelines: 1, members: 8 */
/* padding: 6 */
/* paddings: 1, sum paddings: 1 */
/* last cacheline: 48 bytes */
};
class VectorSet : public AnyObj {
public:
/* class AnyObj <ancestor>; */ /* 0 0 */
/* XXX last struct has 1 byte of padding */
static const uint word_bits; /* 0 0 */
static const uint bit_mask; /* 0 0 */
uint _size; /* 0 4 */
uint _data_size; /* 4 4 */
uint32_t * _data; /* 8 8 */
class Arena * _set_arena; /* 16 8 */
/* size: 24, cachelines: 1, members: 5, static members: 2 */
/* paddings: 1, sum paddings: 1 */
/* last cacheline: 24 bytes */
};
I wrote simple program that just assigns integer value to a variable and observed the following - Number of ArrayPointer instances = 58. Number of C2Access instances = 1390. Number of CallJavaNode instances = 1626. 58 * 8 byte + 1390 * 8 + 1626 * 8 = 24KB 24 KB space saving at the very least and significant memory footprint savings for much complex programs.
Progress
- [ ] Change must be properly reviewed (1 review required, with at least 1 Reviewer)
- [x] Change must not contain extraneous whitespace
- [x] Commit message must refer to an issue
Issue
- JDK-8334230: Optimize C2 classes layout (Sub-task - P4)
Reviewing
Using git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/19861/head:pull/19861
$ git checkout pull/19861
Update a local copy of the PR:
$ git checkout pull/19861
$ git pull https://git.openjdk.org/jdk.git pull/19861/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 19861
View PR using the GUI difftool:
$ git pr show -t 19861
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/19861.diff
:wave: Welcome back neethu-prasad! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.
@neethu-prasad This change now passes all automated pre-integration checks.
ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.
After integration, the commit message for the final commit will be:
8334230: Optimize C2 classes layout
Reviewed-by: shade, kvn, thartmann
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.
At the time when this comment was updated there had been 417 new commits pushed to the master branch:
- 41486131481164a559aa534807fe1a77a7d29fc8: 8335907: JFR: Make SettingControls more robust
- 79bdd811876d75974536aac088bae1719387c97f: 8336763: Parallel: Merge PCMarkAndPushClosure and PCIterateMarkAndPushClosure
- 8162832832ac6e8c17f942e718e309a3489e0da6: 8333354: ubsan: frame.inline.hpp:91:25: and src/hotspot/share/runtime/frame.inline.hpp:88:29: runtime error: member call on null pointer of type 'const struct SmallRegisterMap'
- 0325ab8d2353f29ac40ff4b028cbc29bff40c59b: 8335610: DiagnosticFramework: CmdLine::is_executable() correction
- 7ac531181c25815577ba2f6f426e1da270e4f589: 8331126: [s390x] secondary_super_cache does not scale well
- 156f0b4332bf076165898417cf6678d2fc32df5c: 8337213: Shenandoah: Add verification for class mirrors
- 9e6e0a8f341389215f0db6b2260f2b16351f02be: 8336343: Add more known sysroot library locations for ALSA
- bc7c255b156bf3bb3fd8c3f622b8127ab27e7c7a: 8337416: Fix -Wzero-as-null-pointer-constant warnings in misc. runtime code
- 7e21d4c1916d6690b717911179314c26a0da5ed9: 8337268: Redundant Math.ceil in StyleSheet.ListPainter#drawShape
- ab27090aa085283233851410827767785b3b7b1f: 8337225: Demote maxStack and maxLocals from CodeModel to CodeAttribute
- ... and 407 more: https://git.openjdk.org/jdk/compare/7baddc202a9ab2b85401aa05f827678b514ebf55...master
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.
As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@vnkozlov, @TobiHartmann, @shipilev) but any other Committer may sponsor as well.
➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).
@neethu-prasad The following label will be automatically applied to this pull request:
hotspot
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.
Thanks for the review & approval.
/integrate
@neethu-prasad Your change (at version 490c381ee37ec38774fd08b1239d28ad11ad7aa6) is now ready to be sponsored by a Committer.
/sponsor
Going to push as commit 1cb27f7e2355ccb911bb274fc004e5bc57fd5dc9.
Since your change was applied there have been 417 commits pushed to the master branch:
- 41486131481164a559aa534807fe1a77a7d29fc8: 8335907: JFR: Make SettingControls more robust
- 79bdd811876d75974536aac088bae1719387c97f: 8336763: Parallel: Merge PCMarkAndPushClosure and PCIterateMarkAndPushClosure
- 8162832832ac6e8c17f942e718e309a3489e0da6: 8333354: ubsan: frame.inline.hpp:91:25: and src/hotspot/share/runtime/frame.inline.hpp:88:29: runtime error: member call on null pointer of type 'const struct SmallRegisterMap'
- 0325ab8d2353f29ac40ff4b028cbc29bff40c59b: 8335610: DiagnosticFramework: CmdLine::is_executable() correction
- 7ac531181c25815577ba2f6f426e1da270e4f589: 8331126: [s390x] secondary_super_cache does not scale well
- 156f0b4332bf076165898417cf6678d2fc32df5c: 8337213: Shenandoah: Add verification for class mirrors
- 9e6e0a8f341389215f0db6b2260f2b16351f02be: 8336343: Add more known sysroot library locations for ALSA
- bc7c255b156bf3bb3fd8c3f622b8127ab27e7c7a: 8337416: Fix -Wzero-as-null-pointer-constant warnings in misc. runtime code
- 7e21d4c1916d6690b717911179314c26a0da5ed9: 8337268: Redundant Math.ceil in StyleSheet.ListPainter#drawShape
- ab27090aa085283233851410827767785b3b7b1f: 8337225: Demote maxStack and maxLocals from CodeModel to CodeAttribute
- ... and 407 more: https://git.openjdk.org/jdk/compare/7baddc202a9ab2b85401aa05f827678b514ebf55...master
Your commit was automatically rebased without conflicts.
@shipilev @neethu-prasad Pushed as commit 1cb27f7e2355ccb911bb274fc004e5bc57fd5dc9.
:bulb: You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.