-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Streamline ConcurrentDictionary.Enumerator.MoveNext #116949
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR streamlines the implementation of ConcurrentDictionary’s enumerator to improve performance and reduce code complexity.
- Eliminates the explicit state machine by replacing the switch statement with a while(true) loop.
- Adopts a primary constructor for the Enumerator class and simplifies the bucket iteration logic.
...ries/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentDictionary.cs
Show resolved
Hide resolved
|
Tagging subscribers to this area: @dotnet/area-system-collections |
|
/ba-g unrelated wasm failures |
|
This speedup is likely from getting rid of the irreducible loop. As #25448 (comment) notes, I'll take another look at the JIT heuristics and see if there's some other way to get inlining to happen. |
With this change the JIT will inline We should be able to resolve those GDVs earlier (for value type instantiations) but we currently don't propagate the type information fast enough, so the GDVs are still there during escape analysis and make the JIT overly conservative. I think I can add a post-pass between inlining and EA where if we have discovered the exact type of an enumerator we can try and aggressively resolve its GDVs.
|
cc: @AndyAyersMS