-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add Binary Allocator #14201
base: master
Are you sure you want to change the base?
Add Binary Allocator #14201
Conversation
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.
Awesome work! This is a big step forward in our performance.
But please pay attention to the code style, it seems that the overall code is written very casually and loosely at present...
private int sampleCount; | ||
private final int weight; | ||
private boolean isOld; // Enable to have enough historical data | ||
private final int OLD_THRESHOLD = 100; |
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.
final static
...ns/src/main/java/org/apache/iotdb/commons/utils/binaryallocator/AdaptiveWeightedAverage.java
Show resolved
Hide resolved
...ns/src/main/java/org/apache/iotdb/commons/utils/binaryallocator/AdaptiveWeightedAverage.java
Show resolved
Hide resolved
/** The default value for {@code evictorShutdownTimeout} configuration attribute. */ | ||
private long evictorShutdownTimeoutMillis = 10L * 1000L; | ||
|
||
/** The default value for {@code evictorShutdownTimeout} configuration attribute. */ |
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.
Please describe the meaning of these parameters in the Javadoc. The way it is written now is worse than not writing it at all...
private int[] sizeIdx2sizeTab; | ||
final int lookupMaxSize; | ||
|
||
final int LOG2_QUANTUM; |
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.
why not private?
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.
Do not capitalize variables that are not final static...
|
||
public PooledBinary allocateBinary(int reqCapacity) { | ||
if (reqCapacity < allocatorConfig.minAllocateSize | ||
| reqCapacity > allocatorConfig.maxAllocateSize) { |
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.
|| ?
state.set(BinaryAllocatorState.OPEN); | ||
evictor = | ||
new GCEvictor( | ||
"binary-allocator-gc-evictor", allocatorConfig.getDurationEvictorShutdownTimeout()); |
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.
do no use magic string
} | ||
|
||
public void close(boolean needReopen) { | ||
if (needReopen) state.set(BinaryAllocatorState.TMP_CLOSE); |
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.
use {}
|
||
package org.apache.iotdb.commons.utils.binaryallocator; | ||
|
||
public enum BinaryAllocatorState { |
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.
AllocatorConfig config = new AllocatorConfig(); | ||
config.arenaNum = 1; | ||
BinaryAllocator binaryAllocator = new BinaryAllocator(config); | ||
PooledBinary binary = binaryAllocator.allocateBinary(256); |
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.
use Odd number like 255 is better to test jvm allocation?
Description
Add Binary Allocator for object pooling and reuse of large Binary objects to reduce GC overhead.
Features
Details
Next Steps
Integrate Binary Allocator into IoTDB's writing execution.