Repository navigation
perf(logging): avoid intermediate timestamp objects - #134979
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 3:53 AM ET / 07:53 UTC. ClawSweeper reviewWhat this changesThe PR collects Merge readinessKeep this maintainer-owned performance PR open for normal review. The introduced loop preserves the formatter’s key-to-value overwrite behavior while removing the pair-array and second projection; no concrete correctness or security defect was found. Priority: P3 Review scores
Verification
How this fits togetherThe shared logging timestamp formatter converts a Date and optional timezone into short, medium, or long local-offset strings. Console output, JSON diagnostics, and file transports consume those strings for operator-visible logs. flowchart LR
A[Date and timezone] --> B[Formatter cache]
B --> C[Intl timestamp parts]
C --> D[Offset and style rendering]
D --> E[Console and file logs]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -4. Total -4 across 1 file. View PR surface stats
Review metrics
Technical reviewBest possible solution: Retain one private part lookup in the canonical formatter and preserve its exact timestamp output for every existing consumer. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR is a behavior-preserving performance optimization rather than a reported failure. The existing formatter tests provide the relevant output contract. Is this the best way to solve the issue? Yes. Keeping the collection and rendering in the one private formatter preserves the current overwrite semantics; emitting strings directly from ordered parts would couple the code to presentation ordering and add complexity. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e8c3fbc05b6b. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
What Problem This Solves
Every formatted log timestamp builds an array of key/value pairs and then a second projected object before constructing the string. Console logging, structured file logging, overflow markers, and local-time CLI displays all pay this repeated work.
Why This Change Was Made
Keep the canonical
formatTimestampowner and collect native Intl parts directly into one private dictionary. Its sole consumer formats the offset and final string. Native Intl supplies a closed set of part names; repeated literal fields retain last-write-wins behavior. This removes the intermediate pair array and private projection without changing formatter options, timezone selection, caches, errors, redaction, or transport lifecycle.Production: +10/-14, net -4 lines. Tests: unchanged. This is an internal, behavior-preserving optimization with no config, schema, protocol, SDK, or documentation contract changes.
User Impact
Less steady-state timestamp-formatting work on logging paths. Timestamp bytes remain unchanged. This does not claim a measurable reduction in model-turn latency, Gateway startup, total logging throughput, or memory usage.
Evidence
The complete source owner was measured with native Node 26.8.1 Intl, not an extracted private helper or a substitute formatter. Four fixed-order runs used before/candidate/candidate/before, retaining 756 measured blocks, 672 warmup blocks, and 84 first calls across 21 workloads. All 21 medians improved in both orders, including all 15 predeclared ordinary decision rows.
There were no slower median pairs, but 15 slower first-call pairs are retained. Forward UTC-short's first call rose from 8.231666 to 8.355208 ms. Only the first row is a cold formatter/cache call; later first calls reuse warmed caches. Forward driver system CPU rose by 358 µs and whole-process system CPU by 487 µs; this is not elapsed-time regression. These are four fixed-order processes, not a randomized statistical population. All first-call, CPU, wall-time, and RSS observations remain in the local campaign evidence, without a startup or memory claim.
The paired correctness run checked 63 exact pairs (60 values and three errors), 21 ordered workload oracles, all styles, timezone precedence, invalid/empty/absent zones, fractional offsets, DST edges, leap midnight, milliseconds, historical/extreme Dates, and error precedence. Direct V8 source inspection confirmed the native part-name/data-record contract. Independent review recomputed every measured median and checked raw journals, hashes, process/group closure, and runtime removal.
Source capture was
61763b06923071f1517c32b05243bddfa808a3d4; timing execution wase92637ab84fc0ca1786276cca141dc9e6cbbf510with three unrelated SDK integration paths dirty. The formatter before/candidate bytes match current integration exactly; these are not relabeled current-head timing runs. Candidate SHA256:ed9a11d6cf2e704dc18706162ccece4bc280bedc464f7041d409e65879b95985. Raw numerical reduction:61c4af6b8dcfee10d31bc8caedc38787b905b7beb505218199f29b95d8e683ce. Fresh independent report:65f15b015d2cb0175ea9311d2d0e36368daa10b124331d9534509e1eb79e7fb0.Canonical validation passed 78 tests before and 78 after across timestamp, console, file transport, capture, and subsystem suites:
The complete changed gate passed (types, lint, formatting, boundaries, and Knip; 265.92 s). Managed Codex review finished scoped-clean at its configured P0 scope. Two unsuccessful review attempts are retained: the first failed the source-integrity preflight, the second encountered an unavailable model. The final supported public-model review passed without changing the candidate or weakening isolation.
Fresh integration at commit
71c263b13f3e040f3ac415758e2f81a564087d71also passed:pnpm build: 179.90 s. Existing dependency bundler warnings did not fail the build.Real-provider turn timings were 1.48/3.57/5.42/7.84 s and are integration observations only. The existing conservative
replayInvalidclassification for generictool_callremained true on read/web turns; no retry, fallback, or compaction recovery was exercised. Live readback SHA256:00ddc78f408aa62fcea4ecc607c7cbaaa8415f10913ec25c132198d2764825fd.Final landing checks: CI run 33483592680 succeeded on exact head
71c263b13f3e040f3ac415758e2f81a564087d71on its first attempt. All 268 check entries completed without failure, cancellation, or timeout. The completed ClawSweeper review found no actionable correctness/security issue and requested ordinary maintainer review; that review is complete. A fresh managed review of the exact commit passed at P0 scope, and an independent live audit confirmed the actual console-prefix count, all transcript/tool evidence, profiles, and cleanup. Its report SHA256 is566266888316f76a2fc115c41e9f0c7d2c961ab367501d7c1e7dbc089044d50c.The native review-artifact validator initially rejected a missing space in its required header. The original artifact and failed attempt were retained, the exact stale operation lock was recovered after verifying no associated tools remained, and the corrected artifact passed validation. No source or test changes were made for that administrative retry.