Skip to content

Neon fast path for str::contains#152176

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
JamieCunliffe:neon-str-contains
Feb 24, 2026
Merged

Neon fast path for str::contains#152176
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
JamieCunliffe:neon-str-contains

Conversation

@JamieCunliffe
Copy link
Copy Markdown
Contributor

Using the SIMD friendly version of the function also gives a decent speed up with Neon.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 5, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Feb 5, 2026

r? @jhpratt

rustbot has assigned @jhpratt.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@jhpratt
Copy link
Copy Markdown
Member

jhpratt commented Feb 7, 2026

I can't vouch for correctness.

@rustbot reroll

@rustbot rustbot assigned Mark-Simulacrum and unassigned jhpratt Feb 7, 2026
@Mark-Simulacrum
Copy link
Copy Markdown
Member

decent speed up with Neon.

How do you know? Did we run benchmarks (can you provide the results)?

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 8, 2026
@JamieCunliffe
Copy link
Copy Markdown
Contributor Author

I didn't see any benchmarks for this in tree but I did write a few quick ones, something such as:

let data = "Lorem ipsum dolor sit amet";
c.bench_function("amet", |b| b.iter(|| black_box("amet".is_contained_in(&data))));

Nightly: [41.489 ns 41.512 ns 41.534 ns]
This change: [10.610 ns 10.611 ns 10.613 ns]

@davidtwco davidtwco added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 23, 2026
@Mark-Simulacrum Mark-Simulacrum added the relnotes-perf Performance improvements that should be mentioned in the release notes. label Feb 24, 2026
@Mark-Simulacrum
Copy link
Copy Markdown
Member

Seems like a reasonable result. Thanks for checking!

@bors r+

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Feb 24, 2026

📌 Commit 011d95b has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 24, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 24, 2026
…=Mark-Simulacrum

Neon fast path for str::contains

Using the SIMD friendly version of the function also gives a decent speed up with Neon.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 24, 2026
…=Mark-Simulacrum

Neon fast path for str::contains

Using the SIMD friendly version of the function also gives a decent speed up with Neon.
rust-bors bot pushed a commit that referenced this pull request Feb 24, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #152176 (Neon fast path for str::contains)
 - #152657 (std: move `exit` out of PAL)
 - #152841 (Streamline `QueryVTableUnerased` into `GetQueryVTable`)
 - #152845 (Skip `tidy` in PR CI jobs not dedicated to running `tidy`)
 - #152897 (Add optional json logging)
 - #153009 (Remove `rustc_feedable_queries` and `define_feedable` macros.)
 - #151558 (Port diagnostic attributes)
 - #152492 (mGCA: Enforce WF element types for array valtrees)
 - #152888 (Fix async drop glue MIR bug)
 - #152988 (Port `#[register_tool]` to the new attribute system)
 - #153018 (`unused_must_use` lint improvements)
 - #153023 (Update books)
 - #153033 (Clarify how "ensure" queries check whether they can skip execution)
 - #153043 (fix error on missing value for -C flags)
 - #153045 (rustc-dev-guide subtree update)

Failed merges:

 - #153032 (Fix attribute parser and kind names.)
@rust-bors rust-bors bot merged commit 9f242b1 into rust-lang:main Feb 24, 2026
11 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 24, 2026
rust-timer added a commit that referenced this pull request Feb 24, 2026
Rollup merge of #152176 - JamieCunliffe:neon-str-contains, r=Mark-Simulacrum

Neon fast path for str::contains

