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

feat(130): Introduces SEQREPO_FD_CACHE_MAXSIZE env var #131

Merged

Conversation

kazmiekr
Copy link
Contributor

@kazmiekr kazmiekr commented Jan 9, 2024

Introduces SEQREPO_FD_CACHE_MAXSIZE env var to override the internal fd_cache_size to allow for increased performance without forcing code changes to any SeqRepo clients.

Example:
We are using SeqRepo in an internal library and noticed a 10x decrease in performance with seqrepo 0.6.6 because the internal fd_cache_size is being set to 0 ( no caching ). Rather than forcing clients of SeqRepo to set this value in code and release new versions, it'd be nice to control this value via an env var like SEQREPO_LRU_CACHE_MAXSIZE

Note:
Now that there are two env vars, the old var SEQREPO_LRU_CACHE_MAXSIZE feels incorrectly named as it's unclear which LRU cache it's controlling. I didn't want to introduce any changes to existing code, but maybe this should be renamed to something like SEQREPO_DB_CACHE_MAXSIZE or something to indicate what is being cached and deprecate SEQREPO_LRU_CACHE_MAXSIZE or allow the one env to control all the caches?

Also is it worth providing a better default other than 0 (no cache)? Something small'ish like ~25 or so would at least give a significant performance boost without risking resource exhaustion

@kazmiekr kazmiekr requested a review from andreasprlic January 9, 2024 16:06
@kazmiekr kazmiekr requested a review from reece as a code owner January 9, 2024 16:06
@kazmiekr kazmiekr linked an issue Jan 9, 2024 that may be closed by this pull request
SEQREPO_FD_CACHE_MAXSIZE sets the lru_cache size for file handler caching during FASTA sequence retrievals.
It defaults to 0 to disable any caching, but can be set to a specific value or "none" to be unlimited. Using
a moderate value (>10) will greatly increase performance of sequence retrieval.

Copy link
Member

Choose a reason for hiding this comment

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

What is the downside of increasing this value?

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 think the only downside is in the potential for resource exhaustion on the system? But I'd defer to the discussion in #112 for additional information. Should I add a statement that states if the value is too large, there is a risk for exhaustion?

@andreasprlic
Copy link
Member

I think the mentioned setup issue will require a change similar to this. That appears to be a problem we need to fix across all biocommons packages.

@kazmiekr kazmiekr requested a review from a team as a code owner January 22, 2024 15:23
@kazmiekr kazmiekr requested a review from andreasprlic January 22, 2024 15:54
Copy link
Member

@andreasprlic andreasprlic left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

@andreasprlic andreasprlic merged commit 4d1a349 into main Jan 23, 2024
7 checks passed
@andreasprlic andreasprlic deleted the 130-make-fd_cache_size-configureable-via-env-variable branch January 23, 2024 16:34
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.

Make fd_cache_size configureable via env variable
2 participants