On Thu, 16 Sep 2021 13:52:24 GMT, Scott Gibbons 
<github.com+6704669+asgibb...@openjdk.org> wrote:

> Change the default code entry alignment to 64 bytes from 32 bytes.  This 
> allows for maintaining proper 64-byte alignment of data within a code 
> segment, which is required by several AVX-512 instructions.
> 
> I ran into this while implementing Base64 encoding and decoding.  Code 
> segments which were allocated with the address mod 32 == 0 but with the 
> address mod 64 != 0 would cause the align() macro to misalign.  This is 
> because the align macro aligns to the size of the code segment and not the 
> offset of the PC.  So align(64) would align the PC to a multiple of 64 bytes 
> from the start of the segment, and not to a pure 64-byte boundary as 
> requested.  Changing the alignment of the segment to 64 bytes fixes the issue.
> 
> I have not seen any measurable difference in either performance or memory 
> usage with the tests I have run.
> 
> See [this 
> ](https://mail.openjdk.java.net/pipermail/hotspot-dev/2021-August/054180.html)
>  article for the discussion thread.

It sounds like this will new alignment requirement will only be needed for 
stubs (initially?), but as proposed it will affect all other types of 
CodeBlobs.  Just looking at the affect during startup, I saw padding for 
BufferBlobs go from 24 to 56, RuntimeBlobs go from 0 to 32 and 16 to 48, and 
nmethods go from 24 to 56.

I would like to suggest again, to use the actual alignment requirements of the 
CodeBuffer to determine the alignment of the CodeBlob.

> Perhaps the appropriate thing to do is to put an assert() in align() to fail 
> if the requested alignment cannot be ensured?

I agree.

> IMHO, the "right" thing to do is to mark the bytes requiring address 
> alignment and handle the cases on copy. This would add significant 
> complexity, however.

I disagree.  Let's not mark individual bytes.  The call to align() is enough to 
allow us to record the maximum alignment required by the CodeBuffer, and the 
added complexity is not at the individual instruction copy, but just choosing 
the correct alignment value when creating the CodeBlob.  For example, use 
MAX2(codebuffer->required_alignment(), CodeEntryAlignment) in place of 
CodeEntryAlignment.

And for my own curiousity, I would like to hear from Intel what the expected 
affect on icache performance is from increasing the alignment of code.

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

PR: https://git.openjdk.java.net/jdk/pull/5547

Reply via email to