Closed
Conversation
0cb0dbf to
a8d596a
Compare
Replace escaped tag maps in `meter.Id` with a lower-allocation internal representation and pool spectatord id formatting buffers to cut `NewId` allocations substantially. Made-with: Cursor
Replace per-meter `fmt.Sprintf` calls with shared pooled `strconv.Append*` helpers and add combined benchmark coverage, including a post-GC variant for pool repopulation behavior. Made-with: Cursor
Use explicit tag pairs and shared line-prefix helpers to make the meter internals easier to follow while preserving the large allocation and runtime win versus main. Made-with: Cursor
a8d596a to
584129e
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
meter.Idconstruction overhead by replacing escaped tag maps with a lower-allocation internal representation and pooling spectatord id formatting buffersfmt.Sprintfline construction with pooledstrconv.Append*helpers shared across meter typesmainBenchstat
Against
mainusing the same temporary benchmark harness for both trees (-count=10 -cpu 1) ondarwin/arm64(Apple M3 Pro):Time:
NewId1269.0ns392.5ns-69.07%CombinedBenchmark1366.5ns433.2ns-68.30%Bytes:
NewId B/op920432-53.04%CombinedBenchmark B/op1128608-46.10%Allocations:
NewId allocs93-66.67%CombinedBenchmark allocs124-66.67%Test plan
go test ./spectator/meter ./spectator/writerNewId, combined benchmark coverage, post-GC behavior, and spectatord id formatting during developmentbenchstatcomparison againstmainshowing substantial wins in wall-clock, bytes/op, and allocs/op