Skip to content

Commit d927abd

Browse files
committed
src: mark sync duration events in TraceEventScope
1 parent deb713e commit d927abd

File tree

4 files changed

+16
-52
lines changed

4 files changed

+16
-52
lines changed

src/api/hooks.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ void EmitBeforeExit(Environment* env) {
3232
}
3333

3434
Maybe<bool> EmitProcessBeforeExit(Environment* env) {
35-
TraceEventScope trace_scope(TRACING_CATEGORY_NODE1(environment),
36-
"BeforeExit", env);
35+
TRACE_EVENT0(TRACING_CATEGORY_NODE1(environment), "BeforeExit");
3736
if (!env->destroy_async_id_list()->empty())
3837
AsyncWrap::DestroyAsyncIdsCallback(env);
3938

src/env.cc

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,7 @@ void Environment::PrintSyncTrace() const {
674674

675675
void Environment::RunCleanup() {
676676
started_cleanup_ = true;
677-
TraceEventScope trace_scope(TRACING_CATEGORY_NODE1(environment),
678-
"RunCleanup", this);
677+
TRACE_EVENT0(TRACING_CATEGORY_NODE1(environment), "RunCleanup");
679678
bindings_.clear();
680679
CleanupHandles();
681680

@@ -717,8 +716,7 @@ void Environment::RunCleanup() {
717716
}
718717

719718
void Environment::RunAtExitCallbacks() {
720-
TraceEventScope trace_scope(TRACING_CATEGORY_NODE1(environment),
721-
"AtExit", this);
719+
TRACE_EVENT0(TRACING_CATEGORY_NODE1(environment), "AtExit");
722720
for (ExitCallback at_exit : at_exit_functions_) {
723721
at_exit.cb_(at_exit.arg_);
724722
}
@@ -744,8 +742,8 @@ void Environment::RunAndClearInterrupts() {
744742
}
745743

746744
void Environment::RunAndClearNativeImmediates(bool only_refed) {
747-
TraceEventScope trace_scope(TRACING_CATEGORY_NODE1(environment),
748-
"RunAndClearNativeImmediates", this);
745+
TRACE_EVENT0(TRACING_CATEGORY_NODE1(environment),
746+
"RunAndClearNativeImmediates");
749747
HandleScope handle_scope(isolate_);
750748
InternalCallbackScope cb_scope(this, Object::New(isolate_), { 0, 0 });
751749

@@ -849,8 +847,7 @@ void Environment::ToggleTimerRef(bool ref) {
849847

850848
void Environment::RunTimers(uv_timer_t* handle) {
851849
Environment* env = Environment::from_timer_handle(handle);
852-
TraceEventScope trace_scope(TRACING_CATEGORY_NODE1(environment),
853-
"RunTimers", env);
850+
TRACE_EVENT0(TRACING_CATEGORY_NODE1(environment), "RunTimers");
854851

855852
if (!env->can_call_into_js())
856853
return;
@@ -911,8 +908,7 @@ void Environment::RunTimers(uv_timer_t* handle) {
911908

912909
void Environment::CheckImmediate(uv_check_t* handle) {
913910
Environment* env = Environment::from_immediate_check_handle(handle);
914-
TraceEventScope trace_scope(TRACING_CATEGORY_NODE1(environment),
915-
"CheckImmediate", env);
911+
TRACE_EVENT0(TRACING_CATEGORY_NODE1(environment), "CheckImmediate");
916912

917913
HandleScope scope(env->isolate());
918914
Context::Scope context_scope(env->context());

src/node_contextify.cc

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -740,11 +740,10 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
740740
if (*TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(
741741
TRACING_CATEGORY_NODE2(vm, script)) != 0) {
742742
Utf8Value fn(isolate, filename);
743-
TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(
744-
TRACING_CATEGORY_NODE2(vm, script),
745-
"ContextifyScript::New",
746-
contextify_script,
747-
"filename", TRACE_STR_COPY(*fn));
743+
TRACE_EVENT_BEGIN1(TRACING_CATEGORY_NODE2(vm, script),
744+
"ContextifyScript::New",
745+
"filename",
746+
TRACE_STR_COPY(*fn));
748747
}
749748

750749
ScriptCompiler::CachedData* cached_data = nullptr;
@@ -794,10 +793,8 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
794793
no_abort_scope.Close();
795794
if (!try_catch.HasTerminated())
796795
try_catch.ReThrow();
797-
TRACE_EVENT_NESTABLE_ASYNC_END0(
798-
TRACING_CATEGORY_NODE2(vm, script),
799-
"ContextifyScript::New",
800-
contextify_script);
796+
TRACE_EVENT_END0(TRACING_CATEGORY_NODE2(vm, script),
797+
"ContextifyScript::New");
801798
return;
802799
}
803800
contextify_script->script_.Reset(isolate, v8_script.ToLocalChecked());
@@ -826,10 +823,7 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
826823
env->cached_data_produced_string(),
827824
Boolean::New(isolate, cached_data_produced)).Check();
828825
}
829-
TRACE_EVENT_NESTABLE_ASYNC_END0(
830-
TRACING_CATEGORY_NODE2(vm, script),
831-
"ContextifyScript::New",
832-
contextify_script);
826+
TRACE_EVENT_END0(TRACING_CATEGORY_NODE2(vm, script), "ContextifyScript::New");
833827
}
834828

835829
bool ContextifyScript::InstanceOf(Environment* env,
@@ -865,8 +859,7 @@ void ContextifyScript::RunInThisContext(
865859
ContextifyScript* wrapped_script;
866860
ASSIGN_OR_RETURN_UNWRAP(&wrapped_script, args.Holder());
867861

868-
TRACE_EVENT_NESTABLE_ASYNC_BEGIN0(
869-
TRACING_CATEGORY_NODE2(vm, script), "RunInThisContext", wrapped_script);
862+
TRACE_EVENT0(TRACING_CATEGORY_NODE2(vm, script), "RunInThisContext");
870863

871864
// TODO(addaleax): Use an options object or otherwise merge this with
872865
// RunInContext().
@@ -892,9 +885,6 @@ void ContextifyScript::RunInThisContext(
892885
break_on_first_line,
893886
nullptr, // microtask_queue
894887
args);
895-
896-
TRACE_EVENT_NESTABLE_ASYNC_END0(
897-
TRACING_CATEGORY_NODE2(vm, script), "RunInThisContext", wrapped_script);
898888
}
899889

900890
void ContextifyScript::RunInContext(const FunctionCallbackInfo<Value>& args) {
@@ -916,8 +906,7 @@ void ContextifyScript::RunInContext(const FunctionCallbackInfo<Value>& args) {
916906
if (context.IsEmpty())
917907
return;
918908

919-
TRACE_EVENT_NESTABLE_ASYNC_BEGIN0(
920-
TRACING_CATEGORY_NODE2(vm, script), "RunInContext", wrapped_script);
909+
TRACE_EVENT0(TRACING_CATEGORY_NODE2(vm, script), "RunInContext");
921910

922911
CHECK(args[1]->IsNumber());
923912
int64_t timeout = args[1]->IntegerValue(env->context()).FromJust();
@@ -940,9 +929,6 @@ void ContextifyScript::RunInContext(const FunctionCallbackInfo<Value>& args) {
940929
break_on_first_line,
941930
contextify_context->microtask_queue(),
942931
args);
943-
944-
TRACE_EVENT_NESTABLE_ASYNC_END0(
945-
TRACING_CATEGORY_NODE2(vm, script), "RunInContext", wrapped_script);
946932
}
947933

948934
bool ContextifyScript::EvalMachine(Environment* env,

src/node_internals.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -382,23 +382,6 @@ namespace heap {
382382
v8::Maybe<void> WriteSnapshot(Environment* env, const char* filename);
383383
}
384384

385-
class TraceEventScope {
386-
public:
387-
TraceEventScope(const char* category,
388-
const char* name,
389-
void* id) : category_(category), name_(name), id_(id) {
390-
TRACE_EVENT_NESTABLE_ASYNC_BEGIN0(category_, name_, id_);
391-
}
392-
~TraceEventScope() {
393-
TRACE_EVENT_NESTABLE_ASYNC_END0(category_, name_, id_);
394-
}
395-
396-
private:
397-
const char* category_;
398-
const char* name_;
399-
void* id_;
400-
};
401-
402385
namespace heap {
403386

404387
void DeleteHeapSnapshot(const v8::HeapSnapshot* snapshot);

0 commit comments

Comments
 (0)