[master] Withdrawn: 8325104: Lilliput: Shrink Classpointers

Thomas Stuefe stuefe at openjdk.org
Wed May 1 07:01:18 UTC 2024


On Thu, 1 Feb 2024 10:23:04 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

> Hi,
> 
> I wanted to get input on the following improvement for Lilliput. Testing is still ongoing, but things look really good, so this patch is hopefully near its final form (barring any objections from reviewers, of course).
> 
> Note: I have a companion patch prepared for upstream, minus the markword changes. I will attempt to get that one upstream quickly in order to not have a large delta between upstream and lilliput, especially in Metaspace.
> 
> ## High-Level Overview
> 
> (for a short sequence of slides, please see https://github.com/tstuefe/fosdem24/blob/master/classpointers-and-liliput.pdf - these accompanied a talk we held at FOSDEM 24).
> 
> We want to reduce the bit size of narrow Klass to free up bits in the MarkWord. 
> 
> We cannot just reduce the Klass encoding range size (well, we could, and maybe we will later, but for now we decided not to). We instead increase the alignment Klass is stored at, and use that alignment shadow to store other information.
> 
> In other words, this patch changes the narrow Klass Pointer to a Klass ID, since now (almost) every value in its value range points to a different class. Therefore, we use the value range of nKlass much more efficiently.
> 
> We then use the newly freed bits in the MarkWord to restore the iHash to 31 bits: 
> 
> 
> [ 22-bit nKlass | 31-bit iHash | 4 free bits | age | fwd | lck ]
> 
> nKlass gets reduced to 22 bits. Identity hash gets re-inflated to 31 bits. Preceding iHash are now 4 unused bits. Rest is unchanged.
> 
> (Note: I originally wanted to swap iHash and nKlass such that either of them could be loaded with a 32-bit load, but I found that tricky since C2 seems to rely on the nKlass offset in the Markword being > 0.)
> 
> ## nKlass reduction:
> 
> The reduction in nKlass size is made by only storing them at 10-bit aligned addresses. That alignment (1KB) works well in practice since Klass - although var sized - typically is between 512 bytes and 1KB in size. Outliers are possible, but the size distribution is bell-curvish [1], so far-away outliers are very rare. 
> 
> To not lose memory to alignment waste, metaspace is reshaped to handle arbitrarily aligned allocations efficiently. Basically, we allow the non-Klass arena of a class loader to steal the alignment waste storage from the class arena. So, alignment waste blocks are filled with non-Klass metadata. That works very well in practice since non-Klass metadata is numerous and fine-granular compared to the big Klass blocks. Total footprint loss in metaspace is, therefore, almost ...

This pull request has been closed without being integrated.

-------------

PR: https://git.openjdk.org/lilliput/pull/128


More information about the lilliput-dev mailing list