Skip to content

perf: add fused callback info parts#1983

Open
bartlomieju wants to merge 1 commit into
mainfrom
perf-callback-entry
Open

perf: add fused callback info parts#1983
bartlomieju wants to merge 1 commit into
mainfrom
perf-callback-entry

Conversation

@bartlomieju
Copy link
Copy Markdown
Member

Summary

Adds FunctionCallbackInfo::get_parts() as a single callback-entry shim that returns the isolate pointer, return value, callback data, and argument length together.

This lets raw callbacks avoid separate C++ FFI calls for the common callback prologue:

  • CallbackScope::new(info) / isolate lookup
  • ReturnValue::from_function_callback_info(info)
  • FunctionCallbackArguments::from_function_callback_info(info) for callback data and argument length

The new FunctionCallbackInfoParts can be passed directly to CallbackScope, and FunctionCallbackArguments::from_function_callback_info_parts(info, &parts) reuses the already-loaded callback data and length.

Deno usage

The main Deno consumer should be the generated slow op callback prologue in:

  • libs/ops/op2/dispatch_slow.rs: with_scope, with_retval, and with_fn_args currently generate separate callback-info reads for slow ops.
  • libs/ops/op2/dispatch_async.rs: async slow op generation reuses those same helpers and can benefit from the same callback-entry snapshot.

A smaller direct use is:

  • libs/core/ops_metrics.rs: slow_metrics_dispatch currently constructs FunctionCallbackArguments only to read callback data and recover OpCtx; it can use info.get_parts().data directly.

There are also scattered core callbacks, for example libs/core/error.rs and libs/core/runtime/bindings.rs, but the op2 generator is the valuable centralized follow-up because it affects many generated slow callback paths.

Validation

  • cargo fmt
  • cargo check
  • cargo check --benches

I also tried cargo test --test test_api function_callback_info_parts -- --nocapture; it compiled Rust code but failed at the native link step in my local tree because the existing native archive is missing _v8__FunctionCallbackInfo__GetParts plus pre-existing missing symbols _v8__Object__SetLazyDataProperty and _v8__String__Concat.

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