Skip to content

Commit

Permalink
perf_hooks: invoke performance_entry_callback via MakeSyncCallback()
Browse files Browse the repository at this point in the history
It's desirable to retain async_contexts active at callsites of
perf_hooks.performance.mark() and alike in the subsequent
PerformanceObserver invocations such that the latter can access e.g.
associated AsyncLocalStorage instances.

In working towards this goal replace the node::MakeCallback(...,
async_context{0, 0}) in PerformanceEntry::doNotify() by the new
node::MakeSyncCallback() introduced specifically for this purpose.

This change will retain the original async_context, if any, in
perf_hook's observersCallback() and thus, for the subsequent doNotify()
on unbuffered PerformanceObservers.

Co-Authored-By: ZauberNerd <zaubernerd@zaubernerd.de>

PR-URL: #36343
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
nicstange authored and targos committed Dec 21, 2020
1 parent 4f3d7bb commit e2ced0d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/node_perf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,10 @@ void PerformanceEntry::Notify(Environment* env,
AliasedUint32Array& observers = env->performance_state()->observers;
if (!env->performance_entry_callback().IsEmpty() &&
type != NODE_PERFORMANCE_ENTRY_TYPE_INVALID && observers[type]) {
node::MakeCallback(env->isolate(),
object.As<Object>(),
env->performance_entry_callback(),
1, &object,
node::async_context{0, 0});
node::MakeSyncCallback(env->isolate(),
object.As<Object>(),
env->performance_entry_callback(),
1, &object);
}
}

Expand Down

0 comments on commit e2ced0d

Please sign in to comment.