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

Vectorize find_first_not_of/find_last_not_of member functions (single character) #5102

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

AlexGuteniev
Copy link
Contributor

Another basic_string vectorization.

🎲 Decisions

Some nearly-arbitrary decisions, can change if needed.

  • Return position in "last" but pointer in "first". For "first", pointer has to be adjusted in header due to unknown original beginning and not passing it due to _Start_at applying. For "last", can adjust in the separately compiled code, and can potentially use it for future micro-optimization.
  • Specialize for 32 and 64 bit character too. Not very useful, but general algorithm is written already.

⏱️ Benchmark results

Benchmark main this
bm<char, not_highly_aligned_allocator, Op::StringFindNotFirstOne>/8021/3056 738 ns 49.8 ns
bm<char, not_highly_aligned_allocator, Op::StringFindNotFirstOne>/63/62 17.9 ns 4.78 ns
bm<char, not_highly_aligned_allocator, Op::StringFindNotFirstOne>/31/30 9.56 ns 5.71 ns
bm<char, not_highly_aligned_allocator, Op::StringFindNotFirstOne>/15/14 4.76 ns 5.34 ns
bm<char, not_highly_aligned_allocator, Op::StringFindNotFirstOne>/7/6 2.77 ns 3.23 ns
bm<char, not_highly_aligned_allocator, Op::StringFindNotLastOne>/8021/3056 740 ns 49.8 ns
bm<char, not_highly_aligned_allocator, Op::StringFindNotLastOne>/63/62 25.7 ns 4.89 ns
bm<char, not_highly_aligned_allocator, Op::StringFindNotLastOne>/31/30 8.88 ns 6.07 ns
bm<char, not_highly_aligned_allocator, Op::StringFindNotLastOne>/15/14 4.72 ns 5.31 ns
bm<char, not_highly_aligned_allocator, Op::StringFindNotLastOne>/7/6 2.51 ns 3.68 ns
bm<wchar_t, not_highly_aligned_allocator, Op::StringFindNotFirstOne>/8021/3056 749 ns 82.8 ns
bm<wchar_t, not_highly_aligned_allocator, Op::StringFindNotFirstOne>/63/62 17.5 ns 4.14 ns
bm<wchar_t, not_highly_aligned_allocator, Op::StringFindNotFirstOne>/31/30 9.58 ns 3.64 ns
bm<wchar_t, not_highly_aligned_allocator, Op::StringFindNotFirstOne>/15/14 7.36 ns 4.65 ns
bm<wchar_t, not_highly_aligned_allocator, Op::StringFindNotFirstOne>/7/6 2.91 ns 4.67 ns
bm<wchar_t, not_highly_aligned_allocator, Op::StringFindNotLastOne>/8021/3056 739 ns 85.1 ns
bm<wchar_t, not_highly_aligned_allocator, Op::StringFindNotLastOne>/63/62 21.5 ns 4.69 ns
bm<wchar_t, not_highly_aligned_allocator, Op::StringFindNotLastOne>/31/30 8.55 ns 4.11 ns
bm<wchar_t, not_highly_aligned_allocator, Op::StringFindNotLastOne>/15/14 4.48 ns 4.38 ns
bm<wchar_t, not_highly_aligned_allocator, Op::StringFindNotLastOne>/7/6 2.40 ns 3.63 ns
bm<char32_t, not_highly_aligned_allocator, Op::StringFindNotFirstOne>/8021/3056 737 ns 157 ns
bm<char32_t, not_highly_aligned_allocator, Op::StringFindNotFirstOne>/63/62 17.4 ns 5.51 ns
bm<char32_t, not_highly_aligned_allocator, Op::StringFindNotFirstOne>/31/30 9.39 ns 4.03 ns
bm<char32_t, not_highly_aligned_allocator, Op::StringFindNotFirstOne>/15/14 6.90 ns 3.39 ns
bm<char32_t, not_highly_aligned_allocator, Op::StringFindNotFirstOne>/7/6 2.95 ns 3.17 ns
bm<char32_t, not_highly_aligned_allocator, Op::StringFindNotLastOne>/8021/3056 737 ns 159 ns
bm<char32_t, not_highly_aligned_allocator, Op::StringFindNotLastOne>/63/62 17.5 ns 6.31 ns
bm<char32_t, not_highly_aligned_allocator, Op::StringFindNotLastOne>/31/30 8.83 ns 4.62 ns
bm<char32_t, not_highly_aligned_allocator, Op::StringFindNotLastOne>/15/14 4.52 ns 4.08 ns
bm<char32_t, not_highly_aligned_allocator, Op::StringFindNotLastOne>/7/6 2.63 ns 3.41 ns

@AlexGuteniev AlexGuteniev requested a review from a team as a code owner November 19, 2024 21:04
@StephanTLavavej StephanTLavavej added the performance Must go faster label Nov 19, 2024
@StephanTLavavej StephanTLavavej self-assigned this Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster
Projects
Status: Initial Review
Development

Successfully merging this pull request may close these issues.

2 participants