Skip to content

chore: remove test counters and switches from production paths - #513

Merged
guitarrapc merged 2 commits into
mainfrom
chore/remove-test-counters
Nov 28, 2026
Merged

guitarrapc merged 2 commits into
mainfrom
chore/remove-test-counters

Conversation

@guitarrapc

Copy link
Copy Markdown
Owner

Summary

Removes counters and switches that existed only for tests from production code. Tests now check behavior from the outside.

Intent

Several [ThreadStatic] counters and one switch lived in src only so tests could see which path ran. Each counter cost an increment on hot paths, and each one added a production seam no caller uses. The tests now assert the output, or watch the array pool's events, instead.

Changes

  • Drop the planning counters in QRCodeGenerator and StructuredAppendPlanner (ScalarWalks, LaneBatches and the generator's counters). Tests that only checked which path ran are removed or now assert the output. For example, StructuredAppendWriterPlanTest requires the same modules whether the chunks are planned together or one by one.
  • Drop the Micro QR grid evidence switch. The tests state the measured premise instead.
  • Replace QRImageDecoder.ModuleBuffersPeak with ArrayPoolRentWatch in the test project. It is an EventListener on the array pool's events that reports the most arrays of one size this thread had out at once. The Standard QR one-symbol tests still require one array of a size at a time, for reads and for rejected images.
  • Correct the comments that said a second rent of the same size allocates. The pool's shared stacks are empty only while other threads hold the arrays they had, and only then does a rent allocate.
  • The spec records why the Standard QR several-symbol call keeps its candidate list and image buffer apart.
    • Renting both as one array was tried and undone in this branch. One array rounds up to the next power of two: 2 MiB on a 1000 × 1000 image, against 1 MiB and 64 KiB apart.
    • Renting apart costs little. Four rents of 65,536 B took 91 ns a call on one thread and 238 ns on 32, against 8.5 ns and 19 ns for one rent of 262,144 B. Neither shape allocated from the pool (.NET 10, 32 threads).

Before / After

Before After
Test-only [ThreadStatic] counters in src Planner, generator and module buffer counters None
Micro QR grid evidence switch In src Removed
Module buffer check Counter incremented on every rent and return Array pool events, in the test project only

🤖 Generated with Claude Code

guitarrapc and others added 2 commits November 28, 2026 15:13
- Drop the [ThreadStatic] planning counters from QRCodeGenerator and StructuredAppendPlanner. Tests that only checked a path was taken are removed or now assert the output.
- Drop the Micro QR grid evidence switch. Tests state the measured premise with its date instead.
- Replace the module buffer peak counter with ArrayPoolRentWatch, an EventListener on the array pool's events that counts the most arrays of one size out at once.
- Standard QR DecodeSymbols rents its candidate list and image buffer once per call as one array, longer than any module workspace, so no two arrays of one size are out at once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Standard QR DecodeSymbols rents its candidate list and image buffer apart again. One array rounded up to the next power of two, so a 1000 x 1000 image held 2 MiB instead of 1 MiB and 64 KiB, and a second same-size rent measured tens of nanoseconds with no pool allocation on 32 threads.
- Comments say the shared stacks are empty only while other threads hold the arrays they had, instead of saying the rent allocates.
- The spec records the measurement and why the buffers stay apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@guitarrapc
guitarrapc merged commit 51c3e0a into main Nov 28, 2026
28 checks passed
@guitarrapc
guitarrapc deleted the chore/remove-test-counters branch November 28, 2026 10:33
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