Closed Yomguithereal closed 5 years ago
Any thoughts?
For me looks good, what do you think @avoidwork 🙂
@Yomguithereal bad news; your test change simply exposes a JIT flaw.
If you change iterations from 2
to 4
, performance of all libs get halved, up to a third. No other change needed for everything to slow down.
Now, if we simply add the new lib, it sits comfortably in number 3* spot (it crushes on the gets! wow!).
So, with that simple knowledge I say to close this PR, add the new lib in a new PR and we'll retain accurate results without JIT flaws coming into the picture.
fyi, Maps also tank as your approach 1 million keys, and cease to work properly if you exceed 1 million (today); I'm thinking you uncovered something similar.
Adding a picture 'cause the tables are a pain to copy/pasta... tests ran on an ubuntu 18.04 vm on a tr4 1950x with way more resources than are needed for this project.
Thanks for the answer @avoidwork. This JIT flaw is quite spectacular. Is this only due to the amount of memory used?
Do you want me to explain how I get to those numbers in get/update so we can see whether we can somehow merge our approaches to get the best of both?
@Yomguithereal I don't know about this flaw... this is the first time I've seen a large array iteration seemingly impact unrelated ops; might be a serialization flaw somewhere (seen with IPC years ago).
I'm going to look at your code, and I'll get back via priv message if I have any questions :)
Hello everyone,
So, I drafted some lru cache implementation for the mnemonist library using some idea I had and that we can further discuss if you feel it worthy. (I added it to the benchmark so you can test it on your end)
However, I had one issue with the current benchmark being:
set operations are only "raw" the first time since the cache is the same for each run and this means having an outlier in the results (printing the array of times is a good way to see those outliers and increasing the number of evicts seems to flatten differences).
So, as I understand that benchmarking evictions is an important part of this (and indeed, "raw" sets are marginally interesting), I tried to change some things and test the results. I therefore tried to instantiate the cache for each run and doubled the number of evictions to avoid weird optimizations.
Those are the results I had (once again results on macbook + node v10):
Original
True raw sets (meaning re-instantiating the cache each run)
True raw sets + doubled evicts
Sorry if I am still missing something obvious and if I messed things up while doing the benchmark.
Also, if I switch my implementation to
Map
, I become less efficient with numbers but more efficient with strings.