-
-
Notifications
You must be signed in to change notification settings - Fork 16k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update GraalVM Native Image configuration for 19.2.0. #9515
Conversation
Can one of the admins verify this patch? |
buffer/src/main/java/io/netty/buffer/svm/AbstractReferenceCountedByteBufSubstitution.java
Outdated
Show resolved
Hide resolved
e6578b5
to
a4c2157
Compare
@netty-bot test this please |
1 similar comment
@netty-bot test this please |
buffer/src/main/java/io/netty/buffer/svm/AbstractReferenceCountedByteBufSubstitution.java
Outdated
Show resolved
Hide resolved
common/src/main/java/io/netty/util/svm/AbstractReferenceCountedSubstitution.java
Outdated
Show resolved
Hide resolved
a4c2157
to
000ba53
Compare
@normanmaurer I just realized that this needs some more work. I tested it with
where the |
000ba53
to
f5a2c2a
Compare
@normanmaurer I updated the PR. Instead of using substitutions I just push the initialization of Note: The need to push the initialization of these classes to run time could be avoided by refactoring the usages of |
@netty-bot test this please |
@cstancu can you please update the pr description / commit message to reflect the latest changes (+ squash) |
@pmlopes PTAL as well |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the extra dependency can go away without affecting the expected behaviour of this PR.
f5a2c2a
to
8bc1858
Compare
I think this PR is now ready to be merged. |
@netty-bot test this please |
@cstancu can you please update the commit message to match our rule and reflect what is now done in the PR: |
Motivation: The Netty classes are initialized at build time by default for GraalVM Native Image compilation. This is configured via the `--initialize-at-build-time=io.netty` option. While this reduces start-up time it can lead to some problems: - The class initializer of `io.netty.buffer.PooledByteBufAllocator` looks at the maximum memory size to compute the size of internal buffers. If the class initializer runs during image generation, then the buffers are sized according to the very large heap size that the image generator uses, and Netty allocates several arrays that are 16 MByte. The fix is to initialize the following 3 classes at run time: `io.netty.buffer.PooledByteBufAllocator,io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBufUtil`. This fix was dependent on a GraalVM Native Image fix that was included in 19.2.0. - The class initializer of `io.netty.handler.ssl.util.ThreadLocalInsecureRandom` needs to be initialized at runtime to ensure that the generated values are trully random and not fixed for each generated image. - The class initializers of `io.netty.buffer.AbstractReferenceCountedByteBuf` and `io.netty.util.AbstractReferenceCounted` compute field offsets. While the field offset recomputation is necessary for correct execution as a native image these initializers also have logic that depends on the presence/absence of `sun.misc.Unsafe`, e.g., via the `-Dio.netty.noUnsafe=true` flag. The fix is to push these initializers to runtime so that the field offset lookups (and the logic depending on them) run at run time. This way no manual substitutions are necessary either. Modifications: Add `META-INF/native-image` configuration files that correctly trigger the inialization of the above classes at run time via `--initialize-at-run-time=...` flags. Result: Fixes the initialisation issues described above for Netty executables built with GraalVM.
8bc1858
to
3cafc67
Compare
All done! |
@netty-bot test this please |
@cstancu thanks a lot! |
Motivation: The Netty classes are initialized at build time by default for GraalVM Native Image compilation. This is configured via the `--initialize-at-build-time=io.netty` option. While this reduces start-up time it can lead to some problems: - The class initializer of `io.netty.buffer.PooledByteBufAllocator` looks at the maximum memory size to compute the size of internal buffers. If the class initializer runs during image generation, then the buffers are sized according to the very large heap size that the image generator uses, and Netty allocates several arrays that are 16 MByte. The fix is to initialize the following 3 classes at run time: `io.netty.buffer.PooledByteBufAllocator,io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBufUtil`. This fix was dependent on a GraalVM Native Image fix that was included in 19.2.0. - The class initializer of `io.netty.handler.ssl.util.ThreadLocalInsecureRandom` needs to be initialized at runtime to ensure that the generated values are trully random and not fixed for each generated image. - The class initializers of `io.netty.buffer.AbstractReferenceCountedByteBuf` and `io.netty.util.AbstractReferenceCounted` compute field offsets. While the field offset recomputation is necessary for correct execution as a native image these initializers also have logic that depends on the presence/absence of `sun.misc.Unsafe`, e.g., via the `-Dio.netty.noUnsafe=true` flag. The fix is to push these initializers to runtime so that the field offset lookups (and the logic depending on them) run at run time. This way no manual substitutions are necessary either. Modifications: Add `META-INF/native-image` configuration files that correctly trigger the inialization of the above classes at run time via `--initialize-at-run-time=...` flags. Result: Fixes the initialisation issues described above for Netty executables built with GraalVM.
@normanmaurer thank you for your patience getting this PR in a good shape! |
@cstancu no worries.. we love contributions. So let em keep coming ;) |
Motivation:
The Netty classes are initialized at build time by default for GraalVM Native Image compilation. This is configured via the
--initialize-at-build-time=io.netty
option. While this reduces start-up time it can lead to some problems:The class initializer of
io.netty.buffer.PooledByteBufAllocator
looks at the maximum memory size to compute the size of internal buffers. If the class initializer runs during image generation, then the buffers are sized according to the very large heap size that the image generator uses, and Netty allocates several arrays that are 16 MByte. The fix is to initialize the following 3 classes at run time:io.netty.buffer.PooledByteBufAllocator,io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBufUtil
. This fix was dependent on a GraalVM Native Image fix that was included in 19.2.0.The class initializer of
io.netty.handler.ssl.util.ThreadLocalInsecureRandom
needs to be initialized at runtime to ensure that the generated values are trully random and not fixed for each generated image.The class initializers of
io.netty.buffer.AbstractReferenceCountedByteBuf
andio.netty.util.AbstractReferenceCounted
compute field offsets. While the field offset recomputation is necessary for correct execution as a native image these initializers also have logic that depends on the presence/absence ofsun.misc.Unsafe
, e.g., via the-Dio.netty.noUnsafe=true
flag. The fix is to push these initializers to runtime so that the field offset lookups (and the logic depending on them) run at run time. This way no manual substitutions are necessary either.Modifications:
Add
META-INF/native-image
configuration files that correctly trigger the inialization of the above classes at run time via--initialize-at-run-time=...
flags.Result:
Fixes the initialisation issues described above for Netty executables built with GraalVM.