Use REP MOVSB/STOSB when the ERMSB feature is present #392
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.
Followup to #365, part of addressing #339
The first commit reorganizes the
mem
functions to reduce the amount of platform specific code. Specifically, the following#[inline(always)]
Rust functions:impls::copy_forward
impls::copy_backward
impls::set_bytes
The second commit uses the functionality added in rust-lang/rust#78396 to check if the
"ermsb"
feature is enabled at compile-time (as we can't detect the features at runtime). If so, we useREP MOVSB/STOSB
instead ofREP MOVSQ/STOSQ
. This is what Linux does.The final commit adds
memcpy
/memset
tests that are not 8-byte aligned.Performance
See the "ERMSB" tab of this spreadsheet. For Intel chips with the
"ermsb"
feature, we get a 25%-28% performance improvement against the existing implementation, reaching parity with glibs'smemcpy
andmemset
.Note this improvement only seems to help for small-ish (4 KiB) copies, 1 MiB copies show no effect from the change.
Also note that this feature doesn't exist on AMD CPUs, so we don't have to worry abound performance degradation on those chips.