pnowojski commented on a change in pull request #15322: URL: https://github.com/apache/flink/pull/15322#discussion_r668823024
########## File path: flink-dstl/flink-dstl-dfs/src/main/java/org/apache/flink/changelog/fs/FsStateChangelogCleanerImpl.java ########## @@ -0,0 +1,66 @@ +/* + * 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.flink.changelog.fs; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.Executor; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +class FsStateChangelogCleanerImpl implements FsStateChangelogCleaner { + private static final Logger LOG = LoggerFactory.getLogger(FsStateChangelogCleanerImpl.class); + private static final int MAX_TASKS_PER_THREAD = 100; + + private final Executor executor; + + public FsStateChangelogCleanerImpl(int nThreads) { + // Use a fixed-size thread pool with a bounded queue so that cleanupAsync back pressures + // callers if the cleanup doesn't keep up. + // In all cases except abort this are uploader threads; while on abort this is the task + // thread. + this( + new ThreadPoolExecutor( + nThreads, + nThreads, + 0L, + TimeUnit.MILLISECONDS, + new LinkedBlockingQueue<>(nThreads * MAX_TASKS_PER_THREAD), + (ThreadFactory) Thread::new)); Review comment: I'm not worried about the overhead of having an idle thread pool. 1. I'm not sure if it's currently implemented, but having a backpressure on {{AsyncCheckpointRunnable}} also sounds reasonable. 2. If we have multiple pools doing very similar things, that should be tweaked in very similar way it's not easier to configure all of them independently for the user. At best user would need to know about each of those pools, and even assuming that he would have a problem if he wants to limits parallel threads writing to his DFS to for example 4, regardless if that's {{AsyncCheckpointRunnable}}, periodic materialisation or changelog writes. 3. Is it? What if you want to check if number of threads is an issue and you just simply want to bump/decrease the number of threads by a factor of 4? With single pool it's easier to do. With many pools you might hit a problem that you simply forgotten to modify that one thread pool that was actually causing the problem. -- 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]
