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
Issue 45377: Poor performance determining required modules #3339
Conversation
…a container with many workbooks
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.
I offered a few totally optional suggestions. Let's hear it for 25K workbooks!
CacheManager.DAY, | ||
"Required modules per containers")); | ||
|
||
private final static CacheLoader<GUID, Set<Module>> REQUIRED_MODULE_LOADER = |
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.
You could simply use the Container
as the key
CacheManager.getCache( | ||
Constants.getMaxContainers(), | ||
CacheManager.DAY, | ||
"Required modules per containers")); |
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.
You could call CacheManager.getBlockingCache()
and set the CacheLoader
as part of the factory method. And then call get(key, argument)
.
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.
I tried doing that originally, but there's no get(key, argument)
version. Only get(key)
and get(key, argument, loader)
But if I switch to using the Container as the key, I can consolidate a bit.
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.
Cache
doesn't have that variant, but BlockingCache
does. Declare REQUIRED_MODULES_CACHE
as a BlockingCache and voila!
{ | ||
List<Container> siblings = new ArrayList<>(mm.get(key)); | ||
Collections.sort(siblings); | ||
} |
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.
I guess we don't care about the sort any more?
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.
Unless I'm misreading the code, this never did anything. We create a copy of the list, sort it, and then throw it out.
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.
Yep, agreed... I hadn't looked very closely at first
Rationale
When a container has 25k+ child workbooks, calculating its required modules can be time consuming. And we do it multiple times on a single page render. Caching will provide a big speedup.
Changes