jt2594838 commented on code in PR #9667: URL: https://github.com/apache/iotdb/pull/9667#discussion_r1199868417
########## node-commons/src/assembly/resources/conf/iotdb-common.properties: ########## @@ -541,6 +541,26 @@ cluster_name=defaultCluster # Datatype: int # device_path_cache_size=500000 +# When flushing a MemTable, the range of thread number that will be available for each pipeline state. +# Set to 1 when less than or equal to 0. +# Datatype: int +# flush_min_sub_thread_num=1 +# flush_max_sub_thread_num=16 + +# If the idle ratio of a DynamicThread is below this value, it will try to add a new thread in +# its group if there are fewer threads than flushMemTableMaxSubThread. Review Comment: fixed ########## node-commons/src/assembly/resources/conf/iotdb-common.properties: ########## @@ -541,6 +541,26 @@ cluster_name=defaultCluster # Datatype: int # device_path_cache_size=500000 +# When flushing a MemTable, the range of thread number that will be available for each pipeline state. +# Set to 1 when less than or equal to 0. +# Datatype: int +# flush_min_sub_thread_num=1 +# flush_max_sub_thread_num=16 + +# If the idle ratio of a DynamicThread is below this value, it will try to add a new thread in +# its group if there are fewer threads than flushMemTableMaxSubThread. +# Datatype: double +#dynamic_min_idle_ratio=0.1 + +# If the idle ratio of a DynamicThread is over this value, it will try to exit if there are more +# threads than flushMemTableMinSubThread. Review Comment: fixed ########## node-commons/src/main/java/org/apache/iotdb/commons/concurrent/dynamic/DynamicThread.java: ########## @@ -0,0 +1,117 @@ +/* + * 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.concurrent.dynamic; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * DynamicThread record the idle time and running time of the thread and trigger addThread() or + * onThreadExit() in DynamicThreadGroup to change the number of threads in a thread group + * dynamically. IMPORTANT: the implementation must call idleToRunning(), runningToIdle(), and + * shouldExit() properly in runInternal(). + */ +public abstract class DynamicThread implements Runnable { + + private static final Logger logger = LoggerFactory.getLogger(DynamicThread.class); + private DynamicThreadGroup threadGroup; + private long idleStart; + private long runningStart; + private long idleTimeSum; + private long runningTimeSum; + // TODO: add configuration for the values + private double maximumIdleRatio = 0.5; + private double minimumIdleRatio = 0.1; + private long minimumRunningTime = 10_000_000_000L; Review Comment: fixed -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
