Skip to content
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

Add fast path to String.Equals #111806

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

Conversation

EgorBo
Copy link
Member

@EgorBo EgorBo commented Jan 24, 2025

Experiments with #111586 (comment)

Currently, our primary method for comparing strings is SpanHelpers.SequenceEqual. Due to the string's object layout, we always provide SequenceEqual with only 4-byte aligned data (the offset of String._firstChar is 12 bytes), which might negatively impact performance. SequenceEqual currently does not align data, meaning its Vector512 path always hits the cache line every iteration.

Also, do 64b/16b alignment inside SequenceEqual itself

We will see what the performance bot thinks about the microbenchmarks 🙂

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jan 24, 2025
Copy link
Contributor

@xtqqczze xtqqczze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: rename EqualsHelper to EqualsOrdinalHelper

@EgorBo EgorBo force-pushed the test-optimization branch from 18264c1 to 948b8d7 Compare January 25, 2025 16:21
@EgorBo

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants