HomeFreeBSD

amd64: make memset less slow with mov

Description

amd64: make memset less slow with mov

rep stos has a high startup time even on modern microarchitectures like
Skylake. Intel optimization manuals discuss how for small sizes it is
beneficial to go for streaming stores. Since those cannot be used without
extra penalty in the kernel I investigated performance impact of just
regular movs.

The patch below implements a very simple scheme: a 32-byte loop followed
by filling in the remainder of at most 31 bytes. It has a 256 breaking
point on which it falls back to rep stos. It provides a significant win
over the current primitive on several machines I tested (both Intel and
AMD). A 64-byte loop did not provide any benefit even for multiple of 64
sizes.

See the review for benchmark data.

Reviewed by: kib
Approved by: re (gjb)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D17398

Details

Provenance
mjgAuthored on
Reviewer
kib
Differential Revision
D17398: amd64: make memset less slow with mov stores
Parents
rS339204: MFC r338999:
Branches
Unknown
Tags
Unknown