Skip to content

Prepare compact hash-primary operands once per expression - #1056

Merged
helly25 merged 14 commits into
mainfrom
perf/prepare-hash-operands
Nov 2, 2026
Merged

helly25 merged 14 commits into
mainfrom
perf/prepare-hash-operands

Conversation

@helly25

@helly25 helly25 commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Hash primaries now decode explicit algorithm and encoding syntax once, reducing repeated work in CPU-bound hashing and verification. Expected templates, live defaults and conditional reads preserve their existing behavior.

AG;DR

Based on main after #1055 merged. Synchronization head 4e77548bebf05152bb55b64dadd8e7ec9da8f539 contains main 00d4f84df01e00f1ce2d7c83576ac38b2eb2fb7b; the complete implementation tree is unchanged from measured head 327ea789f840a42712cb92ddf29db52bd812e7e3. Normal synchronization commit/push hooks pass. Required CI is running on the synchronized head. The earlier coverage job failed during LLVM extraction with runner disk exhaustion, before tests; the new synchronized run replaces that failed context.

Implementation:

  • Add a compact prepared hash record using an index into the existing AlgorithmNames registry, encoding/default-use/validity bits, and the existing unique expected-template owner. No second algorithm list or public hash API is introduced.
  • Assert that the record fits the existing 24-byte operand alternative; unrelated operand storage does not grow. Bare hash acquires a prepared pool record/capacity, so preparation is not allocation-free.
  • Register expression-aware preparation in the existing constexpr dispatch. Argument-only families use one preparation adapter and preserve their previous missing-argument guard. A boolean uses existing dispatch-record padding rather than adding another callback pointer.
  • Resolve only requested defaults from the reached direct context; no borrowed source/default view is cached across calls. Expected-field rendering still precedes conditional hash resolution/reads, and verification bookkeeping remains unchanged.
  • Preserve direct-tree reference callbacks. Add no per-file lock, worker, clock, shared ownership, flag, mutation route or exception mechanism. Hash/verification coordinator admission is unchanged.

Evidence and tradeoffs:

  • docs/benchmarks/prepared-hash-operands-20261102.md and compressed lossless data retain source/binary/fixture identities, compiler versions and hashes, build configuration, actual CLI link actions/parameter contents, scripts, logs, private pilot and final/confirmation samples.
  • Per host: 56 native cases x three sessions; 36 in-memory whole-engine cases, 16 hot kernels and eight preparation-only cases x three sessions; confirmation with an identical baseline adds eight native cases x five sessions and 12 memory cases x three sessions. Discarded warmups and fastest seven of nine remain separate contracts.
  • Explicit hashing/equality improves roughly 6-9% in in-memory confirmation on both hosts. Native commands stay near baseline because file I/O dominates. Defaults improve less; no universal speedup is claimed.
  • Preserve cold costs: a one-primary hash preparation adds roughly 50-70 ns, and Linux name preparation adds about 27 ns. The report shows absolute values, percentages, duplicate-baseline controls and unrelated name/diff results; their improvements are not credited to hash parsing.
  • Unstripped CLI: Linux +27,176 bytes; macOS +7,584 bytes. Existing digest/output copies and field-hash rendering remain O22 work; wider EP03/EP07 qualification is still open.

Validation:

  • Complete extension-enabled release suites pass 322/322 on macOS and Linux, with required Linux FUSE mounts.
  • Six focused ASan suites pass on each host; six Linux TSan suites pass.
  • Dedicated tests cover every registered algorithm and both encodings, reused/moved plans with changing defaults, invalid/empty direct defaults, malformed specs with content-dependent expected fields, missing arguments, empty/binary input, failed reads and skipped actions.
  • All four modified translation units pass scoped local clang-tidy after addressing const/optional/test-helper findings. Normal enforcing commit/push hooks pass before PR creation; readiness still requires current pushed-head CI.

Reconcile O15b into the canonical performance analysis, TODO, expression design/qualification audit, changelog and release-site mapping. Keep field-hash binding and broader template-family qualification explicitly open.

Base automatically changed from perf/prepare-diff-configuration to main November 2, 2026 14:57
@helly25
helly25 merged commit fc2cd31 into main Nov 2, 2026
32 checks passed
@helly25
helly25 deleted the perf/prepare-hash-operands branch November 2, 2026 20:24
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.

1 participant