03:26
<Jack Works>
thanks!
17:13
<jschoi>
Kris Kowal: Looking at https://www.collectionsjs.com/, I’m wondering if you haven’t had any demand for LIFO or FIFO maps or sets. I wouldn’t use them myself in favor of LRU or LFU, but LIFO and FIFO are so simple that I’m wondering if anyone has asked for them.
17:14
<Kris Kowal>
Kris Kowal: Looking at https://www.collectionsjs.com/, I’m wondering if you haven’t had any demand for LIFO or FIFO maps or sets. I wouldn’t use them myself in favor of LRU or LFU, but LIFO and FIFO are so simple that I’m wondering if anyone has asked for them.
I made some mistakes in the design of collections that precluded adoption, so I don’t have meaningful signal.
17:15
<Kris Kowal>
That said, those mistakes are addressable and I’ve got a plan, but not time.
17:33
<bakkot>

I wondering if you haven’t had any demand for LIFO or FIFO maps or sets

fwiw I would expect these to exist in more languages if they were actually commonly needed

17:33
<bakkot>
or maybe it's just that they are called a different thing
17:34
<shu>
i have an interest in these things, but not as general purpose collections but as caches
17:34
<shu>
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
17:35
<shu>
they might misguidedly use WeakRefs right now, which, with a "maybe clear on every GC", is a particularly bad cache eviction policy
17:35
<shu>
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
17:39
<jschoi>
Well, the main purpose of https://github.com/js-choi/proposal-policy-map-set would be to act as caches, and so LIFOMap and FIFOMap are in it right now. Hopefully they would match what you’re looking for.
17:40
<jschoi>
E.g., const cache = new LIFOMap(100).
17:40
<shu>
i have not thought yet deeply about if LIFO and FIFO with a simple size are sufficiently flexible eviction policies
17:40
<jschoi>
I’d love to hear about your use cases more sometime.
17:41
<jschoi>
I plan to present this for Stage 1 at the next plenary.
17:41
<shu>
roughly, the same kind of things Java's soft reference and prio references tried to solve
17:55
<rickbutton>
what interesting timing, userland caches with gc-hooks has come up on our side internally as something people are really asking for
17:55
<rickbutton>
not convinced but it keeps getting mentioned
17:56
<rickbutton>
we also had the thought "what if we provided a cache instead"
17:57
<shu>
even for a tightly coupled engine and userspace like bbg has, surfacing gc hooks still seems like a choice you'll rue
17:57
<jschoi>
we also had the thought "what if we provided a cache instead"
If you are interested in co-championing policy caches, or if you have concrete use cases that I can put in the explainer, please let me know!
17:57
<rickbutton>
that is exactly what I said shu
17:58
<rickbutton>
providing a higher-level cache to userland is slightly less "rue the day" but still not pleasant
17:59
<rickbutton>
If you are interested in co-championing policy caches, or if you have concrete use cases that I can put in the explainer, please let me know!
I'll make a note to write down what people have mentioned and forward it along. To be fair it isn't anything concrete on our side, there has been some interest from app teams in something like this tho
18:04
<jschoi>
Re: https://github.com/js-choi/proposal-function-memo/issues/5#issuecomment-1083446581
18:04
<jschoi>
What was the logic of Maps using SameValueZero again? Was it because of NaN?
18:06
<ljharb>
no, it doesn’t impact NaN, it’s because of -0
18:06
<bakkot>
yeah it's just the right thing
18:07
<jschoi>
Should f(+0) and f(-0) always memoize to the same thing, then?
18:07
<bakkot>
haha good luck, that depends on the use case
18:07
<jschoi>
I really would like to allow users to supply Map-like caches…
18:08
<bakkot>
the notion of equality for memoization inherently depends on the use case
18:08
<jschoi>
I suppose the user could supply a MapLikeButWithNegativeZero that has the same interface.
18:08
<bakkot>
this is the main reason memoization is hard
18:08
<jschoi>
f.memo(new MapLikeButWithNegativeZeroAlsoItIsLFU(100))
18:11
<jschoi>
The idea is that the user could supply a map-like cache to memo, with which they can customize both argument-lookup matching and cache policy. By default it would be an unbounded ordinary new Map with SameValueZero semantics, but they could also supply new MapWithDifferentEquivalence or whatever…and that hopefully would be flexible enough for everyone.