Skip to content

perf: optimize notification and batch processing to reduce allocations#25

Merged
nerdalytics merged 2 commits into
trunkfrom
perf/optimize-notification-batch-allocations
Jan 27, 2026
Merged

perf: optimize notification and batch processing to reduce allocations#25
nerdalytics merged 2 commits into
trunkfrom
perf/optimize-notification-batch-allocations

Conversation

@nerdalytics
Copy link
Copy Markdown
Owner

Summary

  • Replace Array.from(Set) + clear() with Set reference swap in notifySubscribers
  • Replace spread operator array copy with reference swap in executeBatch

Benchmarked Improvements

Metric Improvement
Effect Triggers +13% throughput
Batched Updates +5% throughput
Effect memory -43% per operation
Batch memory -55% per operation
Peak heap under load -50% (113MB → 56MB)

Additional Changes

  • Added micro-benchmarks for isolated hot-path operations to scripts/benchmark.ts
  • Added lens performance benchmarks to scripts/benchmark.ts
  • Created new scripts/memory-benchmark.ts for heap/GC analysis

Test plan

  • All 113 tests pass
  • Biome check passes
  • Benchmarks show consistent improvements across multiple runs

- Replace Array.from(Set) + clear() with Set reference swap in notifySubscribers
- Replace spread operator array copy with reference swap in executeBatch

Benchmarked improvements:
- Effect Triggers: +13% throughput
- Batched Updates: +5% throughput
- Effect memory: -43% per operation
- Batch memory: -55% per operation
- Peak heap under load: -50% (113MB → 56MB)

Also adds micro-benchmarks and lens benchmarks to benchmark.ts,
and new memory-benchmark.ts for heap/GC analysis.
@nerdalytics nerdalytics merged commit 72bac2e into trunk Jan 27, 2026
12 checks passed
@nerdalytics nerdalytics deleted the perf/optimize-notification-batch-allocations branch January 27, 2026 21:37
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