-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MemoryCache: optimized clock access, optimized expiration checks #53469
MemoryCache: optimized clock access, optimized expiration checks #53469
Conversation
…lock offset (units).
…azyClockOffsetSerialPosition`
…ckOffsetSerialPosition
…b.com/edevoogd/runtime into memorycache-clockquantization-jit-now
Tagging subscribers to this area: @eerhardt, @maryamariyan, @michaelgsharp Issue DetailsThis PR is intended as an alternative for (or precursor to) #47239: Developers observe more efficient expiration checks in Microsoft.Extensions.Caching.MemoryCache. There is quite a bit to unpack here. This PR does not employ a timer for the background expiration scan, yet. Still relying on the background scan trigger checks in a bunch of public methods, the commits in this PR already eke out quite a bit more performance from the cache. Benchmarks are included below. Additional performance improvements are still expected, if the background scan trigger checks were to be dropped in favor of timer-based background scans. Benchmark comparisonNo Slower results for the provided threshold = 1% and noise filter = 0.3ns.
An extensive description of groups of individual commits explains the steps taken to introduce the alternative approach, which is based on 3 pillars:
All existing unit tests are passing locally, but I would really like to have more eyes on this. Specifically, I would like to gage:
|
Is the cache already benefiting from the runtime clock improvements? |
Yes, "Base" as measured benefits from #50263. |
Hi @edevoogd Big thanks for you PR. Could you please solve the merge conflict? As soon as you do that I am going to test your changes using our TechEmpower infrastructure. |
Hi @adamsitnik, merge conflicts were resolved. The failing build checks appear to be due to
|
Hi @ViktorHofer, I hope you can educate me on this topic. When I opened this PR, a couple of weeks ago, all build checks were passing. When @adamsitnik recently asked me to resolve merge conflicts that had occurred since, it turned out that the build was now failing with more than half of the checks not passing. Apparently, some things had changed in the build infrastructure, such as as the adoption of a new SDK version. But there was more than that and it appears that recent failures were triggered by the As I was looking for clues, I bumped into #54012 and I took inspiration from some of the changes that you did. That said, I'm quite confident that I don't fully grasp the underlying build infrastructure changes that required me to change the project file; it turned out to be quite a trial-and-error experience for me. The build is passing now, but I'm wondering if my approach is correct. As you can see from commit At the moment, as I don't fundamentally understand what it is exactly that I'm "fixing", I'm not very confident with my changes in the latest 2 commits. Could you please shed some light on recent build infrastructure changes that I should accommodate and if these commits are in line with expectations? Do we need the |
Thank you for your contribution and approach proposal. Later, it would be good to first discuss the approach over the issue and expected behavior, before taking this refactored change. |
This PR is intended as an alternative for (or precursor to) #47239: Developers observe more efficient expiration checks in Microsoft.Extensions.Caching.MemoryCache.
There is quite a bit to unpack here.
This PR does not employ a timer for the background expiration scan, yet. Still relying on the background scan trigger checks in a bunch of public methods, the commits in this PR already eke out quite a bit more performance from the cache.
Benchmarks are included below. Additional performance improvements are still expected, if the background scan trigger checks were to be dropped in favor of timer-based background scans.
Benchmark comparison
No Slower results for the provided threshold = 1% and noise filter = 0.3ns.
An extensive description of groups of individual commits explains the steps taken to introduce the alternative approach, which is based on 3 pillars:
DateTimeOffset
representationEnvironment.TickCount64
All existing unit tests are passing locally, but I would really like to have more eyes on this. Specifically, I would like to gage: