perf(producer): gate per-frame debug meta via optional isLevelEnabled#383
Open
vanceingalls wants to merge 1 commit intovance/hdr-benchmark-harnessfrom
Open
perf(producer): gate per-frame debug meta via optional isLevelEnabled#383vanceingalls wants to merge 1 commit intovance/hdr-benchmark-harnessfrom
vanceingalls wants to merge 1 commit intovance/hdr-benchmark-harnessfrom
Conversation
This was referenced Apr 21, 2026
Collaborator
Author
This was referenced Apr 21, 2026
Open
perf(producer): hdr benchmark harness — --tags filter, peak heap/RSS tracking, bench:hdr script
#382
Open
1d3a961 to
cadda3c
Compare
38cae8b to
723c98b
Compare
cadda3c to
aa41490
Compare
723c98b to
2f5ecdc
Compare
2f5ecdc to
57abd3a
Compare
aa41490 to
9b942fb
Compare
57abd3a to
c0d1d4e
Compare
3e3fa0c to
6d2f104
Compare
a4873ca to
35fee67
Compare
8d9641b to
3fcaa60
Compare
35fee67 to
2159cf0
Compare
3fcaa60 to
e675bd9
Compare
2159cf0 to
d746856
Compare
e675bd9 to
f73328c
Compare
2217a93 to
8610f7e
Compare
f73328c to
55a41a8
Compare
8610f7e to
0d2175b
Compare
55a41a8 to
349f0f6
Compare
0d2175b to
cd40e4b
Compare
349f0f6 to
cd65ab0
Compare
cd40e4b to
5594d94
Compare
cd65ab0 to
5409b1a
Compare
5594d94 to
4ea0021
Compare
5409b1a to
c6a8280
Compare
4ea0021 to
c95ffe5
Compare
2ce89a5 to
b8d319d
Compare
c95ffe5 to
6cf7b33
Compare
b8d319d to
d222b31
Compare
23df022 to
53e0f64
Compare
d222b31 to
e72f484
Compare
53e0f64 to
9d3aa62
Compare
e72f484 to
5338173
Compare
9d3aa62 to
3500be4
Compare
5338173 to
b99006d
Compare
3500be4 to
f572ea8
Compare
Add an optional `isLevelEnabled(level)` method to `ProducerLogger` so call
sites can short-circuit expensive metadata construction in hot loops
before handing it to a debug logger. Implement it in
`createConsoleLogger` and gate the per-frame HDR composite snapshot in
`renderOrchestrator` (every 30 frames) on
`log.isLevelEnabled?.("debug") ?? true`, so production runs at
`level="info"` skip the `Array.find` + `toFixed` + struct allocation
entirely while custom loggers without the new method keep their
existing behavior.
Also add unit coverage in `packages/producer/src/logger.test.ts` (17
tests) for level filtering, meta formatting, the new `isLevelEnabled`
path including a hot-loop call-site simulation that asserts zero
builder invocations at info level, and the `?? true` fallback for
loggers that omit the method.
Update `docs/packages/producer.mdx` with a new "Logging" section
documenting `ProducerLogger`, `createConsoleLogger`, `defaultLogger`,
and the `isLevelEnabled` gating pattern.
This closes 8C in `plans/hdr-followups.md`. 8D (gating the
`countNonZeroAlpha` / `countNonZeroRgb48` diagnostic counters) was
verified during the same work to already be guarded by
`shouldLog = debugDumpEnabled && debugFrameIndex >= 0`, where
`debugDumpEnabled` is itself driven by `KEEP_TEMP=1`, so the pixel
iteration is fully skipped on production runs and no code change was
needed.
Made-with: Cursor
b99006d to
644607f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Add an optional
isLevelEnabled(level)method toProducerLoggerand use it to short-circuit per-frame HDR composite metadata construction inrenderOrchestratorwhen the log level is above debug.Closes Chunks 8C and 8D from
plans/hdr-followups.md.Why
Chunk 8Cofplans/hdr-followups.md. The per-frame HDR composite snapshot (every 30 frames) was building anArray.find+toFixed+ struct allocation unconditionally and handing it to a debug logger that immediately discarded it atlevel="info". On long renders, this is allocation pressure and CPU time wasted on log meta nobody reads.Chunk 8Dwas investigated in the same pass and found to already be guarded — see below.What changed
isLevelEnabled(level: ProducerLogLevel): booleanonProducerLogger.createConsoleLoggerimplements it.renderOrchestrator.tsper-frame HDR composite snapshot is now gated oni % 30 === 0 && (log.isLevelEnabled?.("debug") ?? true)— production runs atlevel="info"skip the meta-object construction entirely; custom loggers without the new method keep their existing behavior thanks to the?? truefallback.packages/producer/src/logger.test.ts(17 tests) covering level filtering, meta formatting, theisLevelEnabledpath, a hot-loop call-site simulation that asserts zero builder invocations at info level, and the?? truefallback for loggers that omit the method.docs/packages/producer.mdxgains a new "Logging" section documentingProducerLogger,createConsoleLogger,defaultLogger, and theisLevelEnabledgating pattern.8D resolution (no code change).
countNonZeroAlpha/countNonZeroRgb48calls live behindshouldLog = debugDumpEnabled && debugFrameIndex >= 0, wheredebugDumpEnabledis itself driven byKEEP_TEMP=1. The pixel iteration is fully skipped on production runs already, so 8D needed no fix — verified during the 8C work.Test plan
bun testin producer — 17/17 logger tests pass; existing service tests unchanged.level="info".?? truefallback preserves prior behavior for custom logger implementations that don't define the method.Stack
Chunks 8C + 8D of
plans/hdr-followups.md. Sits on top of the benchmark harness PR (Chunk 8A) so the optimization is measurable.