Skip to content
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

Merged
merged 4 commits into from May 11, 2022

Conversation

labkey-jeckels
Copy link
Contributor

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

  • Cache the required modules for a given container
  • Clear the cache anytime the container tree or container properties change
  • Minor assorted cleanup

Copy link
Contributor

@labkey-adam labkey-adam left a 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 =
Copy link
Contributor

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"));
Copy link
Contributor

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).

Copy link
Contributor Author

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.

Copy link
Contributor

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);
}
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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

@labkey-jeckels labkey-jeckels merged commit 6c801ce into develop May 11, 2022
@labkey-jeckels labkey-jeckels deleted the fb_45377_requiredModulesCache branch May 11, 2022 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants