Socket
Socket
Sign inDemoInstall

@datadog/pprof

Package Overview
Dependencies
6
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.0 to 6.0.0-pre-2dd149e

4

out/src/heap-profiler.js

@@ -21,3 +21,3 @@ "use strict";

const profile_serializer_1 = require("./profile-serializer");
const node_worker_threads_1 = require("node:worker_threads");
const worker_threads_1 = require("worker_threads");
let enabled = false;

@@ -137,5 +137,5 @@ let heapIntervalBytes = 0;

}
(0, heap_profiler_bindings_1.monitorOutOfMemory)(heapLimitExtensionSize, maxHeapLimitExtensionCount, dumpHeapProfileOnSdterr, exportCommand || [], newCallback, typeof callbackMode !== 'undefined' ? callbackMode : exports.CallbackMode.Async, node_worker_threads_1.isMainThread);
(0, heap_profiler_bindings_1.monitorOutOfMemory)(heapLimitExtensionSize, maxHeapLimitExtensionCount, dumpHeapProfileOnSdterr, exportCommand || [], newCallback, typeof callbackMode !== 'undefined' ? callbackMode : exports.CallbackMode.Async, worker_threads_1.isMainThread);
}
exports.monitorOutOfMemory = monitorOutOfMemory;
//# sourceMappingURL=heap-profiler.js.map

@@ -19,2 +19,3 @@ import * as heapProfiler from './heap-profiler';

kSampleCount: any;
GARBAGE_COLLECTION_FUNCTION_NAME: string;
NON_JS_THREADS_FUNCTION_NAME: string;

@@ -21,0 +22,0 @@ };

