Skip to content

perf(agera): speed up effect runs by splitting warmup and rerun paths - #178

Merged
dangreen merged 2 commits into
mainfrom
perf/agera-effect-runs
Jul 21, 2026
Merged

perf(agera): speed up effect runs by splitting warmup and rerun paths#178
dangreen merged 2 commits into
mainfrom
perf/agera-effect-runs

Conversation

@dangreen

Copy link
Copy Markdown
Member

What

Split runEffect into two small specializations — warmupEffect (first run: fn(true), no purgeDeps) and runEffect (rerun: fn(), with purgeDeps) — and gate the noMount / notifyMounted lifecycle hooks behind isMountableUsed.

Why

Profiling the effect benchmark against alien-signals showed the single runEffect body was too large for TurboFan to inline into the effect creation and flush paths — the unconditional lifecycle hook calls kept it above the inlining threshold. Ablation experiments confirmed guards alone recover nothing, while per-call-site specialization recovers about half of the gap:

Benchmark before after
effect-agera-alien.js latency avg ~345 ns ~320 ns
throughput 3.14M ops/s 3.27M ops/s

The notifyMounted gate is safe: mountedListeners can only be populated through link()incrementEffectCount(), which already requires isMountableUsed.

The rerun path now calls e.fn() with no arguments (previously an explicit undefined) — indistinguishable for callbacks, the spec assertion updated accordingly.

Size

Duplicated run bodies cost a few bytes after brotli; size limits bumped minimally: agera All publics 2.46→2.47 kB, agera Popular 1.87→1.88 kB, kida/store Popular 2.21→2.23 kB. Signal-only bundles are unaffected (warmupEffect tree-shakes out).

🤖 Generated with Claude Code

dangreen added 2 commits July 22, 2026 00:53
Split `runEffect` into small `warmupEffect` and `runEffect` specializations
so V8 can inline them into the effect creation and flush paths, and gate the
`noMount` and `notifyMounted` lifecycle hooks behind `isMountableUsed`.
Effect benchmark improves from ~345 to ~320 ns/op (~7% faster).
Bump size limits by 10-20 B in `agera`, `kida` and `store` to account for
the duplicated run bodies.
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.94%. Comparing base (31de1b2) to head (6e4d648).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #178      +/-   ##
==========================================
+ Coverage   83.88%   83.94%   +0.05%     
==========================================
  Files         138      138              
  Lines        2973     2983      +10     
  Branches      559      563       +4     
==========================================
+ Hits         2494     2504      +10     
  Misses        340      340              
  Partials      139      139              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dangreen
dangreen requested a review from Copilot July 21, 2026 21:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@dangreen

Copy link
Copy Markdown
Member Author

@codex make review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 6e4d648f8d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dangreen
dangreen merged commit f550458 into main Jul 21, 2026
10 checks passed
@dangreen
dangreen deleted the perf/agera-effect-runs branch July 21, 2026 22:22
This was referenced Jul 21, 2026
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.

2 participants