-
Improvement
-
Resolution: Done
-
Medium
-
None
We currently store CopyHistory as a reference to an object, costing us 4b/8b of storage in StatementContextBase.
StatementContextBase is the bread&butter of memory/CPU trade-offs and it does not have a single bit of storage left.
At the end of the day, CopyHistory encodes the following information:
- last CopyType
- CopyableNode.isAugmenting()
- AddedByUsesAware.isAddedByUses()
This currently boils down to 2+log2(4)=4 significant bits, for which we are storing 32/64 bits.
Refactor StatementContextBase.copyHistory to be
private final byte copyHistory;
This frees up 3-7 bytes of storage, which provides 24bits of additional free storage.
Another candidate is StatementContextBase.completedPhase, which again is 4/8 bytes of storage, but it only stores 7 states, i.e. none + ModelProcessingPhase which there are 6 of.
We could use only 3 bits for storing that state, but that would incur masking operations for sub-byte access. Since this is an utterly hot path, let's instead keep
private byte completedPhase;
Which again frees up 3-7 bytes of storage.
Combining these two, though, we get real gains – we trim down 8-16 bytes of storage for everything 64bit, while also a creating an unused 2-byte alignment gap. There also remain 4 unused bits in copyHistory, giving us comfortable 20bits if we need to store more information.
- split to
-
YANGTOOLS-1256 Reconsider InferredStatementContet.childCopyType storage
- Resolved
1.
|
Define ModelProcessingPhase.ExecutionOrder | Resolved | Robert Varga | |
2.
|
Inline CopyHistory storage | Resolved | Robert Varga |