BitFaster.Caching
BitFaster.Caching copied to clipboard
Optimize LFU maintenance
Apply [MethodImplOptions.AggressiveOptimization]. This was introduced in .NET Core 3.0, to avoid conditional compile just cast 512 to the enum type which is ignored on earlier versions of .NET.
Dynamic PGO on newer frameworks tends not to optimize the maintenance workload because it doesn't execute on the hot path. This reduces throughput when the cache is contended.
This makes very little difference on Windows + x64, but significantly improves throughput for MacOS + Arm.
coverage: 99.179% (+0.05%) from 99.127% when pulling 173645ac3cecc215475d039992d629129dd59af5 on users/alexpeck/opt2 into 80ba526a7e8f947544bed9e2afd82c26c2fb46e5 on main.
Not able to measure any gain from this on windows or mac, for .Net6 or .net8. Likely the change for the ConcurrentLruCore struct to be embedded/inlined into the parent class eliminated any gain we might see from this.
net6base.zip net6opt.zip net8base.zip net8opt.zip data - mac.zip WinCompare.xlsx