use netty PlatformDependent.estimateMaxDirectMemory#15238
use netty PlatformDependent.estimateMaxDirectMemory#15238hezhangjian merged 7 commits intoapache:masterfrom
Conversation
33739d3 to
d135685
Compare
|
LGTM :) |
|
/pulsarbot run-failure-checks |
michaeljmarshall
left a comment
There was a problem hiding this comment.
@shoothzj - I am not familiar with direct memory computation, but given the javadoc that I share in a comment, I'd like to make sure that we don't introduce a performance regression with this PR. Let me know what you think, thanks!
| @Override | ||
| public double get() { | ||
| return io.netty.util.internal.PlatformDependent.maxDirectMemory(); | ||
| return io.netty.util.internal.PlatformDependent.estimateMaxDirectMemory(); |
There was a problem hiding this comment.
It looks like the javadoc for this method recommends using #maxDirectMemory():
/**
* Compute an estimate of the maximum amount of direct memory available to this JVM.
* <p>
* The computation is not cached, so you probably want to use {@link #maxDirectMemory()} instead.
* <p>
* This will produce debug log output when called.
*
* @return The estimated max direct memory, in bytes.
*/
public static long estimateMaxDirectMemory()I am concerned that the cost of this alternative method. Are you able to provide documentation on how this method is better? Alternatively, is there a reason we can't cache the result in this class and the other references that will be called many times?
|
@michaeljmarshall My bad |
d135685 to
50bf474
Compare
Is it possible that it is a feature, not a bug, that we expose |
|
@michaeljmarshall There are two scenes using this method
|
0ef707c to
d57baf2
Compare
d57baf2 to
ec48c99
Compare
|
@lhotari PTAL again. @codelipenghui @eolivelli @merlimat PTAL |
|
LGTM |
| // Collect JVM direct memory | ||
| systemResourceUsage.setDirectMemory(new ResourceUsage((double) (getJvmDirectMemoryUsed() / MIBI), | ||
| (double) (io.netty.util.internal.PlatformDependent.maxDirectMemory() / MIBI))); | ||
| (double) (io.netty.util.internal.PlatformDependent.estimateMaxDirectMemory() / MIBI))); |
There was a problem hiding this comment.
Is it intentional to keep on using PlatformDependent class here?
There was a problem hiding this comment.
@lhotari Sorry. It's a miss. It have been fixed.
599d2ca to
83f764e
Compare
michaeljmarshall
left a comment
There was a problem hiding this comment.
LGTM. Thanks for answering my questions @shoothzj.
9c52638 to
30aa202
Compare
43a832c to
e935722
Compare
e935722 to
b84bb7d
Compare
3230097 to
98517de
Compare
98517de to
7be5743
Compare
1430c89 to
c383c79
Compare
|
/pulsarbot rerun-failure-checks |
Motivation
PlatformDependent.maxDirectMemory()can be inaccurate ifio.netty.maxDirectMemoryare settedDirectMemoryUtilsis not worked within some jdk releases.In netty 4.1.75, they introduced a new method
PlatformDependent.estimateMaxDirectMemoryto help users get maxDirectMemory. Since netty's this method works well on many jdk releases, use this to replace below two.PS:
DirectMemoryUtilshas been removed from bookkeeper in Use netty maxDirectMemory instead of DirectMemoryUtils bookkeeper#2989Modifications
PlatformDependent.estimateMaxDirectMemoryinstead