Skip to content
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

Revert io.netty.noUnsafe change #32318

Merged
merged 1 commit into from
Apr 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import io.quarkus.deployment.builditem.nativeimage.RuntimeReinitializedClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.UnsafeAccessedFieldBuildItem;
import io.quarkus.deployment.logging.LogCleanupFilterBuildItem;
import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild;
import io.quarkus.netty.BossEventLoopGroup;
import io.quarkus.netty.MainEventLoopGroup;
import io.quarkus.netty.runtime.EmptyByteBufStub;
Expand Down Expand Up @@ -78,11 +77,10 @@ public SystemPropertyBuildItem setNettyMachineId() {
return new SystemPropertyBuildItem("io.netty.machineId", nettyMachineId);
}

@BuildStep(onlyIf = NativeOrNativeSourcesBuild.class)
@BuildStep
NativeImageConfigBuildItem build(
NettyBuildTimeConfig config,
BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
BuildProducer<SystemPropertyBuildItem> systemProperties,
List<MinNettyAllocatorMaxOrderBuildItem> minMaxOrderBuildItems) {

reflectiveClass.produce(ReflectiveClassBuildItem.builder("io.netty.channel.socket.nio.NioSocketChannel")
Expand All @@ -99,8 +97,6 @@ NativeImageConfigBuildItem build(
String maxOrder = calculateMaxOrder(config.allocatorMaxOrder, minMaxOrderBuildItems, false);

NativeImageConfigBuildItem.Builder builder = NativeImageConfigBuildItem.builder()
// disable unsafe usage to allow io.netty.internal.PlarformDependent0 to be reinitialized without issues
.addNativeImageSystemProperty("io.netty.noUnsafe", "true")
// Use small chunks to avoid a lot of wasted space. Default is 16mb * arenas (derived from core count)
// Since buffers are cached to threads, the malloc overhead is temporary anyway
.addNativeImageSystemProperty("io.netty.allocator.maxOrder", maxOrder)
Expand All @@ -116,14 +112,8 @@ NativeImageConfigBuildItem build(
.addRuntimeInitializedClass("io.netty.buffer.ByteBufUtil")
// The default channel id uses the process id, it should not be cached in the native image.
.addRuntimeInitializedClass("io.netty.channel.DefaultChannelId")
// Make sure to re-initialize platform dependent classes/values at runtime
.addRuntimeReinitializedClass("io.netty.util.internal.PlatformDependent")
.addRuntimeReinitializedClass("io.netty.util.internal.PlatformDependent0")
.addNativeImageSystemProperty("io.netty.leakDetection.level", "DISABLED");

// Also set io.netty.noUnsafe at runtime
systemProperties.produce(new SystemPropertyBuildItem("io.netty.noUnsafe", "true"));

if (QuarkusClassLoader.isClassPresentAtRuntime("io.netty.handler.codec.http.HttpObjectEncoder")) {
builder
.addRuntimeInitializedClass("io.netty.handler.codec.http.HttpObjectEncoder")
Expand Down Expand Up @@ -172,7 +162,8 @@ NativeImageConfigBuildItem build(
log.debug("Not registering Netty native kqueue classes as they were not found");
}

return builder.build();
return builder //TODO: make configurable
.build();
}

@BuildStep
Expand Down