Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions bindings/profilers/wall.cc
Original file line number Diff line number Diff line change
Expand Up @@ -774,11 +774,6 @@ WallProfiler::WallProfiler(std::chrono::microseconds samplingPeriod,
jsArray_ = v8::Global<v8::Uint32Array>(isolate, jsArray);
std::fill(fields_, fields_ + kFieldCount, 0);

if (collectAsyncId_ || useCPED_) {
isolate->AddGCPrologueCallback(&GCPrologueCallback, this);
isolate->AddGCEpilogueCallback(&GCEpilogueCallback, this);
}

#if DD_WALL_USE_CPED
if (useCPED_) {
// Used to create CPED proxy objects that will have one internal field to
Expand Down Expand Up @@ -976,6 +971,14 @@ Result WallProfiler::StartImpl() {
return Result{"Cannot start profiler: another profiler is already active."};
}

// Register GC callbacks for async ID and CPED context tracking before
// starting profiling
auto isolate = Isolate::GetCurrent();
if (collectAsyncId_ || useCPED_) {
isolate->AddGCPrologueCallback(&GCPrologueCallback, this);
isolate->AddGCEpilogueCallback(&GCEpilogueCallback, this);
}

profileId_ = StartInternal();

auto collectionMode = withContexts_
Expand All @@ -984,7 +987,6 @@ Result WallProfiler::StartImpl() {
: CollectionMode::kNoCollect);
collectionMode_.store(collectionMode, std::memory_order_relaxed);
started_ = true;
auto isolate = Isolate::GetCurrent();
node::AddEnvironmentCleanupHook(isolate, &WallProfiler::CleanupHook, isolate);
return {};
}
Expand Down