Skip to content

perf(slogpretty): precompute group prefix and avoid value allocations#104

Merged
tigerwill90 merged 3 commits intomasterfrom
perf/slogpretty-handler
May 7, 2026
Merged

perf(slogpretty): precompute group prefix and avoid value allocations#104
tigerwill90 merged 3 commits intomasterfrom
perf/slogpretty-handler

Conversation

@tigerwill90
Copy link
Copy Markdown
Collaborator

Some small optimisation on the builtin slog handler to reduce memory allocation.

goos: darwin
goarch: arm64
pkg: github.com/fox-toolkit/fox/internal/slogpretty
cpu: Apple M4 Max
                           │ /tmp/slog_before.txt │         /tmp/slog_after.txt         │
                           │        sec/op        │   sec/op     vs base                │
Handle-16                             234.4n ± 1%   159.8n ± 1%  -31.81% (p=0.000 n=10)
HandleWithGroup-16                    271.6n ± 1%   164.6n ± 1%  -39.40% (p=0.000 n=10)
HandleWithAttrsAndGroup-16            370.7n ± 1%   210.5n ± 1%  -43.22% (p=0.000 n=10)
geomean                               286.8n        176.9n       -38.32%

@tigerwill90 tigerwill90 requested a review from pawndev May 7, 2026 14:01
@tigerwill90 tigerwill90 self-assigned this May 7, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

❌ Patch coverage is 43.54839% with 35 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/slogpretty/handler.go 43.54% 33 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@tigerwill90 tigerwill90 merged commit 0a61749 into master May 7, 2026
3 of 4 checks passed
@tigerwill90 tigerwill90 deleted the perf/slogpretty-handler branch May 7, 2026 14:36
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