You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
It is necessary to check not only exact hits, but also non-existent keys. #20
An important parameter of reality is an unsuccessful search in the cache.
Misses will break off v8 optimization in implementations that use objects to store keys.
Using 0x & deoptigate I can't validate your claim that accessing a property which doesn't exist has any impact on the hidden class that v8 is looking at. Is there documentation that says otherwise?
@avoidwork , there must be an lru.get instead lru.set
for (let i = 0; i < num; i++) lru.set(data2[i][0]);
Perhaps I was mistaken that the missing keys will greatly influence. According to the tests, it turns out that there is almost no difference. However for reliability it is necessary to check.
I guess that one takeout is that in this case with killed perfs, the approach initiated by @dominictarr still is very good evict-wise while being not so good with gets and memory-wise (twice the memory amount since you need to store two maps).
I've updated the test in master to utilize the consistent data set from the perf* killer above. We could have 2 benchmarks with Number & String keys; I don't think we should drop the Number test 'cause that's primarily what I use in production apps (I hope most people would), as it is a legitimate /10 for perf.
Activity
avoidwork commentedon Nov 21, 2018
[[GetOwnProperty]] ( P ),Pis always a string - https://es5.github.io/#x8.12.1Using
0x&deoptigateI can't validate your claim that accessing a property which doesn't exist has any impact on the hidden class that v8 is looking at. Is there documentation that says otherwise?repsac-by commentedon Nov 21, 2018
V8 performs many optimizations that are sure to be compatible with the language specification, but do not have to follow it literally.
repsac-by commentedon Nov 21, 2018
https://github.com/repsac-by/bench-lru/tree/kill-optimizations
avoidwork commentedon Nov 21, 2018
Ok, but this benchmark is only testing slow evicts, not how to deoptimize v8 with strings in megamorphic objects.
avoidwork commentedon Nov 21, 2018
Oh, I think I can kill perf much better... :)
Sample worker.js script:
results in...
deopts for all.
edit: modified it to simply swap between the 2 datasets for evict vs twice the record count.
avoidwork commentedon Nov 21, 2018
Curious why
mkcgives up the ghost.avoidwork commentedon Nov 21, 2018
@Kikobeats @dominictarr ^
repsac-by commentedon Nov 21, 2018
@avoidwork , there must be an
lru.getinsteadlru.setPerhaps I was mistaken that the missing keys will greatly influence. According to the tests, it turns out that there is almost no difference. However for reliability it is necessary to check.
avoidwork commentedon Nov 21, 2018
@repsac-by fixed the 1 line, also changed the evict to be more obvious imo (data1,data2 > data2,data2).
avoidwork commentedon Nov 21, 2018
@repsac-by if I add a third
getutilizing thedata2keys there's no impact.Yomguithereal commentedon Nov 21, 2018
Results on my end (dropping temporarily
lru_cachebecause of the capacity leak andlru-cachebecause of #26):I guess that one takeout is that in this case with killed perfs, the approach initiated by @dominictarr still is very good evict-wise while being not so good with gets and memory-wise (twice the memory amount since you need to store two maps).
avoidwork commentedon Nov 25, 2018
I've updated the test in
masterto utilize the consistent data set from the perf* killer above. We could have 2 benchmarks withNumber&Stringkeys; I don't think we should drop theNumbertest 'cause that's primarily what I use in production apps (I hope most people would), as it is a legitimate /10 for perf.