Coder Social home page Coder Social logo

Comments (2)

theanarkh avatar theanarkh commented on June 25, 2024

I think we can not use pprof in both the main thread and the worker thread, but we can use it in worker thread as follows.

const { Worker, isMainThread } = require('worker_threads');
// Can not be loaded in both the main thread and the worker thread
// const profile = require('pprof');

if (isMainThread) {
    new Worker(__filename)
} else {
    const profile = require('pprof');
    // Removing this will cause a crash
    process._stopProfilerIdleNotifier = process._startProfilerIdleNotifier = () => {};
    profile.time.profile({
        durationMillis: 1000,
    });
}

from pprof-nodejs.

dmitryuk avatar dmitryuk commented on June 25, 2024
  1. node_modules/pprof/profiles.cc I have changed NODE_MODULE(google_cloud_profiler, InitAll); to NAN_MODULE_WORKER_ENABLED(google_cloud_profiler, InitAll);
  2. cd node_modules/pprof/build && make
  3. as @theanarkh said before calling profile I've added this line process._stopProfilerIdleNotifier = process._startProfilerIdleNotifier = () => {};

Worker profiling totally working now

from pprof-nodejs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.