Skip to content

doc: document PCALIGN assembler directive #64283

@mauri870

Description

@mauri870

The PCALIGN assembler directive is used to align instructions to a given boundary. On critical subroutines and critical innermost loops it can deliver a significant boost in performance.

Currently this pseudo instruction is available for ppc64, loong64, amd64, arm64 and soon for riscv64 once CL 541740 is merged. There is also ongoing work to optimize certain routines in #63678.

I propose adding a new section called "Instruction Alignment" to the https://go.dev/doc/asm that includes the following:

  • Short introduction
  • Supported architectures
  • Usage
    • Tradeoffs
      • some cache space is lost to empty spaces before the aligned code entries
      • can lead to spurious alignment issues if not done correctly
    • Known places where adding it gets perf improvements (hot loops, critical sections)
    • Known boundary sizes that work (e.g 16 bytes on amd64, 32 for AVX2)

I'm happy to write such docs if we agree that it is relevant for the assembler documentation, preferably to be included in Go 1.22.

/cc @rsc @cherrymui @dmitshur

Metadata

Metadata

Assignees

Labels

DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.help wanted

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions