Skip to content

perf(ios): add engine native dispatch fast paths#32

Closed
DjDeveloperr wants to merge 9 commits into
mainfrom
perf/v8-native-api-fast-path
Closed

perf(ios): add engine native dispatch fast paths#32
DjDeveloperr wants to merge 9 commits into
mainfrom
perf/v8-native-api-fast-path

Conversation

@DjDeveloperr
Copy link
Copy Markdown
Collaborator

@DjDeveloperr DjDeveloperr commented May 21, 2026

Summary

  • Adds engine-direct native dispatch paths for V8, JavaScriptCore, QuickJS, and Hermes so native API calls can stay on engine-native callbacks and avoid the generic Node-API dispatch path where possible.
  • Keeps gsd-off on the same engine-direct callback/marshalling path for every engine; only generated typed invoker lookup is disabled, so the comparison isolates GSD.
  • Tightens generated/native object dispatch with fast block invoke, backend-specific generated converters, direct fallback for non-generated signatures, lighter class/protocol wrapper normalization, a JSC unwrap cache, and a Hermes receiver cache.
  • Keeps the generic Node-API path available for non-direct/non-target builds while V8/JSC/QuickJS/Hermes builds use their engine-specific direct layers.

Benchmarks

Simulator: iPhone 17 Pro Max. Harness: npm run benchmark:objc-dispatch, 250k base iterations. V8 generic NAPI backend is intentionally not included.

Runtime / mode Total ms Delta vs off Ratio vs off Notes
NAPI iOS V8 GSD on 339.38 -101.34 1.30x faster fastest run
NAPI iOS V8 GSD off 440.71 baseline 1.00x engine-direct path, GSD disabled
NAPI iOS QuickJS GSD on 459.35 -52.42 1.11x faster faster than legacy V8 AOT
NAPI iOS QuickJS GSD off 511.77 baseline 1.00x engine-direct path, GSD disabled
NAPI iOS JSC GSD on 502.32 -52.86 1.11x faster faster than legacy V8 AOT
NAPI iOS JSC GSD off 555.18 baseline 1.00x engine-direct path, GSD disabled
Legacy iOS V8 AOT on 812.04 -45.67 1.06x faster exact same harness
Legacy iOS V8 AOT off 857.71 baseline 1.00x exact same harness
NAPI iOS Hermes GSD on 1368.02 -562.49 1.41x faster GSD helps, engine boundary still dominates
NAPI iOS Hermes GSD off 1930.51 baseline 1.00x engine-direct path, GSD disabled

Result files used for the final combined report:

  • build/benchmarks/objc-dispatch/results-2026-05-22T03-50-08-551Z.json Hermes
  • build/benchmarks/objc-dispatch/results-2026-05-22T03-51-20-831Z.json JSC
  • build/benchmarks/objc-dispatch/results-2026-05-22T03-52-29-898Z.json QuickJS
  • build/benchmarks/objc-dispatch/results-2026-05-22T03-54-25-288Z.json V8
  • build/benchmarks/objc-dispatch/results-2026-05-22T03-54-53-235Z.json legacy iOS V8 AOT on/off
  • build/benchmarks/objc-dispatch/results-combined-final-2026-05-22.json combined harness report

Notes

  • GSD on/off is now visibly separated across every direct backend: V8 +30%, QuickJS/JSC +11%, Hermes +41%.
  • V8 direct + GSD is now well ahead of legacy iOS V8 AOT on/off in this harness.
  • QuickJS and JSC direct + GSD are also ahead of legacy iOS V8 AOT on/off.
  • Hermes improves substantially with GSD but still has a much higher floor than V8/QuickJS/JSC; the remaining cost appears to be Hermes host-function/wrapper entry overhead rather than libffi/generated-signature dispatch.

Verification

  • git diff --check -- <touched runtime files> exits 0.
  • Clean detached worktree with only this final patch applied: npm run test:ios passes with tests=705, failures=0, errors=0, skipped=14 on iPhone 17 Pro Max simulator.

@DjDeveloperr DjDeveloperr changed the title perf(ios): add v8 native API dispatch fast path perf(ios): add engine native dispatch fast paths May 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.

1 participant