Closed ouvaa closed 3 months ago
I doubt that the root cause is mutex/lock contention(not very sure), I guess that switching to spinlock maybe could consume more/full cpu usage, but it will not increase the throughputs(more likely decrease).
let me investigate it later.
By right, the lockless contention implementations(e.g. otter,ristretto,ccache) should avoid this problem.
Maybe I'll try this approach someday, but it obviously introduces much complexity and more memory usage/GC pressure.
UPDATE: I add gcscan
tests to measure the gc time of golang caches, the results is here https://github.com/phuslu/lru?tab=readme-ov-file#gc-scan
considering the significantly longer gcscan time of lockless contention implementations, I'd like keep current architectural of phuslu/lru.
because it's on hotpath and most used feature currently, was checking cpu utilization and found...
it's great and it's fast but i'm not sure what's wrong with this, with my 12 core laptop, i can only push to use max 660% of cpu cores meaning roughly 55% cpu usage using phuslu lru.
can you try out and see what i mean? i hope to push for 90% cpu utilization, u can comment out the cache.Set below and see the empty for loop with use around 99% cpu.