You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2021/11/29 18:48:16 UTC

[GitHub] [druid] somu-imply opened a new pull request #12000: Removing unused processing threadpool on broker

somu-imply opened a new pull request #12000:
URL: https://github.com/apache/druid/pull/12000


   Removing unused processing thread pool on broker
   
   This PR has:
   - [ ] been self-reviewed.
      - [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
   - [ ] added documentation for new or modified features or behaviors.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
   - [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
   - [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
   - [ ] added integration tests.
   - [ ] been tested in a test Druid cluster.
   


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] somu-imply commented on a change in pull request #12000: Removing unused processing threadpool on broker

Posted by GitBox <gi...@apache.org>.
somu-imply commented on a change in pull request #12000:
URL: https://github.com/apache/druid/pull/12000#discussion_r760390425



##########
File path: server/src/main/java/org/apache/druid/guice/BrokerProcessingModule.java
##########
@@ -0,0 +1,187 @@
+/*
+ * 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.druid.guice;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import com.google.inject.Binder;
+import com.google.inject.Module;
+import com.google.inject.Provides;
+import com.google.inject.ProvisionException;
+import org.apache.druid.client.cache.BackgroundCachePopulator;
+import org.apache.druid.client.cache.CacheConfig;
+import org.apache.druid.client.cache.CachePopulator;
+import org.apache.druid.client.cache.CachePopulatorStats;
+import org.apache.druid.client.cache.ForegroundCachePopulator;
+import org.apache.druid.collections.BlockingPool;
+import org.apache.druid.collections.DefaultBlockingPool;
+import org.apache.druid.collections.DummyNonBlockingPool;
+import org.apache.druid.collections.NonBlockingPool;
+import org.apache.druid.guice.annotations.Global;
+import org.apache.druid.guice.annotations.Merging;
+import org.apache.druid.guice.annotations.Smile;
+import org.apache.druid.java.util.common.StringUtils;
+import org.apache.druid.java.util.common.concurrent.ExecutorServiceConfig;
+import org.apache.druid.java.util.common.lifecycle.Lifecycle;
+import org.apache.druid.java.util.common.logger.Logger;
+import org.apache.druid.offheap.OffheapBufferGenerator;
+import org.apache.druid.query.DruidProcessingConfig;
+import org.apache.druid.query.ExecutorServiceMonitor;
+import org.apache.druid.query.MetricsEmittingQueryProcessingPool;
+import org.apache.druid.query.PrioritizedExecutorService;
+import org.apache.druid.query.QueryProcessingPool;
+import org.apache.druid.server.metrics.MetricsModule;
+import org.apache.druid.utils.JvmUtils;
+
+import java.nio.ByteBuffer;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ForkJoinPool;
+
+/**
+ * This module is used to fulfill dependency injection of query processing and caching resources: buffer pools and
+ * thread pools on Broker. Broker does not need to be allocated an intermediate results pool.
+ * This is separated from DruidProcessingModule to separate the needs of the broker from the historicals
+ */
+
+public class BrokerProcessingModule implements Module
+{
+  private static final Logger log = new Logger(BrokerProcessingModule.class);
+
+  @Override
+  public void configure(Binder binder)
+  {
+    binder.bind(ExecutorServiceConfig.class).to(DruidProcessingConfig.class);
+    MetricsModule.register(binder, ExecutorServiceMonitor.class);
+  }
+
+  @Provides
+  @LazySingleton
+  public CachePopulator getCachePopulator(
+      @Smile ObjectMapper smileMapper,
+      CachePopulatorStats cachePopulatorStats,
+      CacheConfig cacheConfig
+  )
+  {
+    if (cacheConfig.getNumBackgroundThreads() > 0) {
+      final ExecutorService exec = Executors.newFixedThreadPool(
+          cacheConfig.getNumBackgroundThreads(),
+          new ThreadFactoryBuilder()
+              .setNameFormat("background-cacher-%d")
+              .setDaemon(true)
+              .setPriority(Thread.MIN_PRIORITY)
+              .build()
+      );
+
+      return new BackgroundCachePopulator(exec, smileMapper, cachePopulatorStats, cacheConfig.getMaxEntrySize());
+    } else {
+      return new ForegroundCachePopulator(smileMapper, cachePopulatorStats, cacheConfig.getMaxEntrySize());
+    }
+  }
+
+  @Provides
+  @ManageLifecycle
+  public QueryProcessingPool getProcessingExecutorPool(
+      DruidProcessingConfig config,
+      ExecutorServiceMonitor executorServiceMonitor,
+      Lifecycle lifecycle
+  )
+  {
+    return new MetricsEmittingQueryProcessingPool(
+        PrioritizedExecutorService.create(
+            lifecycle,
+            config
+        ),
+        executorServiceMonitor
+    );

Review comment:
       @clintropolis I am not sure about that. The router ignores this pool. If the broker needs to do the same we can make them similar as per your suggestion
   




-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] clintropolis commented on a change in pull request #12000: Removing unused processing threadpool on broker

Posted by GitBox <gi...@apache.org>.
clintropolis commented on a change in pull request #12000:
URL: https://github.com/apache/druid/pull/12000#discussion_r759802025



##########
File path: server/src/main/java/org/apache/druid/guice/BrokerProcessingModule.java
##########
@@ -0,0 +1,187 @@
+/*
+ * 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.druid.guice;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import com.google.inject.Binder;
+import com.google.inject.Module;
+import com.google.inject.Provides;
+import com.google.inject.ProvisionException;
+import org.apache.druid.client.cache.BackgroundCachePopulator;
+import org.apache.druid.client.cache.CacheConfig;
+import org.apache.druid.client.cache.CachePopulator;
+import org.apache.druid.client.cache.CachePopulatorStats;
+import org.apache.druid.client.cache.ForegroundCachePopulator;
+import org.apache.druid.collections.BlockingPool;
+import org.apache.druid.collections.DefaultBlockingPool;
+import org.apache.druid.collections.DummyNonBlockingPool;
+import org.apache.druid.collections.NonBlockingPool;
+import org.apache.druid.guice.annotations.Global;
+import org.apache.druid.guice.annotations.Merging;
+import org.apache.druid.guice.annotations.Smile;
+import org.apache.druid.java.util.common.StringUtils;
+import org.apache.druid.java.util.common.concurrent.ExecutorServiceConfig;
+import org.apache.druid.java.util.common.lifecycle.Lifecycle;
+import org.apache.druid.java.util.common.logger.Logger;
+import org.apache.druid.offheap.OffheapBufferGenerator;
+import org.apache.druid.query.DruidProcessingConfig;
+import org.apache.druid.query.ExecutorServiceMonitor;
+import org.apache.druid.query.MetricsEmittingQueryProcessingPool;
+import org.apache.druid.query.PrioritizedExecutorService;
+import org.apache.druid.query.QueryProcessingPool;
+import org.apache.druid.server.metrics.MetricsModule;
+import org.apache.druid.utils.JvmUtils;
+
+import java.nio.ByteBuffer;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ForkJoinPool;
+
+/**
+ * This module is used to fulfill dependency injection of query processing and caching resources: buffer pools and
+ * thread pools on Broker. Broker does not need to be allocated an intermediate results pool.
+ * This is separated from DruidProcessingModule to separate the needs of the broker from the historicals
+ */
+
+public class BrokerProcessingModule implements Module
+{
+  private static final Logger log = new Logger(BrokerProcessingModule.class);
+
+  @Override
+  public void configure(Binder binder)
+  {
+    binder.bind(ExecutorServiceConfig.class).to(DruidProcessingConfig.class);
+    MetricsModule.register(binder, ExecutorServiceMonitor.class);
+  }
+
+  @Provides
+  @LazySingleton
+  public CachePopulator getCachePopulator(
+      @Smile ObjectMapper smileMapper,
+      CachePopulatorStats cachePopulatorStats,
+      CacheConfig cacheConfig
+  )
+  {
+    if (cacheConfig.getNumBackgroundThreads() > 0) {
+      final ExecutorService exec = Executors.newFixedThreadPool(
+          cacheConfig.getNumBackgroundThreads(),
+          new ThreadFactoryBuilder()
+              .setNameFormat("background-cacher-%d")
+              .setDaemon(true)
+              .setPriority(Thread.MIN_PRIORITY)
+              .build()
+      );
+
+      return new BackgroundCachePopulator(exec, smileMapper, cachePopulatorStats, cacheConfig.getMaxEntrySize());
+    } else {
+      return new ForegroundCachePopulator(smileMapper, cachePopulatorStats, cacheConfig.getMaxEntrySize());
+    }
+  }
+
+  @Provides
+  @ManageLifecycle
+  public QueryProcessingPool getProcessingExecutorPool(
+      DruidProcessingConfig config,
+      ExecutorServiceMonitor executorServiceMonitor,
+      Lifecycle lifecycle
+  )
+  {
+    return new MetricsEmittingQueryProcessingPool(
+        PrioritizedExecutorService.create(
+            lifecycle,
+            config
+        ),
+        executorServiceMonitor
+    );

Review comment:
       does the broker use this thread pool? Should this be like the router processing module? https://github.com/apache/druid/blob/master/server/src/main/java/org/apache/druid/guice/RouterProcessingModule.java#L67




-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] somu-imply commented on a change in pull request #12000: Removing unused processing threadpool on broker

Posted by GitBox <gi...@apache.org>.
somu-imply commented on a change in pull request #12000:
URL: https://github.com/apache/druid/pull/12000#discussion_r758803396



##########
File path: server/src/main/java/org/apache/druid/guice/DruidProcessingModule.java
##########
@@ -94,6 +94,7 @@ public CachePopulator getCachePopulator(
 
   @Provides
   @ManageLifecycle
+  //per segment

Review comment:
       Will be removing this comment in a checkin. Travis already passes on this




-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] somu-imply closed pull request #12000: Removing unused processing threadpool on broker

Posted by GitBox <gi...@apache.org>.
somu-imply closed pull request #12000:
URL: https://github.com/apache/druid/pull/12000


   


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] somu-imply commented on a change in pull request #12000: Removing unused processing threadpool on broker

Posted by GitBox <gi...@apache.org>.
somu-imply commented on a change in pull request #12000:
URL: https://github.com/apache/druid/pull/12000#discussion_r760635678



##########
File path: server/src/main/java/org/apache/druid/guice/BrokerProcessingModule.java
##########
@@ -0,0 +1,187 @@
+/*
+ * 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.druid.guice;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import com.google.inject.Binder;
+import com.google.inject.Module;
+import com.google.inject.Provides;
+import com.google.inject.ProvisionException;
+import org.apache.druid.client.cache.BackgroundCachePopulator;
+import org.apache.druid.client.cache.CacheConfig;
+import org.apache.druid.client.cache.CachePopulator;
+import org.apache.druid.client.cache.CachePopulatorStats;
+import org.apache.druid.client.cache.ForegroundCachePopulator;
+import org.apache.druid.collections.BlockingPool;
+import org.apache.druid.collections.DefaultBlockingPool;
+import org.apache.druid.collections.DummyNonBlockingPool;
+import org.apache.druid.collections.NonBlockingPool;
+import org.apache.druid.guice.annotations.Global;
+import org.apache.druid.guice.annotations.Merging;
+import org.apache.druid.guice.annotations.Smile;
+import org.apache.druid.java.util.common.StringUtils;
+import org.apache.druid.java.util.common.concurrent.ExecutorServiceConfig;
+import org.apache.druid.java.util.common.lifecycle.Lifecycle;
+import org.apache.druid.java.util.common.logger.Logger;
+import org.apache.druid.offheap.OffheapBufferGenerator;
+import org.apache.druid.query.DruidProcessingConfig;
+import org.apache.druid.query.ExecutorServiceMonitor;
+import org.apache.druid.query.MetricsEmittingQueryProcessingPool;
+import org.apache.druid.query.PrioritizedExecutorService;
+import org.apache.druid.query.QueryProcessingPool;
+import org.apache.druid.server.metrics.MetricsModule;
+import org.apache.druid.utils.JvmUtils;
+
+import java.nio.ByteBuffer;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ForkJoinPool;
+
+/**
+ * This module is used to fulfill dependency injection of query processing and caching resources: buffer pools and
+ * thread pools on Broker. Broker does not need to be allocated an intermediate results pool.
+ * This is separated from DruidProcessingModule to separate the needs of the broker from the historicals
+ */
+
+public class BrokerProcessingModule implements Module
+{
+  private static final Logger log = new Logger(BrokerProcessingModule.class);
+
+  @Override
+  public void configure(Binder binder)
+  {
+    binder.bind(ExecutorServiceConfig.class).to(DruidProcessingConfig.class);
+    MetricsModule.register(binder, ExecutorServiceMonitor.class);
+  }
+
+  @Provides
+  @LazySingleton
+  public CachePopulator getCachePopulator(
+      @Smile ObjectMapper smileMapper,
+      CachePopulatorStats cachePopulatorStats,
+      CacheConfig cacheConfig
+  )
+  {
+    if (cacheConfig.getNumBackgroundThreads() > 0) {
+      final ExecutorService exec = Executors.newFixedThreadPool(
+          cacheConfig.getNumBackgroundThreads(),
+          new ThreadFactoryBuilder()
+              .setNameFormat("background-cacher-%d")
+              .setDaemon(true)
+              .setPriority(Thread.MIN_PRIORITY)
+              .build()
+      );
+
+      return new BackgroundCachePopulator(exec, smileMapper, cachePopulatorStats, cacheConfig.getMaxEntrySize());
+    } else {
+      return new ForegroundCachePopulator(smileMapper, cachePopulatorStats, cacheConfig.getMaxEntrySize());
+    }
+  }
+
+  @Provides
+  @ManageLifecycle
+  public QueryProcessingPool getProcessingExecutorPool(
+      DruidProcessingConfig config,
+      ExecutorServiceMonitor executorServiceMonitor,
+      Lifecycle lifecycle
+  )
+  {
+    return new MetricsEmittingQueryProcessingPool(
+        PrioritizedExecutorService.create(
+            lifecycle,
+            config
+        ),
+        executorServiceMonitor
+    );

Review comment:
       Agreed
   




-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] clintropolis commented on a change in pull request #12000: Removing unused processing threadpool on broker

Posted by GitBox <gi...@apache.org>.
clintropolis commented on a change in pull request #12000:
URL: https://github.com/apache/druid/pull/12000#discussion_r760605338



##########
File path: server/src/main/java/org/apache/druid/guice/BrokerProcessingModule.java
##########
@@ -0,0 +1,187 @@
+/*
+ * 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.druid.guice;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import com.google.inject.Binder;
+import com.google.inject.Module;
+import com.google.inject.Provides;
+import com.google.inject.ProvisionException;
+import org.apache.druid.client.cache.BackgroundCachePopulator;
+import org.apache.druid.client.cache.CacheConfig;
+import org.apache.druid.client.cache.CachePopulator;
+import org.apache.druid.client.cache.CachePopulatorStats;
+import org.apache.druid.client.cache.ForegroundCachePopulator;
+import org.apache.druid.collections.BlockingPool;
+import org.apache.druid.collections.DefaultBlockingPool;
+import org.apache.druid.collections.DummyNonBlockingPool;
+import org.apache.druid.collections.NonBlockingPool;
+import org.apache.druid.guice.annotations.Global;
+import org.apache.druid.guice.annotations.Merging;
+import org.apache.druid.guice.annotations.Smile;
+import org.apache.druid.java.util.common.StringUtils;
+import org.apache.druid.java.util.common.concurrent.ExecutorServiceConfig;
+import org.apache.druid.java.util.common.lifecycle.Lifecycle;
+import org.apache.druid.java.util.common.logger.Logger;
+import org.apache.druid.offheap.OffheapBufferGenerator;
+import org.apache.druid.query.DruidProcessingConfig;
+import org.apache.druid.query.ExecutorServiceMonitor;
+import org.apache.druid.query.MetricsEmittingQueryProcessingPool;
+import org.apache.druid.query.PrioritizedExecutorService;
+import org.apache.druid.query.QueryProcessingPool;
+import org.apache.druid.server.metrics.MetricsModule;
+import org.apache.druid.utils.JvmUtils;
+
+import java.nio.ByteBuffer;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ForkJoinPool;
+
+/**
+ * This module is used to fulfill dependency injection of query processing and caching resources: buffer pools and
+ * thread pools on Broker. Broker does not need to be allocated an intermediate results pool.
+ * This is separated from DruidProcessingModule to separate the needs of the broker from the historicals
+ */
+
+public class BrokerProcessingModule implements Module
+{
+  private static final Logger log = new Logger(BrokerProcessingModule.class);
+
+  @Override
+  public void configure(Binder binder)
+  {
+    binder.bind(ExecutorServiceConfig.class).to(DruidProcessingConfig.class);
+    MetricsModule.register(binder, ExecutorServiceMonitor.class);
+  }
+
+  @Provides
+  @LazySingleton
+  public CachePopulator getCachePopulator(
+      @Smile ObjectMapper smileMapper,
+      CachePopulatorStats cachePopulatorStats,
+      CacheConfig cacheConfig
+  )
+  {
+    if (cacheConfig.getNumBackgroundThreads() > 0) {
+      final ExecutorService exec = Executors.newFixedThreadPool(
+          cacheConfig.getNumBackgroundThreads(),
+          new ThreadFactoryBuilder()
+              .setNameFormat("background-cacher-%d")
+              .setDaemon(true)
+              .setPriority(Thread.MIN_PRIORITY)
+              .build()
+      );
+
+      return new BackgroundCachePopulator(exec, smileMapper, cachePopulatorStats, cacheConfig.getMaxEntrySize());
+    } else {
+      return new ForegroundCachePopulator(smileMapper, cachePopulatorStats, cacheConfig.getMaxEntrySize());
+    }
+  }
+
+  @Provides
+  @ManageLifecycle
+  public QueryProcessingPool getProcessingExecutorPool(
+      DruidProcessingConfig config,
+      ExecutorServiceMonitor executorServiceMonitor,
+      Lifecycle lifecycle
+  )
+  {
+    return new MetricsEmittingQueryProcessingPool(
+        PrioritizedExecutorService.create(
+            lifecycle,
+            config
+        ),
+        executorServiceMonitor
+    );

Review comment:
       I think we should try to make it a dummy pool to find out if it is used or not, no point in creating it if it isn't used I think (we could consider making dummy implementations of the broker fork join merge pools in `DruidProcessingModule` for historicals since it definitely isn't used by anything in a historical, but doesn't need to be done in this PR). I think it isn't used, but i'm uncertain and I hope integration tests will fail if it is actually used anywhere.




-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] somu-imply commented on a change in pull request #12000: Removing unused processing threadpool on broker

Posted by GitBox <gi...@apache.org>.
somu-imply commented on a change in pull request #12000:
URL: https://github.com/apache/druid/pull/12000#discussion_r760390425



##########
File path: server/src/main/java/org/apache/druid/guice/BrokerProcessingModule.java
##########
@@ -0,0 +1,187 @@
+/*
+ * 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.druid.guice;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import com.google.inject.Binder;
+import com.google.inject.Module;
+import com.google.inject.Provides;
+import com.google.inject.ProvisionException;
+import org.apache.druid.client.cache.BackgroundCachePopulator;
+import org.apache.druid.client.cache.CacheConfig;
+import org.apache.druid.client.cache.CachePopulator;
+import org.apache.druid.client.cache.CachePopulatorStats;
+import org.apache.druid.client.cache.ForegroundCachePopulator;
+import org.apache.druid.collections.BlockingPool;
+import org.apache.druid.collections.DefaultBlockingPool;
+import org.apache.druid.collections.DummyNonBlockingPool;
+import org.apache.druid.collections.NonBlockingPool;
+import org.apache.druid.guice.annotations.Global;
+import org.apache.druid.guice.annotations.Merging;
+import org.apache.druid.guice.annotations.Smile;
+import org.apache.druid.java.util.common.StringUtils;
+import org.apache.druid.java.util.common.concurrent.ExecutorServiceConfig;
+import org.apache.druid.java.util.common.lifecycle.Lifecycle;
+import org.apache.druid.java.util.common.logger.Logger;
+import org.apache.druid.offheap.OffheapBufferGenerator;
+import org.apache.druid.query.DruidProcessingConfig;
+import org.apache.druid.query.ExecutorServiceMonitor;
+import org.apache.druid.query.MetricsEmittingQueryProcessingPool;
+import org.apache.druid.query.PrioritizedExecutorService;
+import org.apache.druid.query.QueryProcessingPool;
+import org.apache.druid.server.metrics.MetricsModule;
+import org.apache.druid.utils.JvmUtils;
+
+import java.nio.ByteBuffer;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ForkJoinPool;
+
+/**
+ * This module is used to fulfill dependency injection of query processing and caching resources: buffer pools and
+ * thread pools on Broker. Broker does not need to be allocated an intermediate results pool.
+ * This is separated from DruidProcessingModule to separate the needs of the broker from the historicals
+ */
+
+public class BrokerProcessingModule implements Module
+{
+  private static final Logger log = new Logger(BrokerProcessingModule.class);
+
+  @Override
+  public void configure(Binder binder)
+  {
+    binder.bind(ExecutorServiceConfig.class).to(DruidProcessingConfig.class);
+    MetricsModule.register(binder, ExecutorServiceMonitor.class);
+  }
+
+  @Provides
+  @LazySingleton
+  public CachePopulator getCachePopulator(
+      @Smile ObjectMapper smileMapper,
+      CachePopulatorStats cachePopulatorStats,
+      CacheConfig cacheConfig
+  )
+  {
+    if (cacheConfig.getNumBackgroundThreads() > 0) {
+      final ExecutorService exec = Executors.newFixedThreadPool(
+          cacheConfig.getNumBackgroundThreads(),
+          new ThreadFactoryBuilder()
+              .setNameFormat("background-cacher-%d")
+              .setDaemon(true)
+              .setPriority(Thread.MIN_PRIORITY)
+              .build()
+      );
+
+      return new BackgroundCachePopulator(exec, smileMapper, cachePopulatorStats, cacheConfig.getMaxEntrySize());
+    } else {
+      return new ForegroundCachePopulator(smileMapper, cachePopulatorStats, cacheConfig.getMaxEntrySize());
+    }
+  }
+
+  @Provides
+  @ManageLifecycle
+  public QueryProcessingPool getProcessingExecutorPool(
+      DruidProcessingConfig config,
+      ExecutorServiceMonitor executorServiceMonitor,
+      Lifecycle lifecycle
+  )
+  {
+    return new MetricsEmittingQueryProcessingPool(
+        PrioritizedExecutorService.create(
+            lifecycle,
+            config
+        ),
+        executorServiceMonitor
+    );

Review comment:
       @clintropolis Based on what I see, it does not but I am not sure about that.  The router ignores this pool. If the broker needs to do the same we can make them similar as per your suggestion
   




-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org