Skip to content

perf: hoist cap==0 check off full emplace - #2

Merged
equationzhao merged 1 commit into
mainfrom
equationzhao/hoist-cap0-off-full-emplace
Aug 13, 2026
Merged

perf: hoist cap==0 check off full emplace#2
equationzhao merged 1 commit into
mainfrom
equationzhao/hoist-cap0-off-full-emplace

Conversation

@equationzhao

@equationzhao equationzhao commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • Full emplace_back / emplace_front no longer call EQZ_COLD ensure_writable() on every overwrite. The helper runs only when capacity()==0 (still throws std::length_error).

  • Closes the GCC 13 hot-path hole from Investigate GCC 13 bench gap versus Clang #1 without inlining throw into emplace_*.

  • DESIGN.md matches the new shape and records the discarded R2/R3 variants (drop EQZ_COLD / always-inline check + cold throw helper), which sped up overwrite but sent GCC copy/full to ~11 µs.

  • Adds docs/BENCH.md: keep-or-revert, local vs remote release-bench, and how to read GCC/Clang ratios. Issues and PR bodies are English (CONTRIBUTING.md, CODING_STANDARDS.md).

  • Closes Investigate GCC 13 bench gap versus Clang #1

Test plan

  • Existing unit tests: capacity()==0 push_back still throws length_error
  • Experiment branch bench/r1-hoist-cap0 full CI matrix green
  • Five-platform release-bench vs main 56fb5af:
    • GCC 13 x64: slide/u64/4097 5.02 ns → 0.61 ns; geomean 1.29 → 1.10 (0.90 if try_push/full timer-floor 469× is excluded)
    • macOS Clang geomean 0.567 → 0.569
    • Do not land R2/R3: same hot-path win, GCC copy/full 814 ns → ~11 µs
    • try_push/full on GCC going 0.01 ns → 0.70 ns (Boost still 0.00) poisons geomean; it is not an overwrite regression

GCC 13 was calling EQZ_COLD ensure_writable on every overwrite. Keep the
throw out of line; only invoke it when capacity is 0.

Co-authored-by: Cursor <cursoragent@cursor.com>
@equationzhao equationzhao self-assigned this Aug 13, 2026
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@equationzhao
equationzhao merged commit a6fbd5e into main Aug 13, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate GCC 13 bench gap versus Clang

1 participant