DivyanshIITB commented on code in PR #14335:
URL: https://github.com/apache/lucene/pull/14335#discussion_r1998645110


##########
lucene/core/src/java/org/apache/lucene/index/MultiTenantMergeScheduler.java:
##########
@@ -0,0 +1,44 @@
+package org.apache.lucene.index;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.io.IOException;
+
+/**
+ * A multi-tenant merge scheduler that shares a global thread pool across 
multiple IndexWriters.
+ */
+public class MultiTenantMergeScheduler extends MergeScheduler {
+
+    // Shared global thread pool
+    private static final ExecutorService MERGE_THREAD_POOL = 
Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() / 2);

Review Comment:
   Thanks for the suggestion! I've updated the implementation to use lazy 
static initialization by wrapping the thread pool in a nested static class. 
This ensures the thread pool is only created when first accessed, avoiding 
unnecessary resource allocation. Let me know if you have any further feedback! 
Now, instead of directly initializing MERGE_THREAD_POOL, I'm using a LazyHolder 
class with a getMergeThreadPool() method to ensure thread-safe lazy 
initialization. This should prevent the thread pool from being created when the 
policy is unused."



-- 
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: issues-unsubscr...@lucene.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to