perf(evlog): eliminate object allocations on hot paths#181
Merged
Conversation
Replace `deepDefaults()` with in-place `mergeInto()` across all logger methods (`set`, `error`, `info`, `warn`), remove double context spreads in `emit()`, and add an `ownsEvent` fast path in `emitWideEvent()` that stamps metadata directly instead of spreading `globalEnv + event`. Also: in-place `addLog()` push, cached RegExp in `matchesPattern()`.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Thank you for following the naming conventions! 🙏 |
commit: |
Contributor
Benchmark reportPerformance
Summary
Warning Performance regressions detected (>10% slower). Review before merging. Bundle size
|
Instead of comparing PR benchmarks against a stored baseline from a previous run (different runner, different load), the compare job now builds and benchmarks main first, then the PR branch, on the same machine. This eliminates cross-runner variance that caused false regression reports.
Drop the custom A/B compare job (cross-runner noise made it unreliable) and add CodSpeed for PR benchmark regression detection. CodSpeed uses instrumentation instead of wall-clock timing, eliminating CI noise. - Add `@codspeed/vitest-plugin` to vitest config - Create `.github/workflows/codspeed.yml` for PR + push benchmarks - Simplify `bench.yml` to only update-baseline (RESULTS.md tracking)
Congrats! CodSpeed is installed 🎉
You will start to see performance impacts in the reports once the benchmarks are run from your default branch.
|
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
deepDefaults()with in-placemergeInto()— eliminates 1-N allocations perset(),error(),info(),warn()callemit()— mutate context directly (terminal operation), pass reference toemitWideEvent()ownsEventfast path inemitWideEvent()— stamptimestamp,level, andglobalEnvfields directly instead of{ ...globalEnv, ...event }spreadaddLog()— push to existing array instead of array spread + context spreadmatchesPattern()— avoid recompiling glob patterns on everyshouldKeep()callBenchmark results (vs baseline)
Core benchmarks:
log.set()deep nestedlog.set()multiple sequentiallog.emit()with contextComparison vs alternatives (evlog now wins 5/7):
Bundle size
Total gzip decreased from 38.61 kB → 37.88 kB (-730 B).