@@ -19,3 +19,4 @@ /**

import { AllocationProfileNode, GenerateAllocationLabelsFunction, GenerateTimeLabelsFunction, TimeProfile } from './v8-types';
export declare const NON_JS_THREADS_FUNCTION_NAME = "(non-JS threads)";
export declare const NON_JS_THREADS_FUNCTION_NAME = "Non JS threads activity";
export declare const GARBAGE_COLLECTION_FUNCTION_NAME = "Garbage Collection";
/**

@@ -22,0 +23,0 @@ * Converts v8 time profile into into a profile proto.

@@ -18,5 +18,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.serializeHeapProfile = exports.serializeTimeProfile = exports.NON_JS_THREADS_FUNCTION_NAME = void 0;
exports.serializeHeapProfile = exports.serializeTimeProfile = exports.GARBAGE_COLLECTION_FUNCTION_NAME = exports.NON_JS_THREADS_FUNCTION_NAME = void 0;
const pprof_format_1 = require("pprof-format");
exports.NON_JS_THREADS_FUNCTION_NAME = '(non-JS threads)';
exports.NON_JS_THREADS_FUNCTION_NAME = 'Non JS threads activity';
exports.GARBAGE_COLLECTION_FUNCTION_NAME = 'Garbage Collection';
function isGeneratedLocation(location) {

@@ -52,7 +53,9 @@ return (location.column !== undefined &&

const node = entry.node;
// mjs files have a `file://` prefix in the scriptName -> remove it
if (node.scriptName.startsWith('file://')) {
node.scriptName = node.scriptName.slice(7);
}
if (ignoreSamplesPath && node.scriptName.indexOf(ignoreSamplesPath) > -1) {
continue;
}
if (node.name === '(idle)' || node.name === '(program)')
continue;
const stack = entry.stack;

@@ -191,2 +194,67 @@ const location = getLocation(node, sourceMapper);

}
/** Perform some modifications on time profile:
* - Add non-JS thread activity node if available
* - Remove `(idle)` and `(program)` nodes
* - Convert `(garbage collector)` node to `Garbage Collection`
* - Put `non-JS thread activity` node and `Garbage Collection` under a top level `Node.js` node
* This function does not change the input profile.
*/
function updateTimeProfile(prof) {
const newTopLevelChildren = [];
let runtimeNode;
function getRuntimeNode() {
if (!runtimeNode) {
runtimeNode = {
name: 'Node.js',
scriptName: '',
scriptId: 0,
lineNumber: 0,
columnNumber: 0,
children: [],
hitCount: 0,
};
newTopLevelChildren.push(runtimeNode);
}
return runtimeNode;
}
for (const child of prof.topDownRoot.children) {
if (child.name === '(idle)' || child.name === '(program)') {
continue;
}
if (child.name === '(garbage collector)') {
// Create a new node to avoid modifying the input one
const newChild = {
...child,
name: exports.GARBAGE_COLLECTION_FUNCTION_NAME,
};
getRuntimeNode().children.push(newChild);
}
else {
newTopLevelChildren.push(child);
}
}
if (prof.hasCpuTime && prof.nonJSThreadsCpuTime) {
const node = {
name: exports.NON_JS_THREADS_FUNCTION_NAME,
scriptName: '',
scriptId: 0,
lineNumber: 0,
columnNumber: 0,
children: [],
hitCount: 0,
contexts: [
{
context: {},
timestamp: BigInt(0),
cpuTime: prof.nonJSThreadsCpuTime,
},
],
};
getRuntimeNode().children.push(node);
}
return {
...prof,
topDownRoot: { ...prof.topDownRoot, children: newTopLevelChildren },
};
}
/**

@@ -221,3 +289,6 @@ * Converts v8 time profile into into a profile proto.

if (Object.keys(labels).length > 0) {
const values = [1, intervalNanos];
// Only assign wall time if there are hits, some special nodes such as `(Non-JS threads)`
// have zero hit count (since they do not count as wall time) and should not be assigned any
// wall time.
const values = unlabelledHits > 0 ? [1, intervalNanos] : [0, 0];
if (prof.hasCpuTime) {

@@ -240,3 +311,5 @@ values.push(context.cpuTime);

const labels = generateLabels ? generateLabels({ node: entry.node }) : {};
const values = [unlabelledHits, unlabelledHits * intervalNanos];
const values = unlabelledHits > 0
? [unlabelledHits, unlabelledHits * intervalNanos]
: [0, 0];
if (prof.hasCpuTime) {

@@ -268,22 +341,4 @@ values.push(unlabelledCpuTime);

};
if (prof.nonJSThreadsCpuTime) {
const node = {
name: exports.NON_JS_THREADS_FUNCTION_NAME,
scriptName: '',
scriptId: 0,
lineNumber: 0,
columnNumber: 0,
children: [],
hitCount: 0,
contexts: [
{
context: {},
timestamp: BigInt(0),
cpuTime: prof.nonJSThreadsCpuTime,
},
],
};
prof.topDownRoot.children.push(node);
}
serialize(profile, prof.topDownRoot, appendTimeEntryToSamples, stringTable, undefined, sourceMapper);
const updatedProf = updateTimeProfile(prof);
serialize(profile, updatedProf.topDownRoot, appendTimeEntryToSamples, stringTable, undefined, sourceMapper);
return new pprof_format_1.Profile(profile);

@@ -290,0 +345,0 @@ }

@@ -316,3 +316,3 @@ "use strict";

const mapFiles = [];
for await (const entry of walk(baseDir, filename => filename.endsWith('.js.map'), (root, dirname) => root !== '/proc' && dirname !== '.git' && dirname !== 'node_modules')) {
for await (const entry of walk(baseDir, filename => /\.[cm]?js\.map$/.test(filename), (root, dirname) => root !== '/proc' && dirname !== '.git' && dirname !== 'node_modules')) {
mapFiles.push(path.relative(baseDir, entry));

@@ -319,0 +319,0 @@ }

@@ -48,4 +48,5 @@ /**

kSampleCount: any;
GARBAGE_COLLECTION_FUNCTION_NAME: string;
NON_JS_THREADS_FUNCTION_NAME: string;
};
export { getNativeThreadId };

@@ -26,3 +26,3 @@ "use strict";

Object.defineProperty(exports, "getNativeThreadId", { enumerable: true, get: function () { return time_profiler_bindings_1.getNativeThreadId; } });
const node_worker_threads_1 = require("node:worker_threads");
const worker_threads_1 = require("worker_threads");
const { kSampleCount } = time_profiler_bindings_1.constants;

@@ -62,3 +62,3 @@ const DEFAULT_INTERVAL_MICROS = 1000;

}
gProfiler = new time_profiler_bindings_1.TimeProfiler({ ...options, isMainThread: node_worker_threads_1.isMainThread });
gProfiler = new time_profiler_bindings_1.TimeProfiler({ ...options, isMainThread: worker_threads_1.isMainThread });
gSourceMapper = options.sourceMapper;

@@ -95,2 +95,3 @@ gIntervalMicros = options.intervalMicros;

if (!restart) {
gProfiler.dispose();
gProfiler = undefined;

@@ -132,3 +133,7 @@ gSourceMapper = undefined;

exports.v8ProfilerStuckEventLoopDetected = v8ProfilerStuckEventLoopDetected;
exports.constants = { kSampleCount, NON_JS_THREADS_FUNCTION_NAME: profile_serializer_1.NON_JS_THREADS_FUNCTION_NAME };
exports.constants = {
kSampleCount,
GARBAGE_COLLECTION_FUNCTION_NAME: profile_serializer_1.GARBAGE_COLLECTION_FUNCTION_NAME,
NON_JS_THREADS_FUNCTION_NAME: profile_serializer_1.NON_JS_THREADS_FUNCTION_NAME,
};
//# sourceMappingURL=time-profiler.js.map
{
"name": "@datadog/pprof",
"version": "5.0.0",
"version": "6.0.0-pre-2dd149e",
"description": "pprof support for Node.js",

@@ -9,15 +9,23 @@ "repository": "datadog/pprof-nodejs",

"scripts": {
"install": "exit 0",
"rebuild": "node-gyp rebuild --jobs=max",
"test:js": "nyc mocha -r source-map-support/register out/test/test-*.js",
"test:cpp": "node scripts/cctest.js",
"test:wall": "nyc mocha -r source-map-support/register out/test/test-time-profiler.js",
"test": "npm run test:js && npm run test:cpp",
"build:asan": "node-gyp configure build --jobs=max --address_sanitizer",
"build:tsan": "node-gyp configure build --jobs=max --thread_sanitizer",
"build": "node-gyp configure build --jobs=max",
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json",
"compile": "tsc -p .",
"fix": "gts fix",
"format": "clang-format --style file -i --glob='bindings/**/*.{h,hh,cpp,cc}'",
"install": "exit 0",
"lint": "jsgl --local . && gts check && clang-format --style file -n -Werror --glob='bindings/**/*.{h,hh,cpp,cc}'",
"format": "clang-format --style file -i --glob='bindings/**/*.{h,hh,cpp,cc}'",
"prepare": "npm run compile && npm run rebuild",
"pretest": "npm run compile"
"pretest:js-asan": "npm run compile && npm run build:asan",
"pretest:js-tsan": "npm run compile && npm run build:tsan",
"pretest:js-valgrind": "npm run pretest",
"pretest": "npm run compile",
"rebuild": "node-gyp rebuild --jobs=max",
"test:cpp": "node scripts/cctest.js",
"test:js-asan": "LSAN_OPTIONS='suppressions=./suppressions/lsan_suppr.txt' LD_PRELOAD=`gcc -print-file-name=libasan.so` mocha out/test/test-*.js",
"test:js-tsan": "LD_PRELOAD=`gcc -print-file-name=libtsan.so` mocha out/test/test-*.js",
"test:js-valgrind": "valgrind --leak-check=full mocha out/test/test-*.js",
"test:js": "nyc mocha -r source-map-support/register out/test/test-*.js",
"test": "npm run test:js && npm run test:cpp"
},

@@ -24,0 +32,0 @@ "author": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc