randomairborne / expiringmap

a HashMap-backed TTL map
2 stars 1 forks source link

speed up ExpiringMap::vacuum #5

Closed demoray closed 4 months ago

demoray commented 4 months ago

Using not_expired requires calling elapsed for every entry in the hashset, which requires a syscall. By calling duration_since, we only have a single syscall regardless of how many entries are in the map.

randomairborne commented 4 months ago

I ran into this in some of my own code. thanks!