Steve Fink (2014-10-22T22:06:01.000Z)
d at domenic.me (2014-11-18T22:43:17.169Z)
On 10/22/2014 02:26 PM, Mark Miller wrote: > I should have been more explicit, but GC costs are almost my entire > point. These costs aside, my FastWeakMaps are more expensive in all > ways than SlowWeakMaps, though only by a constant factor, since each > FastWeakMap operation must also perform the corresponding SlowWeakMap > operation. Ah, sorry, I totally missed your point. > That is when you find yourself doing an ephemeron collection. The > point of the transposed representation is to collect most ephemeron > garbage using conventional collection. Consider Ok, I get it now, and completely agree with your analysis, with the caveat that supporting [[Shadow]] gives me the heebie-jeebies. It turns a read into a write, for one thing. (The read of the key, I mean.) Could the extra shadow table be kept separate from the key object? I know! Let's use a WeakMap! :-) > Here's the key important thing: In a generational collector, at this > point we'd typically postpone ephemeron collection. To do so, we would > complete the mark phase conventionally, by simply marking the values > held by slowField. This marks slowValue, causing it to get promoted to > the next older generation. THIS IS EXPENSIVE. Yes, this is a big deal. > Chicken and egg. If WeakMaps are used for private state (and > trademarks and...), they will be used a lot. But they will only be > used for those things if it isn't fatally slow to do so. Yes, I fully expect WeakMaps to start mattering soon-ish, though I'm still procrastinating on doing anything about our current implementation. > Yeah, I'm very curious about whether this can be made cheap enough > that implementations would be willing to do it. If so, then everything > is much better, whether we transpose the representation or not. We'll probably all end up at some messy point in the middle. Maybe a fast initial pass without the checks. It'll be something that depends on a bunch of assumptions for normal-case performance, but doesn't completely break down in the pathological cases. > Exactly! I should have been clearer that these were the only costs I > am concerned about here. Regarding all other costs, my example code > only adds expense. If I had read more closely, I probably would have noticed that...