Using the SIMD friendly version of the function also gives a decent speed up with Neon.
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Mar 2, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - rust-lang/rust#152176 (Neon fast path for str::contains)
 - rust-lang/rust#152657 (std: move `exit` out of PAL)
 - rust-lang/rust#152841 (Streamline `QueryVTableUnerased` into `GetQueryVTable`)
 - rust-lang/rust#152845 (Skip `tidy` in PR CI jobs not dedicated to running `tidy`)
 - rust-lang/rust#152897 (Add optional json logging)
 - rust-lang/rust#153009 (Remove `rustc_feedable_queries` and `define_feedable` macros.)
 - rust-lang/rust#151558 (Port diagnostic attributes)
 - rust-lang/rust#152492 (mGCA: Enforce WF element types for array valtrees)
 - rust-lang/rust#152888 (Fix async drop glue MIR bug)
 - rust-lang/rust#152988 (Port `#[register_tool]` to the new attribute system)
 - rust-lang/rust#153018 (`unused_must_use` lint improvements)
 - rust-lang/rust#153023 (Update books)
 - rust-lang/rust#153033 (Clarify how "ensure" queries check whether they can skip execution)
 - rust-lang/rust#153043 (fix error on missing value for -C flags)
 - rust-lang/rust#153045 (rustc-dev-guide subtree update)

Failed merges:

 - rust-lang/rust#153032 (Fix attribute parser and kind names.)
wip-sync pushed a commit to NetBSD/pkgsrc-wip that referenced this pull request Apr 16, 2026
Pkgsrc changes:
 * Update version & checksums, and adapt to new libc crate included.

Upstream changes relative to 1.94.1:

Version 1.95 (2026-04-16)
==========================

