-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Draft] Multi-Tenant CMS Manager #14953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Initial working MultiTenantCMSManager with 3 basic tests
A simplistic MultiTenantCMSManager implementation
A simplistic MultiTenantCMSManager implementation with 3 basic tests
add dynamic rebalancing and live writer tests
merge main CMS manager
merge CMS manager edits and tests
Continuing where @yaser-aj left off, here's what I plan to tackle next:
Please let us know if we are missing anything important. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Yaser, and Luke, for sharing a prototype of this approach. The simplicity of tweaking things from outside while leaving CMS untouched, is indeed tempting!
I do agree with @jpountz however that
- The simplest version (equal sharing) is too limited.
- As we start building more elaborate logic, things get very complex very quickly.
- As a small example, an equal sharing strategy doesn't account for some schedulers getting more merges than others. Once you start doing that,
updateBudget()
must be called each time a merge is submitted or completed, which needs deeply integrated hooks. - The real complexity in designing and maintaining, lies in figuring out the right policy budget allocation policy.
- As a small example, an equal sharing strategy doesn't account for some schedulers getting more merges than others. Once you start doing that,
- It doesn't provide a sure way of controlling the total no. of threads consumed by indexing+merging, which is a primary motivation for such a scheduler.
Hence, I'm leaning more in the direction of #14900, at least as of now. Happy to hear more thoughts on this.
Regardless, there's a lot of good work here, especially in the tests, which can be leveraged in any impl. we pursue for this change.
* | ||
* @param cms the merge scheduler to unregister | ||
*/ | ||
public void unregister(ConcurrentMergeScheduler cms) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should we call it "deregister"?
int count = schedulers.size(); | ||
if (count == 0) return; | ||
|
||
int share = Math.max(1, maxThreadCount / count); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be Math.min()
, otherwise, we'll set some schedulers to 0 maxMergeThreads.
ConcurrentMergeScheduler[] cmsArr = new ConcurrentMergeScheduler[numSchedulers]; | ||
for (int i = 0; i < numSchedulers; i++) { | ||
cmsArr[i] = new ConcurrentMergeScheduler(); | ||
manager.register(cmsArr[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already register in the CMS ctor. Do we need to register again?
|
||
/** Used in tests to read the current registered CMS set */ | ||
synchronized Set<ConcurrentMergeScheduler> getRegisteredSchedulersForTest() { | ||
return new HashSet<>(schedulers); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just return a 1Collections.unmodifableSet()` ? and avoid allocating a new set and copy all the entries into it..
} | ||
|
||
/** Used in tests to clear all registered CMS instances */ | ||
synchronized void unregisterAllForTest() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this method need to be synchronized
?
A proposed solution to #13883.
Currently, each
ConcurrentMergeScheduler
manages its own threads independently, assuming no other merge schedulers are running in the JVM. This leads to potential over-allocation of system resources when manyIndexWriter
s are active. This draft PR demonstrates a simple approach to multi-tenancy by introducing a global manager that divides a global thread budget among all registered CMS instances.Key Changes
MultiTenantCMSManager
ConcurrentMergeScheduler
instances.maxThreadCount
andmaxMergeCount
as CMSs are registered or unregistered.ConcurrentMergeScheduler
IndexWriter
integration, and auto-unregistering behavior.Important Notes
Will update this draft PR with more points + to-dos soon.