Skip to content

fix(parquet/metadata): stop bloom filter asm clobbering the frame pointer - #1379

Merged
zeroshade merged 1 commit into
apache:mainfrom
zeroshade:bloom-asm-vet
Oct 20, 2026
Merged

zeroshade merged 1 commit into
apache:mainfrom
zeroshade:bloom-asm-vet

Conversation

@zeroshade

Copy link
Copy Markdown
Member

Rationale for this change

go vet ./parquet/metadata/ reports 12 findings in the c2goasm-generated bloom filter block kernels (bloom_filter_block_{avx2,sse4}_amd64.s):

  • framepointer (6): each kernel ran LEAQ LCDATAx<>(SB), BP in a frameless function, using BP as the constant-table pointer without saving it. While the kernel runs, any frame-pointer unwinder (Go's execution tracer, profilers, perf/eBPF) walks a garbage frame chain.
  • asmdecl (6): _check_block_{avx2,sse4} return a bool but declared a $0-32 arg frame and stored the result with MOVQ. This is harmless in practice (the extra bytes land in padding) but incorrect.

What changes are included in this PR?

Hand edits to the two .s files. c2goasm is unmaintained, so the header now says the files are hand-edited:

  • _insert_block_* / _insert_bulk_*: load the constant table into R11 (no kernel uses it otherwise) instead of BP. The raw-encoded [rbp] instructions become the equivalent Go mnemonics (VPMULLD, VPBROADCASTD, VMOVDQA; MOVO, PMULLD). go tool objdump shows the same opcodes as before; only the base register changed.
  • _check_block_*: these never read the table, so the dead LEAQ … BP is removed. The frame is now $0-25 and the result is stored with MOVB.

Are these changes tested?

  • go vet ./parquet/metadata/ is now clean (previously 12 findings).
  • go test ./parquet/metadata/ ./parquet/file/ passes on the AVX2 path and with GODEBUG=cpu.avx2=off. Under that setting BenchmarkFilterInsertBulk goes from ~14 to ~22 ns, which confirms the SSE4 kernels are the ones running.
  • Performance is neutral (count=10, Intel Core Ultra 7 155H, geomean -0.26%):
goos: linux
goarch: amd64
pkg: github.com/apache/arrow-go/v18/parquet/metadata
cpu: Intel(R) Core(TM) Ultra 7 155H
                        │ /tmp/asm_old.txt │          /tmp/asm_new.txt          │
                        │      sec/op      │   sec/op     vs base               │
FilterInsert-22                2.565n ± 1%   2.583n ± 0%       ~ (p=0.143 n=10)
FilterCheck-22                 3.922n ± 1%   3.877n ± 0%  -1.15% (p=0.000 n=10)
FilterCheckBulk-22             78.78n ± 2%   77.39n ± 2%  -1.76% (p=0.009 n=10)
FilterInsertBulk-22            14.02n ± 0%   14.22n ± 1%  +1.43% (p=0.000 n=10)
SSE4FilterInsert-22            3.152n ± 1%   3.185n ± 1%  +1.05% (p=0.000 n=10)
SSE4FilterCheck-22             3.902n ± 0%   3.819n ± 2%  -2.15% (p=0.001 n=10)
SSE4FilterCheckBulk-22         78.80n ± 1%   77.64n ± 2%       ~ (p=0.063 n=10)
SSE4FilterInsertBulk-22        21.58n ± 1%   21.88n ± 1%  +1.37% (p=0.000 n=10)
geomean                        11.11n        11.08n       -0.26%

                        │ /tmp/asm_old.txt │          /tmp/asm_new.txt           │
                        │       B/s        │     B/s       vs base               │
FilterInsert-22               11.62Gi ± 1%   11.54Gi ± 0%       ~ (p=0.165 n=10)
FilterCheck-22                7.599Gi ± 1%   7.687Gi ± 0%  +1.16% (p=0.000 n=10)
FilterCheckBulk-22            6.052Gi ± 2%   6.161Gi ± 2%  +1.80% (p=0.009 n=10)
FilterInsertBulk-22           34.01Gi ± 0%   33.54Gi ± 1%  -1.37% (p=0.000 n=10)
SSE4FilterInsert-22           9.454Gi ± 1%   9.356Gi ± 1%  -1.04% (p=0.000 n=10)
SSE4FilterCheck-22            7.637Gi ± 0%   7.805Gi ± 2%  +2.20% (p=0.002 n=10)
SSE4FilterCheckBulk-22        6.051Gi ± 1%   6.142Gi ± 2%       ~ (p=0.063 n=10)
SSE4FilterInsertBulk-22       22.09Gi ± 1%   21.79Gi ± 1%  -1.34% (p=0.000 n=10)
geomean                       10.73Gi        10.76Gi       +0.27%

Are there any user-facing changes?

No.

…nter

go vet reported two classes of issues in the c2goasm-generated bloom
filter block kernels:

- framepointer: every kernel loaded its constant table into BP without
  saving it, so frame-pointer unwinders (execution tracer, profilers,
  perf/eBPF) observed a garbage frame chain while the kernel ran. The
  constants are now addressed through R11, which no kernel otherwise
  uses. The _check_block kernels never read the table, so their dead
  LEAQ is dropped. The raw-encoded [rbp] instructions are replaced with
  the equivalent Go mnemonics (VPMULLD/VPBROADCASTD/VMOVDQA, MOVO/PMULLD).

- asmdecl: _check_block_{avx2,sse4} declared a 32-byte argument frame and
  stored the bool result with MOVQ. They now declare $0-25 and use MOVB.

The files are marked as hand-edited so the changes are re-applied if
they are ever regenerated.
@zeroshade
zeroshade requested review from amoeba, kou and lidavidm October 19, 2026 14:58
@zeroshade
zeroshade merged commit 1eb1d9c into apache:main Oct 20, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants