sdk/log: allow unused loggers to be garbage collected #9638
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.44) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.44 · 263 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.334
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #9638"
general
weight: 0.35
pellared
Store loggers in the LoggerProvider cache in
weakpointers, allowing them to be garbage collected after the caller stops using them. This leaves us with the empty map entries, which we sweep on cache misses, roughly every time the logger count doubles.Added a test which puts loggers in its own weak pointers and checks if GC sweeps drop them.
The additional memory cost per logger is 16B. The CPU cost is roughly 142 ns per new logger and 8.7 ns per cache hit. The amortized sweep cost is an additional ~100 ns with a lot of logger churn. I needed to modify the existing benchmark to use fixed batches, so its output isn't dependent on particulars of Go's map implementation. See the raw benchstat output below:
Resolves #6352