Skip to content

cmd/compile: on amd64, compiler's Zero operation is slower than memclrNoHeapPointers for 1024-2048 bytes #74171

Open
@matloob

Description

@matloob

cc @randall77 @mknyszek

On amd64, it looks like memclrNoHeapPointers performs better than the code that the compiler substitutes it with for a constant length "Zero" SSA operation, for byte sizes between 1024 and 2048 bytes. In that range, memclrNoHeapPointers use avx2 instructions to do the clear, not using the rep stos until the size is at least 2048 bytes, while the compiler will generate a rep stos.

There's a comment in the assembly memclrNoHeapPointers about why that's done:

// If the size is less than 2kb, do not use ERMS as it has a big start-up cost.

I put together a CL 681496 with some benchmarks those sizes and ran it on the C3 perf gomotes. I put the results in the change description.

I think in those cases we sholudn't turn memclrNoHeapPointers call with a constant size into a Zero? Or we could copy what memclrNoHeapPointers does?

Also: I haven't tested this, but there's a branch in the memclrNoHeapPointers that will have different behavior for clears 32M or larger so we may want to investigate that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ImplementationIssues describing a semantics-preserving change to the Go implementation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performancecompiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions