@datadog/pprof
Advanced tools
Comparing version 5.4.0 to 6.0.0-pre-2cbc15d
@@ -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) { | ||
@@ -59,4 +60,2 @@ return (location.column !== undefined && | ||
} | ||
if (node.name === '(idle)' || node.name === '(program)') | ||
continue; | ||
const stack = entry.stack; | ||
@@ -195,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 }, | ||
}; | ||
} | ||
/** | ||
@@ -275,22 +339,4 @@ * Converts v8 time profile into into a profile proto. | ||
}; | ||
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, | ||
}, | ||
], | ||
}; | ||
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); | ||
@@ -297,0 +343,0 @@ } |
@@ -48,4 +48,5 @@ /** | ||
kSampleCount: any; | ||
GARBAGE_COLLECTION_FUNCTION_NAME: string; | ||
NON_JS_THREADS_FUNCTION_NAME: string; | ||
}; | ||
export { getNativeThreadId }; |
@@ -130,3 +130,7 @@ "use strict"; | ||
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.4.0", | ||
"version": "6.0.0-pre-2cbc15d", | ||
"description": "pprof support for Node.js", | ||
@@ -5,0 +5,0 @@ "repository": "datadog/pprof-nodejs", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
9763798
91
1658
2
58