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

Evaluation of the ngd cache performance and types #94

Open
erikyao opened this issue Oct 10, 2022 · 2 comments
Open

Evaluation of the ngd cache performance and types #94

erikyao opened this issue Oct 10, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@erikyao
Copy link
Contributor

erikyao commented Oct 10, 2022

Status Quo

Current implementation of NGD caches is in https://github.com/biothings/pending.api/blob/master/web/utils/cache.py. It's made due to that functools.lru_cache cannot decorate async def functions.

Alternative: cachetools

Performance Comparison

Is cachetools.LRUCache faster than our vanilla implementation?

Which type is best for the NGD scenario?

cachetools provided the following types of caches:

  • cachetools.FIFOCache: First In First Out
  • cachetools.LFUCache: Least Frequently Used (will be discarded)
  • cachetools.LRUCache: Least Recently Used (will be discarded)
  • cachetools.MRUCache: Most Recently Used (will be discarded)
  • cachetools.RRCache: Random Replacement (item selected by random.choice())
  • cachetools.TTLCache: LRU Cache with per-item time-to-live (TTL)
  • cachetools.TLRUCache: Time-aware LRU; similar to cachetools.TTLCache but the TTL calculation can be customized

Which type works best for NGD?

Side Note: cachetools thread-safety

All the above cache classes are not thread-safe. However, cachetools provides thread-safe decorators; see cachetools.func - functools.lru_cache() compatible decorators.

Since we are using corotines, thread-safety is not an issue so far.

@erikyao erikyao self-assigned this Oct 10, 2022
@ctrl-schaff
Copy link
Contributor

Referring to the endpoint https://biothings.ci.transltr.io/semmeddb/query/ngd. Isn't documented in the pending.api example queries, but is found on the smartapi listing

@ctrl-schaff ctrl-schaff added the enhancement New feature or request label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants