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

Caching fix #282

Merged
merged 8 commits into from
Jul 11, 2024
Merged

Caching fix #282

merged 8 commits into from
Jul 11, 2024

Conversation

hextraza
Copy link
Contributor

Caching was getting aggressively emptied because Lucene has a callback running on a loop internally that empties the cache if the IndexReader gets garbage collected. This patch caches the IndexReader per-session alongside the LRUQueryCache and slightly modifies the caching policy, which should improve the cache's behavior in prod.

private final LRUQueryCache queryCache;
private final IndexReader indexReader;

public CacheEntry(LRUQueryCache queryCache, IndexReader indexReader) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont know anything about lucene, but is caching a Reader a good idea? Does this keep file handles open?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and if we cache them, should we be caching one reader instance per lucene index, rather than one per cache result?

@hextraza
Copy link
Contributor Author

hextraza commented Jul 1, 2024

This moves to caching one IndexSearcher per lucene index path instead of one IndexReader. I moved the error handling to the caching function instead of the base of the API call which is why there are so many line changes in the most recent patch. If this passes (except for that postgres issue) we should reindex.

@bbimber
Copy link
Contributor

bbimber commented Jul 2, 2024

@hextraza: i think this is probably fine. there's one thing i think we need and one question i have:

  • Should we add a server shutdown listener and call close() on any open readers? not sure this practically matters but it feels like a reasonable thing.
  • I think we need a hook for code to announce changes to a lucene index (like the ETL copying a new file) on JBrowseService, which would cause the cache to just clear/close that entry.

as i write this: open file handles could be a problem if unrelated code tried to update the lucene index files, right?

@bbimber bbimber merged commit bb92e7c into discvr-23.11 Jul 11, 2024
2 of 4 checks passed
@bbimber bbimber deleted the 23.11_fb_cachingProdFix branch July 11, 2024 14:38
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.

2 participants