Language
--------
- [Stabilize `if let` guards on match arms]
  (rust-lang/rust#141295)
- [`irrefutable_let_patterns` lint no longer lints on let chains]
  (rust-lang/rust#146832)
- [Support importing path-segment keywords with renaming]
  (rust-lang/rust#146972)
- [Stabilize inline assembly for PowerPC and PowerPC64]
  (rust-lang/rust#147996)
- [const-eval: be more consistent in the behavior of padding during
  typed copies] (rust-lang/rust#148967)
- [Const blocks are no longer evaluated to determine if expressions
  involving fallible operations can implicitly be constant-promoted.]
  (rust-lang/rust#150557). Expressions
  whose ability to implicitly be promoted would depend on the result
  of a const block are no longer implicitly promoted.
- [Make operational semantics of pattern matching independent of
  crate and module] (rust-lang/rust#150681)

Compiler
--------
- [Stabilize `--remap-path-scope` for controlling the scoping of
  how paths get remapped in the resulting binary]
  (rust-lang/rust#147611)

Platform Support
----------------
- [Promote `powerpc64-unknown-linux-musl` to Tier 2 with host tools]
  (rust-lang/rust#149962)
- [Promote `aarch64-apple-tvos` to Tier 2]
  (rust-lang/rust#152021)
- [Promote `aarch64-apple-tvos-sim` to Tier 2]
  (rust-lang/rust#152021)
- [Promote `aarch64-apple-watchos` to Tier 2]
  (rust-lang/rust#152021)
- [Promote `aarch64-apple-watchos-sim` to Tier 2]
  (rust-lang/rust#152021)
- [Promote `aarch64-apple-visionos` to Tier 2]
  (rust-lang/rust#152021)
- [Promote `aarch64-apple-visionos-sim` to Tier 2]
  (rust-lang/rust#152021)

Refer to Rust's [platform support page][platform-support-doc]
for more information on Rust's tiered platform support.

https://doc.rust-lang.org/rustc/platform-support.html

Libraries
---------
- [`thread::scope`: document how join interacts with TLS destructors]
  (rust-lang/rust#149482)
- [Speed up `str::contains` on aarch64 targets with `neon` target
  feature enabled by default]
  (rust-lang/rust#152176)

Stabilized APIs
---------------

- [`MaybeUninit<[T; N]>: From<[MaybeUninit<T>; N]>`]
  (https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#impl-From%3CMaybeUninit%3C%5BT;+N%5D%3E%3E-for-%5BMaybeUninit%3CT%3E;+N%5D)
- [`MaybeUninit<[T; N]>: AsRef<[MaybeUninit<T>; N]>`]
  (https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#impl-AsRef%3C%5BMaybeUninit%3CT%3E;+N%5D%3E-for-MaybeUninit%3C%5BT;+N%5D%3E)
- [`MaybeUninit<[T; N]>: AsRef<[MaybeUninit<T>]>`]
  (https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#impl-AsRef%3C%5BMaybeUninit%3CT%3E%5D%3E-for-MaybeUninit%3C%5BT;+N%5D%3E)
- [`MaybeUninit<[T; N]>: AsMut<[MaybeUninit<T>; N]>`]
  (https://doc.rust-lang.org/beta/std/mem/union.MaybeUninit.html#impl-AsMut%3C%5BMaybeUninit%3CT%3E;+N%5D%3E-for-MaybeUninit%3C%5BT;+N%5D%3E)
- [`MaybeUninit<[T; N]>: AsMut<[MaybeUninit<T>]>`]
  (https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#impl-AsMut%3C%5BMaybeUninit%3CT%3E%5D%3E-for-MaybeUninit%3C%5BT;+N%5D%3E)
- [`[MaybeUninit<T>; N]: From<MaybeUninit<[T; N]>>`]
  (https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#impl-From%3C%5BMaybeUninit%3CT%3E;+N%5D%3E-for-MaybeUninit%3C%5BT;+N%5D%3E)
- [`Cell<[T; N]>: AsRef<[Cell<T>; N]>`]
  (https://doc.rust-lang.org/stable/std/cell/struct.Cell.html#impl-AsRef%3C%5BCell%3CT%3E;+N%5D%3E-for-Cell%3C%5BT;+N%5D%3E)
- [`Cell<[T; N]>: AsRef<[Cell<T>]>`]
  (https://doc.rust-lang.org/stable/std/cell/struct.Cell.html#impl-AsRef%3C%5BCell%3CT%3E%5D%3E-for-Cell%3C%5BT;+N%5D%3E)
- [`Cell<[T]>: AsRef<[Cell<T>]>`]
  (https://doc.rust-lang.org/stable/std/cell/struct.Cell.html#impl-AsRef%3C%5BCell%3CT%3E%5D%3E-for-Cell%3C%5BT%5D%3E)
- [`bool: TryFrom<{integer}>`]
  (https://doc.rust-lang.org/stable/std/primitive.bool.html#impl-TryFrom%3Cu128%3E-for-bool)
- [`AtomicPtr::update`]
  (https://doc.rust-lang.org/stable/std/sync/atomic/struct.AtomicPtr.html#method.update)
- [`AtomicPtr::try_update`]
  (https://doc.rust-lang.org/stable/std/sync/atomic/struct.AtomicPtr.html#method.try_update)
- [`AtomicBool::update`]
  (https://doc.rust-lang.org/stable/std/sync/atomic/struct.AtomicBool.html#method.update)
- [`AtomicBool::try_update`]
  (https://doc.rust-lang.org/stable/std/sync/atomic/struct.AtomicBool.html#method.try_update)
- [`AtomicIn::update`]
  (https://doc.rust-lang.org/stable/std/sync/atomic/struct.AtomicIsize.html#method.update)
- [`AtomicIn::try_update`]
  (https://doc.rust-lang.org/stable/std/sync/atomic/struct.AtomicIsize.html#method.try_update)
- [`AtomicUn::update`]
  (https://doc.rust-lang.org/stable/std/sync/atomic/struct.AtomicUsize.html#method.update)
- [`AtomicUn::try_update`]
  (https://doc.rust-lang.org/stable/std/sync/atomic/struct.AtomicUsize.html#method.try_update)
- [`cfg_select!`]
  (https://doc.rust-lang.org/stable/std/macro.cfg_select.html)
- [`mod core::range`]
  (https://doc.rust-lang.org/stable/core/range/index.html)
- [`core::range::RangeInclusive`]
  (https://doc.rust-lang.org/stable/core/range/struct.RangeInclusive.html)
- [`core::range::RangeInclusiveIter`]
  (https://doc.rust-lang.org/stable/core/range/struct.RangeInclusiveIter.html)
- [`core::hint::cold_path`]
  (https://doc.rust-lang.org/stable/core/hint/fn.cold_path.html)
- [`<*const T>::as_ref_unchecked`]
  (https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.as_ref_unchecked)
- [`<*mut T>::as_ref_unchecked`]
  (https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.as_ref_unchecked-1)
- [`<*mut T>::as_mut_unchecked`]
  (https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.as_mut_unchecked)

These previously stable APIs are now stable in const contexts:

- [`fmt::from_fn`]
  (https://doc.rust-lang.org/stable/std/fmt/fn.from_fn.html)
- [`ControlFlow::is_break`]
  (https://doc.rust-lang.org/stable/core/ops/enum.ControlFlow.html#method.is_break)
- [`ControlFlow::is_continue`]
  (https://doc.rust-lang.org/stable/core/ops/enum.ControlFlow.html#method.is_continue)

Cargo
-----
- [docs(report): enhance man pages for `cargo report *`]
  (rust-lang/cargo#16430)

Rustdoc
-----
- [In search results, rank unstable items lower]
  (rust-lang/rust#149460)
- [Add new "hide deprecated items" setting in rustdoc]
  (rust-lang/rust#151091)

Compatibility Notes
-------------------
- [Array coercions may now result in less inference constraints than before]
  (rust-lang/rust#140283)
- Importing `$crate` without renaming, i.e. `use $crate::{self};`,
  is now no longer permitted due to stricter error checking for `self`
  imports.
- [const-eval: be more consistent in the behavior of padding during
  typed copies.] (rust-lang/rust#148967)
  In very rare cases, this may cause compilation errors due to
  bytes from parts of a pointer ending up in the padding bytes of
  a `const` or `static`.
- [A future-incompatibility warning lint `ambiguous_glob_imported_traits`
  is now reported when using an ambiguously glob imported trait]
  (rust-lang/rust#149058)
- [Check lifetime bounds of types mentioning only type parameters]
  (rust-lang/rust#149389)
- [Report more visibility-related ambiguous import errors]
  (rust-lang/rust#149596)
- [Deprecate `Eq::assert_receiver_is_total_eq` and emit future
  compatibility warnings on manual impls]
  (rust-lang/rust#149978)
- [powerpc64: Use the ELF ABI version set in target spec instead
  of guessing] (rust-lang/rust#150468)
  (fixes the ELF ABI used by the OpenBSD target)
- Matching on a `#[non_exhaustive]` enum [now reads the discriminant,
  even if the enum has only one variant]
  (rust-lang/rust#150681). This can cause
  closures to capture values that they previously wouldn't.
- `mut ref` and `mut ref mut` patterns, part of the unstable [Match
  Ergonomics 2024 RFC] (rust-lang/rust#123076),
  were accidentally allowed on stable within struct pattern field
  shorthand. These patterns are now correctly feature-gated as
  unstable in this position.
- [Add future-compatibility warning for derive helper attributes
  which conflict with built-in attributes]
  (rust-lang/rust#151152)
- [JSON target specs]
  (https://doc.rust-lang.org/rustc/targets/custom.html) have been
  destabilized and now require `-Z unstable-options` to use.
  Previously, they could not be used without the standard library,
  which has no stable build mechanism. In preparation for the
  `build-std` project adding that support, JSON target specs are
  being proactively gated to ensure they remain unstable even if
  `build-std` is stabilized. Cargo now includes the `-Z json-target-spec`
  CLI flag to automatically pass `-Z unstable-options` to the
  compiler when needed. See [#150151]
  (rust-lang/rust#150151), [#151534]
  (rust-lang/rust#150151), and
  [rust-lang/cargo#16557] (rust-lang/cargo#16557).
- [The arguments of `#[feature]` attributes on invalid targets are
  now checked] (rust-lang/rust#153764)

Internal Changes
----------------

These changes do not affect any public interfaces of Rust, but they
represent significant improvements to the performance or internals
of rustc and related tools.

- [Update to LLVM 22](rust-lang/rust#150722)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

relnotes-perf Performance improvements that should be mentioned in the release notes. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants