-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Speed up KeyAnalyzer for substring based frozen collections #89689
Closed
Commits on Jul 29, 2023
-
Move the IsLeft/IsRight decision out of the loop
The slicing is really only changed once per Count, so move the IsLeft-dependent logic into `Slicer` method and eliminate the `GetSpan` delegate. Changed to also pass the already-computed `set` of unique substrings to the `CreateAnalysisResults` method, so we don't recompute the slices twice. In order than either the set or the original `uniqueStrings` can be passed, swapped that argument for the `Analyze` method to take the `uniqueStrings` as a `string[]` (which it already is at all call-sites).
Configuration menu - View commit details
-
Copy full SHA for 677d59d - Browse repository at this point
Copy the full SHA 677d59dView commit details -
Subtle bug in that the entire string is being placed in the set, not the span.
Configuration menu - View commit details
-
Copy full SHA for c8c8801 - Browse repository at this point
Copy the full SHA c8c8801View commit details -
Only count the input strings once.
Since we are working with the same set of input strings in each strategy there's no reason to take the length every time we make an attempt (per count, both left and right justified). Hoist the calculation of the acceptable number of collisions out to the top, do it once, and pass that number into the `HasSufficientUniquenessFactor` method for it to (locally) use up.
Configuration menu - View commit details
-
Copy full SHA for a168767 - Browse repository at this point
Copy the full SHA a168767View commit details -
Back to string[] for HasSufficientUniquenessFactor
Benchmarks ever so slightly better.
Configuration menu - View commit details
-
Copy full SHA for 860ebb3 - Browse repository at this point
Copy the full SHA 860ebb3View commit details -
Looks like the overhead of IEnumerable<string> is not worth the savings for the benchmark test data. Perhaps it would matter less if we were freezing more strings, but not likely
Configuration menu - View commit details
-
Copy full SHA for c1dd5d9 - Browse repository at this point
Copy the full SHA c1dd5d9View commit details
Commits on Jul 30, 2023
-
Use trait-based classes to get everything inlined
This will cost one extra `HashSet<string>` and one extra `SubstringComparer` to be allocated, but might make the code run faster. Use the GSW strategy for virtual flattening
Configuration menu - View commit details
-
Copy full SHA for 7060c23 - Browse repository at this point
Copy the full SHA 7060c23View commit details
Commits on Aug 1, 2023
-
Replace ISubstringComparer with ISubstringEqualityComparer as that's more indicative of the interface it's exposing, and rename everything derived from that. Fixed the implementation of FullStringEqualityComparer to not actually use the slice ReadOnlySpan(s) in the Equals and GetHashCode specializations. Added comments for the SubstringEquality classes Renamed the files for the specialization of the comparers. Fixed the unit tests under debug builds. Extended the test suite data for the KeyAnalyzer tests to exercise using the data in FrozenFromKnownValuesTests.
Configuration menu - View commit details
-
Copy full SHA for 23d028f - Browse repository at this point
Copy the full SHA 23d028fView commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.