You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "MrQuansy (via GitHub)" <gi...@apache.org> on 2024/11/26 05:06:21 UTC
[PR] Add Binary Allocator [iotdb]
MrQuansy opened a new pull request, #14201:
URL: https://github.com/apache/iotdb/pull/14201
## Description
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add Binary Allocator [iotdb]
Posted by "MrQuansy (via GitHub)" <gi...@apache.org>.
MrQuansy commented on code in PR #14201:
URL: https://github.com/apache/iotdb/pull/14201#discussion_r1862155805
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/binaryallocator/BinaryAllocator.java:
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.utils.binaryallocator;
+
+import org.apache.iotdb.commons.service.metric.JvmGcMonitorMetrics;
+import org.apache.iotdb.commons.service.metric.MetricService;
+
+import org.apache.tsfile.utils.PooledBinary;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.time.Duration;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class BinaryAllocator {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(BinaryAllocator.class);
+
+ private final Arena[] heapArenas;
+ private final AllocatorConfig allocatorConfig;
+
+ public static final BinaryAllocator DEFAULT = new BinaryAllocator(AllocatorConfig.DEFAULT_CONFIG);
+ private ArenaStrategy arenaStrategy = new LeastUsedArenaStrategy();
+ private AtomicReference<BinaryAllocatorState> state =
+ new AtomicReference<>(BinaryAllocatorState.UNINITIALIZED);
+
+ private BinaryAllocatorMetrics metrics;
+ private static ThreadLocal<ThreadArenaRegistry> arenaRegistry =
+ ThreadLocal.withInitial(() -> new ThreadArenaRegistry());
+
+ private Evictor evictor;
+
+ public BinaryAllocator(AllocatorConfig allocatorConfig) {
+ this.allocatorConfig = allocatorConfig;
+
+ heapArenas = newArenaArray(allocatorConfig.arenaNum);
+ SizeClasses sizeClasses = new SizeClasses(allocatorConfig);
+
+ for (int i = 0; i < heapArenas.length; i++) {
+ Arena arena = new Arena(this, sizeClasses, i, allocatorConfig);
+ heapArenas[i] = arena;
+ }
+
+ this.metrics = new BinaryAllocatorMetrics(this);
+ MetricService.getInstance().addMetricSet(this.metrics);
+
+ if (allocatorConfig.enableBinaryAllocator) {
+ state.set(BinaryAllocatorState.OPEN);
+ evictor =
+ new GCEvictor(
+ "binary-allocator-gc-evictor", allocatorConfig.getDurationEvictorShutdownTimeout());
+ evictor.startEvictor(allocatorConfig.getDurationBetweenEvictorRuns());
+ } else {
+ state.set(BinaryAllocatorState.CLOSE);
+ this.close(false);
+ }
+ }
+
+ public PooledBinary allocateBinary(int reqCapacity) {
+ if (reqCapacity < allocatorConfig.minAllocateSize
+ | reqCapacity > allocatorConfig.maxAllocateSize) {
+ return new PooledBinary(new byte[reqCapacity]);
+ }
+
+ Arena arena = arenaStrategy.choose(heapArenas);
+
+ return new PooledBinary(arena.allocate(reqCapacity), reqCapacity, arena.getArenaID());
+ }
+
+ public void deallocateBinary(PooledBinary binary) {
+ if (binary != null
+ && binary.getLength() >= allocatorConfig.minAllocateSize
+ && binary.getLength() <= allocatorConfig.maxAllocateSize) {
+ int arenaIndex = binary.getArenaIndex();
+ if (arenaIndex != -1) {
+ Arena arena = heapArenas[arenaIndex];
+ arena.deallocate(binary.getValues());
+ }
+ }
+ }
+
+ public void deallocateBatch(PooledBinary[] blobs) {
+ for (PooledBinary blob : blobs) {
+ deallocateBinary(blob);
+ }
+ }
+
+ public long getTotalUsedMemory() {
+ long totalUsedMemory = 0;
+ for (Arena arena : heapArenas) {
+ totalUsedMemory += arena.getTotalUsedMemory();
+ }
+ return totalUsedMemory;
+ }
+
+ public long getTotalActiveMemory() {
+ long totalActiveMemory = 0;
+ for (Arena arena : heapArenas) {
+ totalActiveMemory += arena.getActiveMemory();
+ }
+ return totalActiveMemory;
+ }
+
+ public void evict(double ratio) {
+ for (Arena arena : heapArenas) {
+ arena.evict(ratio);
+ }
+ }
+
+ public boolean isOpen() {
+ return state.get() == BinaryAllocatorState.OPEN;
+ }
+
+ public void close(boolean needReopen) {
+ if (needReopen) state.set(BinaryAllocatorState.TMP_CLOSE);
+ else {
+ state.set(BinaryAllocatorState.CLOSE);
+ if (evictor != null) {
+ evictor.stopEvictor();
+ }
+ }
+ for (Arena arena : heapArenas) {
+ arena.close();
+ }
+ }
+
+ private void restart() {
+ state.set(BinaryAllocatorState.OPEN);
+ for (Arena arena : heapArenas) {
+ arena.restart();
+ }
+ }
+
+ public BinaryAllocatorMetrics getMetrics() {
+ return metrics;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static Arena[] newArenaArray(int size) {
+ return new Arena[size];
+ }
+
+ private static class ThreadArenaRegistry {
+ private Arena threadArenaBinding = null;
+
+ public Arena getArena() {
+ return threadArenaBinding;
+ }
+
+ public void bindArena(Arena arena) {
+ threadArenaBinding = arena;
+ arena.numRegisterThread.incrementAndGet();
+ }
+
+ public void unbindArena() {
+ Arena arena = threadArenaBinding;
+ if (arena != null) {
+ arena.numRegisterThread.decrementAndGet();
+ }
+ }
+
+ @Override
+ protected void finalize() {
+ unbindArena();
+ }
+ }
+
+ private class LeastUsedArenaStrategy implements ArenaStrategy {
+ @Override
+ public Arena choose(Arena[] arenas) {
+ Arena boundArena = arenaRegistry.get().getArena();
+ if (boundArena != null) {
+ return boundArena;
+ }
+
+ if (arenas == null || arenas.length == 0) {
+ return null;
+ }
+
+ Arena minArena = arenas[0];
+
+ for (int i = 1; i < arenas.length; i++) {
+ Arena arena = arenas[i];
+ if (arena.numRegisterThread.get() < minArena.numRegisterThread.get()) {
+ minArena = arena;
+ }
+ }
+
+ arenaRegistry.get().bindArena(minArena);
+ return minArena;
+ }
+ }
+
+ public class GCEvictor extends Evictor {
+ public GCEvictor(String name, Duration evictorShutdownTimeoutDuration) {
+ super(name, evictorShutdownTimeoutDuration);
+ }
+
+ @Override
+ public void run() {
+ LOGGER.debug("Binary allocator running evictor");
+ if (state.get() == BinaryAllocatorState.TMP_CLOSE) {
+ if (JvmGcMonitorMetrics.getInstance().getGcData().getGcTimePercentage() > 20) {
+ restart();
+ }
+ return;
+ }
+
+ if (JvmGcMonitorMetrics.getInstance().getGcData().getGcTimePercentage() > 30) {
+ for (Arena arena : heapArenas) {
+ arena.evict(1.0);
+ }
+ close(true);
Review Comment:
Now, when GC time percentage is > 20%, the allocator will be restarted if its state is TMP_CLOSE.
BTW, I'm thinking about whether we can initialize the allocator with TMP_CLOSE state and start it when we observe serious GC overhead?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add Binary Allocator [iotdb]
Posted by "MrQuansy (via GitHub)" <gi...@apache.org>.
MrQuansy commented on code in PR #14201:
URL: https://github.com/apache/iotdb/pull/14201#discussion_r1863023436
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/binaryallocator/AdaptiveWeightedAverage.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.utils.binaryallocator;
+
+import static java.lang.Math.max;
+
+public class AdaptiveWeightedAverage {
+ private float average;
+ private int sampleCount;
+ private final int weight;
+ private boolean isOld; // Enable to have enough historical data
+ private final int OLD_THRESHOLD = 100;
+
+ public AdaptiveWeightedAverage(int weight) {
+ this.weight = weight;
+ average = 0f;
+ sampleCount = 0;
+ }
+
+ public void sample(int newSample) {
Review Comment:
The EWMA implementation in com.codahale.metrics introduces extra work to improve concurrent performance, which wastes additional memory and reduces update performance. We don't need to consider concurrency issues here.
BTW, the AdaptiveWeightedAverage is modified from JDK17 source codes. However, I made some modifications after discovering that memory allocation and deallocation occurs in cycles, such as before and after a request completes. Therefore, the active memory volume fluctuates significantly, so we calculate a moving average based on the peak active memory within each evictor cycle.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add Binary Allocator [iotdb]
Posted by "MrQuansy (via GitHub)" <gi...@apache.org>.
MrQuansy commented on code in PR #14201:
URL: https://github.com/apache/iotdb/pull/14201#discussion_r1862306916
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/binaryallocator/EvictionTimer.java:
##########
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.utils.binaryallocator;
+
+import org.apache.iotdb.commons.concurrent.IoTThreadFactory;
+import org.apache.iotdb.commons.concurrent.threadpool.ScheduledExecutorUtil;
+
+import java.lang.ref.WeakReference;
+import java.time.Duration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+public class EvictionTimer {
Review Comment:
not public... Maybe we can simplify it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add Binary Allocator [iotdb]
Posted by "MrQuansy (via GitHub)" <gi...@apache.org>.
MrQuansy commented on code in PR #14201:
URL: https://github.com/apache/iotdb/pull/14201#discussion_r1863001753
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/binaryallocator/AdaptiveWeightedAverage.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.utils.binaryallocator;
+
+import static java.lang.Math.max;
+
+public class AdaptiveWeightedAverage {
Review Comment:
Copied from jdk17
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add Binary Allocator [iotdb]
Posted by "MrQuansy (via GitHub)" <gi...@apache.org>.
MrQuansy commented on code in PR #14201:
URL: https://github.com/apache/iotdb/pull/14201#discussion_r1862166395
##########
iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/BinaryAllocatorTest.java:
##########
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.utils;
+
+import org.apache.iotdb.commons.utils.binaryallocator.AllocatorConfig;
+import org.apache.iotdb.commons.utils.binaryallocator.BinaryAllocator;
+import org.apache.iotdb.commons.utils.binaryallocator.SizeClasses;
+
+import org.apache.tsfile.utils.PooledBinary;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CountDownLatch;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class BinaryAllocatorTest {
+ @Test
+ public void testAllocateBinary() {
+ AllocatorConfig config = new AllocatorConfig();
+ config.arenaNum = 1;
+ BinaryAllocator binaryAllocator = new BinaryAllocator(config);
+ PooledBinary binary = binaryAllocator.allocateBinary(256);
Review Comment:
sry, I didn't get your point. I think 255 and 256 have no difference in this testcase..
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add Binary Allocator [iotdb]
Posted by "OneSizeFitsQuorum (via GitHub)" <gi...@apache.org>.
OneSizeFitsQuorum merged PR #14201:
URL: https://github.com/apache/iotdb/pull/14201
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add Binary Allocator [iotdb]
Posted by "OneSizeFitsQuorum (via GitHub)" <gi...@apache.org>.
OneSizeFitsQuorum commented on code in PR #14201:
URL: https://github.com/apache/iotdb/pull/14201#discussion_r1861959698
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/binaryallocator/SizeClasses.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.utils.binaryallocator;
+
+public final class SizeClasses {
+
+ // loookup table
+ private int[] sizeIdx2sizeTab;
+ final int lookupMaxSize;
Review Comment:
same
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/binaryallocator/AdaptiveWeightedAverage.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.utils.binaryallocator;
+
+import static java.lang.Math.max;
+
+public class AdaptiveWeightedAverage {
Review Comment:
add javadoc
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/binaryallocator/AdaptiveWeightedAverage.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.utils.binaryallocator;
+
+import static java.lang.Math.max;
+
+public class AdaptiveWeightedAverage {
+ private float average;
+ private int sampleCount;
+ private final int weight;
+ private boolean isOld; // Enable to have enough historical data
+ private final int OLD_THRESHOLD = 100;
+
+ public AdaptiveWeightedAverage(int weight) {
+ this.weight = weight;
+ average = 0f;
+ sampleCount = 0;
+ }
+
+ public void sample(int newSample) {
Review Comment:
This does not seem to be writing friendly, and it feels like adaptiveWeightedAverage is a write more read less structure, should not be implemented this way.
In addition whether we use some mature EMA class such as "com.codahale.metrics.EWMA, don't have to write yourself?
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/binaryallocator/EvictionTimer.java:
##########
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.utils.binaryallocator;
+
+import org.apache.iotdb.commons.concurrent.IoTThreadFactory;
+import org.apache.iotdb.commons.concurrent.threadpool.ScheduledExecutorUtil;
+
+import java.lang.ref.WeakReference;
+import java.time.Duration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+public class EvictionTimer {
Review Comment:
Why not just org.apache.commons.pool2.impl.EvictionTimer? What's the meaning of copying another almost equal one?
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/binaryallocator/BinaryAllocatorState.java:
##########
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.utils.binaryallocator;
+
+public enum BinaryAllocatorState {
Review Comment:
<img width="876" alt="image" src="https://github.com/user-attachments/assets/0ada72f1-9710-4a04-8ec1-0432345e447c">
Describe the transition relationship between these states, and what conditions trigger the transition
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/binaryallocator/AllocatorConfig.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.utils.binaryallocator;
+
+import org.apache.iotdb.commons.conf.CommonDescriptor;
+
+import java.time.Duration;
+
+public class AllocatorConfig {
+ public int minAllocateSize = CommonDescriptor.getInstance().getConfig().getMinAllocateSize();
+
+ public int maxAllocateSize = CommonDescriptor.getInstance().getConfig().getMaxAllocateSize();
+
+ public int arenaNum = CommonDescriptor.getInstance().getConfig().getArenaNum();
+
+ public int log2ClassSizeGroup =
+ CommonDescriptor.getInstance().getConfig().getLog2SizeClassGroup();
+
+ public boolean enableBinaryAllocator =
+ CommonDescriptor.getInstance().getConfig().isEnableBinaryAllocator();
+
+ /** The default value for {@code evictorShutdownTimeout} configuration attribute. */
+ private long evictorShutdownTimeoutMillis = 10L * 1000L;
+
+ /** The default value for {@code evictorShutdownTimeout} configuration attribute. */
Review Comment:
Please describe the meaning of these parameters in the Javadoc. The way it is written now is worse than not writing it at all...
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/binaryallocator/AdaptiveWeightedAverage.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.utils.binaryallocator;
+
+import static java.lang.Math.max;
+
+public class AdaptiveWeightedAverage {
+ private float average;
+ private int sampleCount;
+ private final int weight;
+ private boolean isOld; // Enable to have enough historical data
+ private final int OLD_THRESHOLD = 100;
Review Comment:
final static
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/binaryallocator/BinaryAllocator.java:
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.utils.binaryallocator;
+
+import org.apache.iotdb.commons.service.metric.JvmGcMonitorMetrics;
+import org.apache.iotdb.commons.service.metric.MetricService;
+
+import org.apache.tsfile.utils.PooledBinary;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.time.Duration;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class BinaryAllocator {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(BinaryAllocator.class);
+
+ private final Arena[] heapArenas;
+ private final AllocatorConfig allocatorConfig;
+
+ public static final BinaryAllocator DEFAULT = new BinaryAllocator(AllocatorConfig.DEFAULT_CONFIG);
+ private ArenaStrategy arenaStrategy = new LeastUsedArenaStrategy();
+ private AtomicReference<BinaryAllocatorState> state =
+ new AtomicReference<>(BinaryAllocatorState.UNINITIALIZED);
+
+ private BinaryAllocatorMetrics metrics;
+ private static ThreadLocal<ThreadArenaRegistry> arenaRegistry =
+ ThreadLocal.withInitial(() -> new ThreadArenaRegistry());
+
+ private Evictor evictor;
+
+ public BinaryAllocator(AllocatorConfig allocatorConfig) {
+ this.allocatorConfig = allocatorConfig;
+
+ heapArenas = newArenaArray(allocatorConfig.arenaNum);
+ SizeClasses sizeClasses = new SizeClasses(allocatorConfig);
+
+ for (int i = 0; i < heapArenas.length; i++) {
+ Arena arena = new Arena(this, sizeClasses, i, allocatorConfig);
+ heapArenas[i] = arena;
+ }
+
+ this.metrics = new BinaryAllocatorMetrics(this);
+ MetricService.getInstance().addMetricSet(this.metrics);
+
+ if (allocatorConfig.enableBinaryAllocator) {
+ state.set(BinaryAllocatorState.OPEN);
+ evictor =
+ new GCEvictor(
+ "binary-allocator-gc-evictor", allocatorConfig.getDurationEvictorShutdownTimeout());
+ evictor.startEvictor(allocatorConfig.getDurationBetweenEvictorRuns());
+ } else {
+ state.set(BinaryAllocatorState.CLOSE);
+ this.close(false);
+ }
+ }
+
+ public PooledBinary allocateBinary(int reqCapacity) {
+ if (reqCapacity < allocatorConfig.minAllocateSize
+ | reqCapacity > allocatorConfig.maxAllocateSize) {
+ return new PooledBinary(new byte[reqCapacity]);
+ }
+
+ Arena arena = arenaStrategy.choose(heapArenas);
+
+ return new PooledBinary(arena.allocate(reqCapacity), reqCapacity, arena.getArenaID());
+ }
+
+ public void deallocateBinary(PooledBinary binary) {
+ if (binary != null
+ && binary.getLength() >= allocatorConfig.minAllocateSize
+ && binary.getLength() <= allocatorConfig.maxAllocateSize) {
+ int arenaIndex = binary.getArenaIndex();
+ if (arenaIndex != -1) {
+ Arena arena = heapArenas[arenaIndex];
+ arena.deallocate(binary.getValues());
+ }
+ }
+ }
+
+ public void deallocateBatch(PooledBinary[] blobs) {
+ for (PooledBinary blob : blobs) {
+ deallocateBinary(blob);
+ }
+ }
+
+ public long getTotalUsedMemory() {
+ long totalUsedMemory = 0;
+ for (Arena arena : heapArenas) {
+ totalUsedMemory += arena.getTotalUsedMemory();
+ }
+ return totalUsedMemory;
+ }
+
+ public long getTotalActiveMemory() {
+ long totalActiveMemory = 0;
+ for (Arena arena : heapArenas) {
+ totalActiveMemory += arena.getActiveMemory();
+ }
+ return totalActiveMemory;
+ }
+
+ public void evict(double ratio) {
+ for (Arena arena : heapArenas) {
+ arena.evict(ratio);
+ }
+ }
+
+ public boolean isOpen() {
+ return state.get() == BinaryAllocatorState.OPEN;
+ }
+
+ public void close(boolean needReopen) {
+ if (needReopen) state.set(BinaryAllocatorState.TMP_CLOSE);
+ else {
+ state.set(BinaryAllocatorState.CLOSE);
+ if (evictor != null) {
+ evictor.stopEvictor();
+ }
+ }
+ for (Arena arena : heapArenas) {
+ arena.close();
+ }
+ }
+
+ private void restart() {
+ state.set(BinaryAllocatorState.OPEN);
+ for (Arena arena : heapArenas) {
+ arena.restart();
+ }
+ }
+
+ public BinaryAllocatorMetrics getMetrics() {
+ return metrics;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static Arena[] newArenaArray(int size) {
+ return new Arena[size];
+ }
+
+ private static class ThreadArenaRegistry {
+ private Arena threadArenaBinding = null;
+
+ public Arena getArena() {
+ return threadArenaBinding;
+ }
+
+ public void bindArena(Arena arena) {
+ threadArenaBinding = arena;
+ arena.numRegisterThread.incrementAndGet();
+ }
+
+ public void unbindArena() {
+ Arena arena = threadArenaBinding;
+ if (arena != null) {
+ arena.numRegisterThread.decrementAndGet();
+ }
+ }
+
+ @Override
+ protected void finalize() {
+ unbindArena();
+ }
+ }
+
+ private class LeastUsedArenaStrategy implements ArenaStrategy {
+ @Override
+ public Arena choose(Arena[] arenas) {
+ Arena boundArena = arenaRegistry.get().getArena();
+ if (boundArena != null) {
+ return boundArena;
+ }
+
+ if (arenas == null || arenas.length == 0) {
+ return null;
+ }
+
+ Arena minArena = arenas[0];
+
+ for (int i = 1; i < arenas.length; i++) {
+ Arena arena = arenas[i];
+ if (arena.numRegisterThread.get() < minArena.numRegisterThread.get()) {
+ minArena = arena;
+ }
+ }
+
+ arenaRegistry.get().bindArena(minArena);
+ return minArena;
+ }
+ }
+
+ public class GCEvictor extends Evictor {
+ public GCEvictor(String name, Duration evictorShutdownTimeoutDuration) {
+ super(name, evictorShutdownTimeoutDuration);
+ }
+
+ @Override
+ public void run() {
+ LOGGER.debug("Binary allocator running evictor");
+ if (state.get() == BinaryAllocatorState.TMP_CLOSE) {
+ if (JvmGcMonitorMetrics.getInstance().getGcData().getGcTimePercentage() > 20) {
Review Comment:
do not use magic number
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/binaryallocator/SizeClasses.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.utils.binaryallocator;
+
+public final class SizeClasses {
+
+ // loookup table
+ private int[] sizeIdx2sizeTab;
+ final int lookupMaxSize;
+
+ final int LOG2_QUANTUM;
Review Comment:
why not private?
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/binaryallocator/BinaryAllocator.java:
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.utils.binaryallocator;
+
+import org.apache.iotdb.commons.service.metric.JvmGcMonitorMetrics;
+import org.apache.iotdb.commons.service.metric.MetricService;
+
+import org.apache.tsfile.utils.PooledBinary;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.time.Duration;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class BinaryAllocator {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(BinaryAllocator.class);
+
+ private final Arena[] heapArenas;
+ private final AllocatorConfig allocatorConfig;
+
+ public static final BinaryAllocator DEFAULT = new BinaryAllocator(AllocatorConfig.DEFAULT_CONFIG);
+ private ArenaStrategy arenaStrategy = new LeastUsedArenaStrategy();
+ private AtomicReference<BinaryAllocatorState> state =
+ new AtomicReference<>(BinaryAllocatorState.UNINITIALIZED);
+
+ private BinaryAllocatorMetrics metrics;
+ private static ThreadLocal<ThreadArenaRegistry> arenaRegistry =
+ ThreadLocal.withInitial(() -> new ThreadArenaRegistry());
+
+ private Evictor evictor;
+
+ public BinaryAllocator(AllocatorConfig allocatorConfig) {
+ this.allocatorConfig = allocatorConfig;
+
+ heapArenas = newArenaArray(allocatorConfig.arenaNum);
+ SizeClasses sizeClasses = new SizeClasses(allocatorConfig);
+
+ for (int i = 0; i < heapArenas.length; i++) {
+ Arena arena = new Arena(this, sizeClasses, i, allocatorConfig);
+ heapArenas[i] = arena;
+ }
+
+ this.metrics = new BinaryAllocatorMetrics(this);
+ MetricService.getInstance().addMetricSet(this.metrics);
+
+ if (allocatorConfig.enableBinaryAllocator) {
+ state.set(BinaryAllocatorState.OPEN);
+ evictor =
+ new GCEvictor(
+ "binary-allocator-gc-evictor", allocatorConfig.getDurationEvictorShutdownTimeout());
+ evictor.startEvictor(allocatorConfig.getDurationBetweenEvictorRuns());
+ } else {
+ state.set(BinaryAllocatorState.CLOSE);
+ this.close(false);
+ }
+ }
+
+ public PooledBinary allocateBinary(int reqCapacity) {
+ if (reqCapacity < allocatorConfig.minAllocateSize
+ | reqCapacity > allocatorConfig.maxAllocateSize) {
+ return new PooledBinary(new byte[reqCapacity]);
+ }
+
+ Arena arena = arenaStrategy.choose(heapArenas);
+
+ return new PooledBinary(arena.allocate(reqCapacity), reqCapacity, arena.getArenaID());
+ }
+
+ public void deallocateBinary(PooledBinary binary) {
+ if (binary != null
+ && binary.getLength() >= allocatorConfig.minAllocateSize
+ && binary.getLength() <= allocatorConfig.maxAllocateSize) {
+ int arenaIndex = binary.getArenaIndex();
+ if (arenaIndex != -1) {
+ Arena arena = heapArenas[arenaIndex];
+ arena.deallocate(binary.getValues());
+ }
+ }
+ }
+
+ public void deallocateBatch(PooledBinary[] blobs) {
+ for (PooledBinary blob : blobs) {
+ deallocateBinary(blob);
+ }
+ }
+
+ public long getTotalUsedMemory() {
+ long totalUsedMemory = 0;
+ for (Arena arena : heapArenas) {
+ totalUsedMemory += arena.getTotalUsedMemory();
+ }
+ return totalUsedMemory;
+ }
+
+ public long getTotalActiveMemory() {
+ long totalActiveMemory = 0;
+ for (Arena arena : heapArenas) {
+ totalActiveMemory += arena.getActiveMemory();
+ }
+ return totalActiveMemory;
+ }
+
+ public void evict(double ratio) {
+ for (Arena arena : heapArenas) {
+ arena.evict(ratio);
+ }
+ }
+
+ public boolean isOpen() {
+ return state.get() == BinaryAllocatorState.OPEN;
+ }
+
+ public void close(boolean needReopen) {
+ if (needReopen) state.set(BinaryAllocatorState.TMP_CLOSE);
+ else {
+ state.set(BinaryAllocatorState.CLOSE);
+ if (evictor != null) {
+ evictor.stopEvictor();
+ }
+ }
+ for (Arena arena : heapArenas) {
+ arena.close();
+ }
+ }
+
+ private void restart() {
+ state.set(BinaryAllocatorState.OPEN);
+ for (Arena arena : heapArenas) {
+ arena.restart();
+ }
+ }
+
+ public BinaryAllocatorMetrics getMetrics() {
+ return metrics;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static Arena[] newArenaArray(int size) {
+ return new Arena[size];
+ }
+
+ private static class ThreadArenaRegistry {
+ private Arena threadArenaBinding = null;
+
+ public Arena getArena() {
+ return threadArenaBinding;
+ }
+
+ public void bindArena(Arena arena) {
+ threadArenaBinding = arena;
+ arena.numRegisterThread.incrementAndGet();
+ }
+
+ public void unbindArena() {
+ Arena arena = threadArenaBinding;
+ if (arena != null) {
+ arena.numRegisterThread.decrementAndGet();
+ }
+ }
+
+ @Override
+ protected void finalize() {
+ unbindArena();
+ }
+ }
+
+ private class LeastUsedArenaStrategy implements ArenaStrategy {
+ @Override
+ public Arena choose(Arena[] arenas) {
+ Arena boundArena = arenaRegistry.get().getArena();
+ if (boundArena != null) {
+ return boundArena;
+ }
+
+ if (arenas == null || arenas.length == 0) {
+ return null;
+ }
+
+ Arena minArena = arenas[0];
+
+ for (int i = 1; i < arenas.length; i++) {
+ Arena arena = arenas[i];
+ if (arena.numRegisterThread.get() < minArena.numRegisterThread.get()) {
+ minArena = arena;
+ }
+ }
+
+ arenaRegistry.get().bindArena(minArena);
+ return minArena;
+ }
+ }
+
+ public class GCEvictor extends Evictor {
+ public GCEvictor(String name, Duration evictorShutdownTimeoutDuration) {
+ super(name, evictorShutdownTimeoutDuration);
+ }
+
+ @Override
+ public void run() {
+ LOGGER.debug("Binary allocator running evictor");
+ if (state.get() == BinaryAllocatorState.TMP_CLOSE) {
+ if (JvmGcMonitorMetrics.getInstance().getGcData().getGcTimePercentage() > 20) {
+ restart();
+ }
+ return;
+ }
+
+ if (JvmGcMonitorMetrics.getInstance().getGcData().getGcTimePercentage() > 30) {
Review Comment:
do not use magic number
##########
iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/BinaryAllocatorTest.java:
##########
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.utils;
+
+import org.apache.iotdb.commons.utils.binaryallocator.AllocatorConfig;
+import org.apache.iotdb.commons.utils.binaryallocator.BinaryAllocator;
+import org.apache.iotdb.commons.utils.binaryallocator.SizeClasses;
+
+import org.apache.tsfile.utils.PooledBinary;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CountDownLatch;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class BinaryAllocatorTest {
+ @Test
+ public void testAllocateBinary() {
+ AllocatorConfig config = new AllocatorConfig();
+ config.arenaNum = 1;
+ BinaryAllocator binaryAllocator = new BinaryAllocator(config);
+ PooledBinary binary = binaryAllocator.allocateBinary(256);
Review Comment:
use Odd number like 255 is better to test jvm allocation?
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/binaryallocator/BinaryAllocator.java:
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.utils.binaryallocator;
+
+import org.apache.iotdb.commons.service.metric.JvmGcMonitorMetrics;
+import org.apache.iotdb.commons.service.metric.MetricService;
+
+import org.apache.tsfile.utils.PooledBinary;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.time.Duration;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class BinaryAllocator {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(BinaryAllocator.class);
+
+ private final Arena[] heapArenas;
+ private final AllocatorConfig allocatorConfig;
+
+ public static final BinaryAllocator DEFAULT = new BinaryAllocator(AllocatorConfig.DEFAULT_CONFIG);
+ private ArenaStrategy arenaStrategy = new LeastUsedArenaStrategy();
+ private AtomicReference<BinaryAllocatorState> state =
+ new AtomicReference<>(BinaryAllocatorState.UNINITIALIZED);
+
+ private BinaryAllocatorMetrics metrics;
+ private static ThreadLocal<ThreadArenaRegistry> arenaRegistry =
+ ThreadLocal.withInitial(() -> new ThreadArenaRegistry());
+
+ private Evictor evictor;
+
+ public BinaryAllocator(AllocatorConfig allocatorConfig) {
+ this.allocatorConfig = allocatorConfig;
+
+ heapArenas = newArenaArray(allocatorConfig.arenaNum);
+ SizeClasses sizeClasses = new SizeClasses(allocatorConfig);
+
+ for (int i = 0; i < heapArenas.length; i++) {
+ Arena arena = new Arena(this, sizeClasses, i, allocatorConfig);
+ heapArenas[i] = arena;
+ }
+
+ this.metrics = new BinaryAllocatorMetrics(this);
+ MetricService.getInstance().addMetricSet(this.metrics);
+
+ if (allocatorConfig.enableBinaryAllocator) {
+ state.set(BinaryAllocatorState.OPEN);
+ evictor =
+ new GCEvictor(
+ "binary-allocator-gc-evictor", allocatorConfig.getDurationEvictorShutdownTimeout());
+ evictor.startEvictor(allocatorConfig.getDurationBetweenEvictorRuns());
+ } else {
+ state.set(BinaryAllocatorState.CLOSE);
+ this.close(false);
+ }
+ }
+
+ public PooledBinary allocateBinary(int reqCapacity) {
+ if (reqCapacity < allocatorConfig.minAllocateSize
+ | reqCapacity > allocatorConfig.maxAllocateSize) {
+ return new PooledBinary(new byte[reqCapacity]);
+ }
+
+ Arena arena = arenaStrategy.choose(heapArenas);
+
+ return new PooledBinary(arena.allocate(reqCapacity), reqCapacity, arena.getArenaID());
+ }
+
+ public void deallocateBinary(PooledBinary binary) {
+ if (binary != null
+ && binary.getLength() >= allocatorConfig.minAllocateSize
+ && binary.getLength() <= allocatorConfig.maxAllocateSize) {
+ int arenaIndex = binary.getArenaIndex();
+ if (arenaIndex != -1) {
+ Arena arena = heapArenas[arenaIndex];
+ arena.deallocate(binary.getValues());
+ }
+ }
+ }
+
+ public void deallocateBatch(PooledBinary[] blobs) {
+ for (PooledBinary blob : blobs) {
+ deallocateBinary(blob);
+ }
+ }
+
+ public long getTotalUsedMemory() {
+ long totalUsedMemory = 0;
+ for (Arena arena : heapArenas) {
+ totalUsedMemory += arena.getTotalUsedMemory();
+ }
+ return totalUsedMemory;
+ }
+
+ public long getTotalActiveMemory() {
+ long totalActiveMemory = 0;
+ for (Arena arena : heapArenas) {
+ totalActiveMemory += arena.getActiveMemory();
+ }
+ return totalActiveMemory;
+ }
+
+ public void evict(double ratio) {
+ for (Arena arena : heapArenas) {
+ arena.evict(ratio);
+ }
+ }
+
+ public boolean isOpen() {
+ return state.get() == BinaryAllocatorState.OPEN;
+ }
+
+ public void close(boolean needReopen) {
+ if (needReopen) state.set(BinaryAllocatorState.TMP_CLOSE);
Review Comment:
use {}
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/binaryallocator/BinaryAllocator.java:
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.utils.binaryallocator;
+
+import org.apache.iotdb.commons.service.metric.JvmGcMonitorMetrics;
+import org.apache.iotdb.commons.service.metric.MetricService;
+
+import org.apache.tsfile.utils.PooledBinary;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.time.Duration;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class BinaryAllocator {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(BinaryAllocator.class);
+
+ private final Arena[] heapArenas;
+ private final AllocatorConfig allocatorConfig;
+
+ public static final BinaryAllocator DEFAULT = new BinaryAllocator(AllocatorConfig.DEFAULT_CONFIG);
+ private ArenaStrategy arenaStrategy = new LeastUsedArenaStrategy();
+ private AtomicReference<BinaryAllocatorState> state =
+ new AtomicReference<>(BinaryAllocatorState.UNINITIALIZED);
+
+ private BinaryAllocatorMetrics metrics;
+ private static ThreadLocal<ThreadArenaRegistry> arenaRegistry =
+ ThreadLocal.withInitial(() -> new ThreadArenaRegistry());
+
+ private Evictor evictor;
+
+ public BinaryAllocator(AllocatorConfig allocatorConfig) {
+ this.allocatorConfig = allocatorConfig;
+
+ heapArenas = newArenaArray(allocatorConfig.arenaNum);
+ SizeClasses sizeClasses = new SizeClasses(allocatorConfig);
+
+ for (int i = 0; i < heapArenas.length; i++) {
+ Arena arena = new Arena(this, sizeClasses, i, allocatorConfig);
+ heapArenas[i] = arena;
+ }
+
+ this.metrics = new BinaryAllocatorMetrics(this);
+ MetricService.getInstance().addMetricSet(this.metrics);
+
+ if (allocatorConfig.enableBinaryAllocator) {
+ state.set(BinaryAllocatorState.OPEN);
+ evictor =
+ new GCEvictor(
+ "binary-allocator-gc-evictor", allocatorConfig.getDurationEvictorShutdownTimeout());
+ evictor.startEvictor(allocatorConfig.getDurationBetweenEvictorRuns());
+ } else {
+ state.set(BinaryAllocatorState.CLOSE);
+ this.close(false);
+ }
+ }
+
+ public PooledBinary allocateBinary(int reqCapacity) {
+ if (reqCapacity < allocatorConfig.minAllocateSize
+ | reqCapacity > allocatorConfig.maxAllocateSize) {
+ return new PooledBinary(new byte[reqCapacity]);
+ }
+
+ Arena arena = arenaStrategy.choose(heapArenas);
+
+ return new PooledBinary(arena.allocate(reqCapacity), reqCapacity, arena.getArenaID());
+ }
+
+ public void deallocateBinary(PooledBinary binary) {
+ if (binary != null
+ && binary.getLength() >= allocatorConfig.minAllocateSize
+ && binary.getLength() <= allocatorConfig.maxAllocateSize) {
+ int arenaIndex = binary.getArenaIndex();
+ if (arenaIndex != -1) {
+ Arena arena = heapArenas[arenaIndex];
+ arena.deallocate(binary.getValues());
+ }
+ }
+ }
+
+ public void deallocateBatch(PooledBinary[] blobs) {
+ for (PooledBinary blob : blobs) {
+ deallocateBinary(blob);
+ }
+ }
+
+ public long getTotalUsedMemory() {
+ long totalUsedMemory = 0;
+ for (Arena arena : heapArenas) {
+ totalUsedMemory += arena.getTotalUsedMemory();
+ }
+ return totalUsedMemory;
+ }
+
+ public long getTotalActiveMemory() {
+ long totalActiveMemory = 0;
+ for (Arena arena : heapArenas) {
+ totalActiveMemory += arena.getActiveMemory();
+ }
+ return totalActiveMemory;
+ }
+
+ public void evict(double ratio) {
+ for (Arena arena : heapArenas) {
+ arena.evict(ratio);
+ }
+ }
+
+ public boolean isOpen() {
+ return state.get() == BinaryAllocatorState.OPEN;
+ }
+
+ public void close(boolean needReopen) {
+ if (needReopen) state.set(BinaryAllocatorState.TMP_CLOSE);
+ else {
+ state.set(BinaryAllocatorState.CLOSE);
+ if (evictor != null) {
+ evictor.stopEvictor();
+ }
+ }
+ for (Arena arena : heapArenas) {
+ arena.close();
+ }
+ }
+
+ private void restart() {
+ state.set(BinaryAllocatorState.OPEN);
+ for (Arena arena : heapArenas) {
+ arena.restart();
+ }
+ }
+
+ public BinaryAllocatorMetrics getMetrics() {
+ return metrics;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static Arena[] newArenaArray(int size) {
+ return new Arena[size];
+ }
+
+ private static class ThreadArenaRegistry {
+ private Arena threadArenaBinding = null;
+
+ public Arena getArena() {
+ return threadArenaBinding;
+ }
+
+ public void bindArena(Arena arena) {
+ threadArenaBinding = arena;
+ arena.numRegisterThread.incrementAndGet();
+ }
+
+ public void unbindArena() {
+ Arena arena = threadArenaBinding;
+ if (arena != null) {
+ arena.numRegisterThread.decrementAndGet();
+ }
+ }
+
+ @Override
+ protected void finalize() {
+ unbindArena();
+ }
+ }
+
+ private class LeastUsedArenaStrategy implements ArenaStrategy {
+ @Override
+ public Arena choose(Arena[] arenas) {
+ Arena boundArena = arenaRegistry.get().getArena();
+ if (boundArena != null) {
+ return boundArena;
+ }
+
+ if (arenas == null || arenas.length == 0) {
+ return null;
+ }
+
+ Arena minArena = arenas[0];
+
+ for (int i = 1; i < arenas.length; i++) {
+ Arena arena = arenas[i];
+ if (arena.numRegisterThread.get() < minArena.numRegisterThread.get()) {
+ minArena = arena;
+ }
+ }
+
+ arenaRegistry.get().bindArena(minArena);
+ return minArena;
+ }
+ }
+
+ public class GCEvictor extends Evictor {
+ public GCEvictor(String name, Duration evictorShutdownTimeoutDuration) {
+ super(name, evictorShutdownTimeoutDuration);
+ }
+
+ @Override
+ public void run() {
+ LOGGER.debug("Binary allocator running evictor");
+ if (state.get() == BinaryAllocatorState.TMP_CLOSE) {
+ if (JvmGcMonitorMetrics.getInstance().getGcData().getGcTimePercentage() > 20) {
+ restart();
+ }
+ return;
+ }
+
+ if (JvmGcMonitorMetrics.getInstance().getGcData().getGcTimePercentage() > 30) {
+ for (Arena arena : heapArenas) {
+ arena.evict(1.0);
+ }
+ close(true);
Review Comment:
when to restart if gc become slower?
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/binaryallocator/BinaryAllocator.java:
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.utils.binaryallocator;
+
+import org.apache.iotdb.commons.service.metric.JvmGcMonitorMetrics;
+import org.apache.iotdb.commons.service.metric.MetricService;
+
+import org.apache.tsfile.utils.PooledBinary;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.time.Duration;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class BinaryAllocator {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(BinaryAllocator.class);
+
+ private final Arena[] heapArenas;
+ private final AllocatorConfig allocatorConfig;
+
+ public static final BinaryAllocator DEFAULT = new BinaryAllocator(AllocatorConfig.DEFAULT_CONFIG);
+ private ArenaStrategy arenaStrategy = new LeastUsedArenaStrategy();
+ private AtomicReference<BinaryAllocatorState> state =
+ new AtomicReference<>(BinaryAllocatorState.UNINITIALIZED);
+
+ private BinaryAllocatorMetrics metrics;
+ private static ThreadLocal<ThreadArenaRegistry> arenaRegistry =
+ ThreadLocal.withInitial(() -> new ThreadArenaRegistry());
+
+ private Evictor evictor;
+
+ public BinaryAllocator(AllocatorConfig allocatorConfig) {
+ this.allocatorConfig = allocatorConfig;
+
+ heapArenas = newArenaArray(allocatorConfig.arenaNum);
+ SizeClasses sizeClasses = new SizeClasses(allocatorConfig);
+
+ for (int i = 0; i < heapArenas.length; i++) {
+ Arena arena = new Arena(this, sizeClasses, i, allocatorConfig);
+ heapArenas[i] = arena;
+ }
+
+ this.metrics = new BinaryAllocatorMetrics(this);
+ MetricService.getInstance().addMetricSet(this.metrics);
+
+ if (allocatorConfig.enableBinaryAllocator) {
+ state.set(BinaryAllocatorState.OPEN);
+ evictor =
+ new GCEvictor(
+ "binary-allocator-gc-evictor", allocatorConfig.getDurationEvictorShutdownTimeout());
Review Comment:
do no use magic string
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/binaryallocator/SizeClasses.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.utils.binaryallocator;
+
+public final class SizeClasses {
+
+ // loookup table
+ private int[] sizeIdx2sizeTab;
+ final int lookupMaxSize;
+
+ final int LOG2_QUANTUM;
Review Comment:
Do not capitalize variables that are not final static...
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/binaryallocator/BinaryAllocator.java:
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.utils.binaryallocator;
+
+import org.apache.iotdb.commons.service.metric.JvmGcMonitorMetrics;
+import org.apache.iotdb.commons.service.metric.MetricService;
+
+import org.apache.tsfile.utils.PooledBinary;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.time.Duration;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class BinaryAllocator {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(BinaryAllocator.class);
+
+ private final Arena[] heapArenas;
+ private final AllocatorConfig allocatorConfig;
+
+ public static final BinaryAllocator DEFAULT = new BinaryAllocator(AllocatorConfig.DEFAULT_CONFIG);
+ private ArenaStrategy arenaStrategy = new LeastUsedArenaStrategy();
+ private AtomicReference<BinaryAllocatorState> state =
+ new AtomicReference<>(BinaryAllocatorState.UNINITIALIZED);
+
+ private BinaryAllocatorMetrics metrics;
+ private static ThreadLocal<ThreadArenaRegistry> arenaRegistry =
+ ThreadLocal.withInitial(() -> new ThreadArenaRegistry());
+
+ private Evictor evictor;
+
+ public BinaryAllocator(AllocatorConfig allocatorConfig) {
+ this.allocatorConfig = allocatorConfig;
+
+ heapArenas = newArenaArray(allocatorConfig.arenaNum);
+ SizeClasses sizeClasses = new SizeClasses(allocatorConfig);
+
+ for (int i = 0; i < heapArenas.length; i++) {
+ Arena arena = new Arena(this, sizeClasses, i, allocatorConfig);
+ heapArenas[i] = arena;
+ }
+
+ this.metrics = new BinaryAllocatorMetrics(this);
+ MetricService.getInstance().addMetricSet(this.metrics);
+
+ if (allocatorConfig.enableBinaryAllocator) {
+ state.set(BinaryAllocatorState.OPEN);
+ evictor =
+ new GCEvictor(
+ "binary-allocator-gc-evictor", allocatorConfig.getDurationEvictorShutdownTimeout());
+ evictor.startEvictor(allocatorConfig.getDurationBetweenEvictorRuns());
+ } else {
+ state.set(BinaryAllocatorState.CLOSE);
+ this.close(false);
+ }
+ }
+
+ public PooledBinary allocateBinary(int reqCapacity) {
+ if (reqCapacity < allocatorConfig.minAllocateSize
+ | reqCapacity > allocatorConfig.maxAllocateSize) {
Review Comment:
|| ?
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/binaryallocator/SizeClasses.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.utils.binaryallocator;
+
+public final class SizeClasses {
+
+ // loookup table
+ private int[] sizeIdx2sizeTab;
+ final int lookupMaxSize;
Review Comment:
do you really need this to be a class field? seems only used in constrcutor
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add Binary Allocator [iotdb]
Posted by "MrQuansy (via GitHub)" <gi...@apache.org>.
MrQuansy commented on code in PR #14201:
URL: https://github.com/apache/iotdb/pull/14201#discussion_r1862166395
##########
iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/BinaryAllocatorTest.java:
##########
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.utils;
+
+import org.apache.iotdb.commons.utils.binaryallocator.AllocatorConfig;
+import org.apache.iotdb.commons.utils.binaryallocator.BinaryAllocator;
+import org.apache.iotdb.commons.utils.binaryallocator.SizeClasses;
+
+import org.apache.tsfile.utils.PooledBinary;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CountDownLatch;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class BinaryAllocatorTest {
+ @Test
+ public void testAllocateBinary() {
+ AllocatorConfig config = new AllocatorConfig();
+ config.arenaNum = 1;
+ BinaryAllocator binaryAllocator = new BinaryAllocator(config);
+ PooledBinary binary = binaryAllocator.allocateBinary(256);
Review Comment:
sry, I didn't get your point. I think 255 and 256 have no difference in this testcase..
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add Binary Allocator [iotdb]
Posted by "MrQuansy (via GitHub)" <gi...@apache.org>.
MrQuansy commented on code in PR #14201:
URL: https://github.com/apache/iotdb/pull/14201#discussion_r1863001753
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/binaryallocator/AdaptiveWeightedAverage.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.utils.binaryallocator;
+
+import static java.lang.Math.max;
+
+public class AdaptiveWeightedAverage {
Review Comment:
Copied from jdk17
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org