Skip to content

v8: GetCpuProfiler is going away soon #18039

Description

@targos

A new API was introduced in v8/v8@120b753.
The current API is deprecated in V8 6.4: v8/v8@8c5e2d7

Our usage:

node/src/env.cc

Lines 150 to 160 in 6aac05b

void Environment::StartProfilerIdleNotifier() {
uv_prepare_start(&idle_prepare_handle_, [](uv_prepare_t* handle) {
Environment* env = ContainerOf(&Environment::idle_prepare_handle_, handle);
env->isolate()->GetCpuProfiler()->SetIdle(true);
});
uv_check_start(&idle_check_handle_, [](uv_check_t* handle) {
Environment* env = ContainerOf(&Environment::idle_check_handle_, handle);
env->isolate()->GetCpuProfiler()->SetIdle(false);
});
}

Activity

  1. added
    c++Issues and PRs that require attention from people who are familiar with C++.
    v8 engineIssues and PRs related to the V8 dependency.
    on Jan 8, 2018
  2. targos commented on Jan 8, 2018

    @targos
    MemberAuthor

    /cc @nodejs/v8

  3. ofrobots commented on Jan 8, 2018

    @ofrobots
    Contributor

    Hmm.. with the new API it seems that it should be possible to create multiple instances of the CPU profiler. Previously it was a singleton. This means that user-space modules could all use different profilers, and the idle notification above would stop working. Does this mean that Node needs to instantiate a singleton profiler and the ecosystem needs to change to start using that?

    /cc @hashseed @fhinkel is my understanding correct?

  4. fhinkel commented on Jan 9, 2018

    @fhinkel
    Contributor

    Yes, with the old API, every isolate has one profiler assigned, created during Isolate::Init. With the new API, embedders can create multiple profilers.

    Node could instantiate a singleton and provide that - or maybe we should invert dependencies: Addons can use as many profilers as they want, but they are responsible for registering for the IdleNotifier.

  5. bnoordhuis commented on Feb 2, 2018

    @bnoordhuis
    Member

    Node could instantiate a singleton and provide that - or maybe we should invert dependencies: Addons can use as many profilers as they want, but they are responsible for registering for the IdleNotifier.

    I don't think we have to worry about that. We only use it to call CpuProfiler::SetIdle() and that's not even a proper CpuProfiler method (it updates v8::internal::Isolate::current_vm_state_.) Add-ons can create their own CpuProfiler instance.

    I've opened #18534 with a simple fix.

  6. bnoordhuis commented on Feb 3, 2018

    @bnoordhuis
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++Issues and PRs that require attention from people who are familiar with C++.v8 engineIssues and PRs related to the V8 dependency.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions