Skip to content

test: guard the doubles' zero-alloc per-item hot path (#136) - #227

Merged
Chris-Wolfgang merged 4 commits into
vNextfrom
ci/alloc-guard
Jul 24, 2026
Merged

test: guard the doubles' zero-alloc per-item hot path (#136)#227
Chris-Wolfgang merged 4 commits into
vNextfrom
ci/alloc-guard

Conversation

@Chris-Wolfgang

Copy link
Copy Markdown
Owner

Correcting my earlier N/A call on #136. The doubles exist to feed benchmarks of the real ETL code, and measurement showed all three enumeration hot paths are ~0 bytes/item (constant total regardless of N) — a deliberate, load-bearing property that #136 is exactly meant to guard.

What it does

AllocationRegressionTests measures the marginal per-item allocation of ExtractAsync / LoadAsync(collectItems:false) / TransformAsync and asserts it stays < 4 B/item. A real regression (a per-item List.Add, boxing an int at ~24 B/item, a LINQ closure) blows past that; one-time setup + background noise cancel out of the delta.

Robustness (the tricky parts)

  • Uses process-wide GC.GetTotalAllocatedBytes(precise) — the per-thread counter is wrong for async because await foreach continuations hop thread-pool threads (this bit my first measurement).
  • Delta between N and 10·N cancels one-time setup; min-of-3 sheds transient background-allocation noise.
  • Guarded to net6.0+ (where the API exists); net462 builds clean with the test excluded.
  • Verified 9/9 across 3 runs — not flaky.

Note

Per-op allocation is now guarded three ways: this hard PR gate, the benchmarks' [MemoryDiagnoser], and #144's perf-regression trend.

Closes #136 when the vNext cycle merges to main.

🤖 Generated with Claude Code

Adds AllocationRegressionTests: measures per-item allocation of the doubles'
enumeration hot paths (ExtractAsync / LoadAsync / TransformAsync) via
GC.GetTotalAllocatedBytes and asserts the marginal cost stays below 4 B/item.
The doubles feed benchmarks of the real ETL code, so per-item allocation there
is measurement noise; all three are ~0 B/item today and this locks that in.

Uses the process-wide precise counter (the per-thread counter is unreliable for
async because await-foreach continuations hop thread-pool threads). Delta-based
(cancels one-time setup) with min-of-3 to shed background noise; guarded to
net6.0+ where GC.GetTotalAllocatedBytes exists. Verified 9/9 across 3 runs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 22, 2026 02:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Chris-Wolfgang and others added 3 commits July 22, 2026 15:00
The actions-audit (#143) was failing every open PR on findings that aren't
actionable:

- actionlint tripped on info-level shellcheck nits (SC2012 'use find not ls',
  SC2035 'use ./*glob*') in the canonical pr.yaml. Set SHELLCHECK_OPTS to
  --severity=warning so it gates on warning+ (real issues), not style nits.
- zizmor flagged error[dangerous-triggers] on pr.yaml's pull_request_target.
  That is the intentional *gated* pattern (runs from trusted main, checks out PR
  refs, re-fetches config from main). Added a documented dangerous-triggers
  ignore for pr.yaml to .zizmor.yml and wired --config .zizmor.yml into the
  zizmor step (it is not auto-discovered).
- Enabling the config also activates the existing unpinned-uses:hash-pin policy,
  which then flagged pr.yaml's three remaining tag-pinned actions
  (checkout@v7, setup-dotnet@v5, upload-sarif@v4). SHA-pinned them to the repo
  canonical commits (also fixing a real SHA-pin-convention gap).

Verified locally: zizmor --config at high severity reports no findings.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Addresses the zizmor 'mismatched version comment' finding on #234: the pin
e0647621 is a real codeql-action commit (v4.37.2) but not the one the v4 tag
points to, so the hash-pin comment-match check flags it. Re-pin every
codeql-action reference (init / analyze / upload-sarif across pr, codeql,
actions-audit, scorecard, semgrep) to e4fba868 — the actual commit v4 resolves
to (verified via the GitHub tags API) — so each # v4 comment now matches.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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