Skip to content
Draft
Show file tree
Hide file tree
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
37 changes: 0 additions & 37 deletions bindings/profilers/wall.cc
Original file line number Diff line number Diff line change
Expand Up @@ -920,28 +920,6 @@ v8::ProfilerId WallProfiler::StartInternal() {
return result.id;
}

NAN_METHOD(WallProfiler::Stop) {
if (info.Length() != 1) {
return Nan::ThrowTypeError("Stop must have one argument.");
}
if (!info[0]->IsBoolean()) {
return Nan::ThrowTypeError("Restart must be a boolean.");
}

bool restart = info[0].As<Boolean>()->Value();

WallProfiler* wallProfiler =
Nan::ObjectWrap::Unwrap<WallProfiler>(info.This());

v8::Local<v8::Value> profile;
auto err = wallProfiler->StopImpl(restart, profile);

if (!err.success) {
return Nan::ThrowTypeError(err.msg.c_str());
}
info.GetReturnValue().Set(profile);
}

// stopAndCollect(restart, callback): callback result
NAN_METHOD(WallProfiler::StopAndCollect) {
if (info.Length() != 2) {
Expand Down Expand Up @@ -1100,20 +1078,6 @@ Result WallProfiler::StopCore(bool restart, ProfileBuilder&& buildProfile) {
return {};
}

Result WallProfiler::StopImpl(bool restart, v8::Local<v8::Value>& profile) {
return StopCore(restart,
[&](const v8::CpuProfile* v8_profile,
bool hasCpuTime,
int64_t nonJSThreadsCpuTime,
ContextsByNode* contextsByNodePtr) {
profile = TranslateTimeProfile(v8_profile,
includeLines_,
contextsByNodePtr,
hasCpuTime,
nonJSThreadsCpuTime);
});
}

Result WallProfiler::StopAndCollectImpl(bool restart,
v8::Local<v8::Function> callback,
v8::Local<v8::Value>& result) {
Expand Down Expand Up @@ -1148,7 +1112,6 @@ NAN_MODULE_INIT(WallProfiler::Init) {
SetContext);

Nan::SetPrototypeMethod(tpl, "start", Start);
Nan::SetPrototypeMethod(tpl, "stop", Stop);
Nan::SetPrototypeMethod(tpl, "stopAndCollect", StopAndCollect);
Nan::SetPrototypeMethod(tpl, "dispose", Dispose);
Nan::SetPrototypeMethod(tpl,
Expand Down
2 changes: 0 additions & 2 deletions bindings/profilers/wall.hh
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ class WallProfiler : public Nan::ObjectWrap {
v8::ProfilerId StartInternal();
template <typename ProfileBuilder>
Result StopCore(bool restart, ProfileBuilder&& buildProfile);
Result StopImpl(bool restart, v8::Local<v8::Value>& profile);
Result StopAndCollectImpl(bool restart,
v8::Local<v8::Function> callback,
v8::Local<v8::Value>& result);
Expand Down Expand Up @@ -189,7 +188,6 @@ class WallProfiler : public Nan::ObjectWrap {

static NAN_METHOD(New);
static NAN_METHOD(Start);
static NAN_METHOD(Stop);
static NAN_METHOD(StopAndCollect);
static NAN_METHOD(V8ProfilerStuckEventLoopDetected);
static NAN_METHOD(Dispose);
Expand Down
1 change: 0 additions & 1 deletion ts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export const time = {
profile: timeProfiler.profile,
start: timeProfiler.start,
stop: timeProfiler.stop,
profileV2: timeProfiler.profileV2,
getContext: timeProfiler.getContext,
setContext: timeProfiler.setContext,
runWithContext: timeProfiler.runWithContext,
Expand Down
45 changes: 5 additions & 40 deletions ts/src/time-profiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type Microseconds = number;
type Milliseconds = number;

type NativeTimeProfiler = InstanceType<typeof TimeProfiler> & {
stopAndCollect?: <T>(
stopAndCollect: <T>(
restart: boolean,
callback: (profile: TimeProfile) => T,
) => T;
Expand All @@ -65,7 +65,7 @@ function handleStopRestart() {
// a loop eating 100% CPU, leading to empty profiles.
// Fully stop and restart the profiler to reset the profile to a valid state.
if (gV8ProfilerStuckEventLoopDetected > 0) {
gProfiler.stop(false);
gProfiler.stopAndCollect(false, () => undefined);
gProfiler.start();
}
}
Expand Down Expand Up @@ -126,13 +126,6 @@ export async function profile(options: TimeProfilerOptions = {}) {
return stop();
}

export async function profileV2(options: TimeProfilerOptions = {}) {
options = {...DEFAULT_OPTIONS, ...options};
start(options);
await setTimeout(options.durationMillis!);
return stopV2();
}

// Temporarily retained for backwards compatibility with older tracer
export function start(options: TimeProfilerOptions = {}) {
options = {...DEFAULT_OPTIONS, ...options};
Expand All @@ -155,39 +148,11 @@ export function start(options: TimeProfilerOptions = {}) {
}
}

export function stop(
restart = false,
generateLabels?: GenerateTimeLabelsFunction,
lowCardinalityLabels?: string[],
) {
if (!gProfiler) {
throw new Error('Wall profiler is not started');
}

const profile = gProfiler.stop(restart);
if (restart) {
handleStopRestart();
} else {
handleStopNoRestart();
}

const serializedProfile = serializeTimeProfile(
profile,
gIntervalMicros,
gSourceMapper,
true,
generateLabels,
lowCardinalityLabels,
);
return serializedProfile;
}

/**
* Same as stop() but uses the lazy callback path: serialization happens inside
* a native callback while the V8 profile is still alive.
* This reduces memory overhead.
* Serializes the profile inside a native callback while the V8 profile is
* still alive. This reduces memory overhead.
*/
export function stopV2(
export function stop(
restart = false,
generateLabels?: GenerateTimeLabelsFunction,
lowCardinalityLabels?: string[],
Expand Down
Loading
Loading