runtime: memmove should use the REP MOVSB
instruction on newer Intel microarchitectures.
#66958
Labels
arch-amd64
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
Go version
go version go1.22.2 linux/amd64
Output of
go env
in your module/workspace:What did you do?
Copy data larger than 2KB.
What did you see happen?
On newer Intel CPUs which support ERMS,
copy
uses AVX to copy the data instead of using theREP MOVSB
instruction.What did you expect to see?
The current memmove implementation uses REP MOVSB to copy data larger than 2KB when the useAVXmemmove global variable is false and the CPU supports the ERMS feature.
According to the runtime/cpuflags_amd64.go code:
As you can see this feature is currently only enabled on CPUs in the Sandy Bridge (Client), Sandy Bridge (Server), Ivy Bridge (Client), and Ivy Bridge (Server) microarchitectures.
For modern Intel CPU microarchitectures that support the ERMS feature, such as Ice Lake (Server), Sapphire Rapids , REP MOVSB achieves better performance than the AVX-based copies currently implemented in memmove.
(You can get the CPUID table here: https://en.wikichip.org/wiki/intel/cpuid)
The text was updated successfully, but these errors were encountered: