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

Cache use cases #4

Open
js-choi opened this issue Mar 31, 2022 · 1 comment
Open

Cache use cases #4

js-choi opened this issue Mar 31, 2022 · 1 comment
Labels
question Further information is requested

Comments

@js-choi
Copy link
Collaborator

js-choi commented Mar 31, 2022

My primary use case is to give control to the developer over the caches that the memo function would use for function memoization. For example, Python offers a LRU policy with a customizable limit.

@syg from V8 said:

We have a lot of pressure, from my observations, of large and "expert" apps asking for GC hooking points and GC info to be exposed for the purpose of writing userland caches. They might misguidedly use WeakRefs right now, which, with a “maybe clear on every GC”, is a particularly bad cache eviction policy. One realization the V8 team has had recently is well, maybe there's space for directly designing caches instead of exposing GC stuff, which seems blech. […] I have not thought yet deeply about if LIFO and FIFO with a simple size are sufficiently flexible eviction policies. [Use cases would include] roughly, the same kind of things Java's soft reference and prio references tried to solve.

@rickbutton added:

Userland caches with gc-hooks has come up on our side internally as something people are really asking for. Not convinced but it keeps getting mentioned. We also had the thought “what if we provided a cache instead”.

We need to come up with specific isolated illustrations of these use cases and check if they would be adequately served by Map-like data structures with constant limits.

@js-choi js-choi added the question Further information is requested label Mar 31, 2022
@js-choi
Copy link
Collaborator Author

js-choi commented Aug 17, 2022

The withdrawn WICG memory-pressure proposal lists several use cases related to memory pressure and therefore to caching in general:

  • An application with an infinite-scroll wants to know if they need to remove items from their list and how agressively.
  • An application handling large files (photo/video sharing for example) wants to free up cache when the user's device need it.
  • An email application saving email content for fast interaction wants to free up the cache if it is needed by the system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant