Improve performance symmetry of Set.intersect#19291
Improve performance symmetry of Set.intersect#19291aw0lid wants to merge 4 commits intodotnet:mainfrom
Conversation
❗ Release notes requiredCaution No release notes found for the changed paths (see table below). Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format. The following format is recommended for this repository:
If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request. You can open this PR in browser to add release notes: open in github.dev
|
ca72b26 to
e7906f4
Compare
e7906f4 to
779485c
Compare
|
Closing this PR due to messy merge conflicts and history issues. |
Fix Set.intersect Performance Asymmetry & Identity Preservation
Problem
Set.intersectin F# currently exhibits a significant performance asymmetry when intersecting sets of very different sizes.a) and checks membership in the second set (b).a).Observed Behavior (Current)
Solution
This PR introduces a size-based heuristic and a lookup approach to preserve identity while optimizing traversal:
tryGetmethod to retrieve the original references from the first set (a).a), satisfying the identity contract.Benchmark Results
Tested on Linux x64, .NET 10.0 (Debug build for local verification).
Verification Code
The following snippet was used to verify both performance and identity preservation:
Note
This code is for verification purposes only. It demonstrates performance and identity correctness; it is not part of the production API.
Checklist