We should prefer direct buffers if we can access the cleaner even if sun.misc.Unsafe is not present. (#8233)
Motivation: We should prefer direct buffers whenever we can use the cleaner even if sun.misc.Unsafe is not present. Modifications: Correctly prefer direct buffers in all cases. Result: More correct code.
This commit is contained in:
parent
8679c5ef43
commit
f77891cc17
@ -79,8 +79,7 @@ public final class PlatformDependent {
|
|||||||
private static final boolean CAN_ENABLE_TCP_NODELAY_BY_DEFAULT = !isAndroid();
|
private static final boolean CAN_ENABLE_TCP_NODELAY_BY_DEFAULT = !isAndroid();
|
||||||
|
|
||||||
private static final Throwable UNSAFE_UNAVAILABILITY_CAUSE = unsafeUnavailabilityCause0();
|
private static final Throwable UNSAFE_UNAVAILABILITY_CAUSE = unsafeUnavailabilityCause0();
|
||||||
private static final boolean DIRECT_BUFFER_PREFERRED =
|
private static final boolean DIRECT_BUFFER_PREFERRED;
|
||||||
UNSAFE_UNAVAILABILITY_CAUSE == null && !SystemPropertyUtil.getBoolean("io.netty.noPreferDirect", false);
|
|
||||||
private static final long MAX_DIRECT_MEMORY = maxDirectMemory0();
|
private static final long MAX_DIRECT_MEMORY = maxDirectMemory0();
|
||||||
|
|
||||||
private static final int MPSC_CHUNK_SIZE = 1024;
|
private static final int MPSC_CHUNK_SIZE = 1024;
|
||||||
@ -128,9 +127,6 @@ public final class PlatformDependent {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (logger.isDebugEnabled()) {
|
|
||||||
logger.debug("-Dio.netty.noPreferDirect: {}", !DIRECT_BUFFER_PREFERRED);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We do not want to log this message if unsafe is explicitly disabled. Do not remove the explicit no unsafe
|
* We do not want to log this message if unsafe is explicitly disabled. Do not remove the explicit no unsafe
|
||||||
@ -190,6 +186,13 @@ public final class PlatformDependent {
|
|||||||
} else {
|
} else {
|
||||||
CLEANER = NOOP;
|
CLEANER = NOOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We should always prefer direct buffers by default if we can use a Cleaner to release direct buffers.
|
||||||
|
DIRECT_BUFFER_PREFERRED = CLEANER != NOOP
|
||||||
|
&& !SystemPropertyUtil.getBoolean("io.netty.noPreferDirect", false);
|
||||||
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug("-Dio.netty.noPreferDirect: {}", !DIRECT_BUFFER_PREFERRED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasDirectBufferNoCleanerConstructor() {
|
public static boolean hasDirectBufferNoCleanerConstructor() {
|
||||||
|
Loading…
Reference in New Issue
Block a user