@datadog/pprof
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -20,1 +20,3 @@ /** | ||
export declare function getAllocationProfile(): AllocationProfileNode; | ||
export declare type NearHeapLimitCallback = (profile: AllocationProfileNode) => void; | ||
export declare function monitorOutOfMemory(heapLimitExtensionSize: number, maxHeapLimitExtensionCount: number, dumpHeapProfileOnSdterr: boolean, exportCommand: Array<String> | undefined, callback: NearHeapLimitCallback | undefined, callbackMode: number): void; |
@@ -18,3 +18,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getAllocationProfile = exports.stopSamplingHeapProfiler = exports.startSamplingHeapProfiler = void 0; | ||
exports.monitorOutOfMemory = exports.getAllocationProfile = exports.stopSamplingHeapProfiler = exports.startSamplingHeapProfiler = void 0; | ||
const path = require("path"); | ||
@@ -36,2 +36,6 @@ const findBinding = require('node-gyp-build'); | ||
exports.getAllocationProfile = getAllocationProfile; | ||
function monitorOutOfMemory(heapLimitExtensionSize, maxHeapLimitExtensionCount, dumpHeapProfileOnSdterr, exportCommand, callback, callbackMode) { | ||
profiler.heapProfiler.monitorOutOfMemory(heapLimitExtensionSize, maxHeapLimitExtensionCount, dumpHeapProfileOnSdterr, exportCommand, callback, callbackMode); | ||
} | ||
exports.monitorOutOfMemory = monitorOutOfMemory; | ||
//# sourceMappingURL=heap-profiler-bindings.js.map |
@@ -28,2 +28,3 @@ /** | ||
export declare function profile(ignoreSamplePath?: string, sourceMapper?: SourceMapper): Profile; | ||
export declare function convertProfile(rootNode: AllocationProfileNode, ignoreSamplePath?: string, sourceMapper?: SourceMapper): Profile; | ||
/** | ||
@@ -39,1 +40,35 @@ * Starts heap profiling. If heap profiling has already been started with | ||
export declare function stop(): void; | ||
export declare type NearHeapLimitCallback = (profile: Profile) => void; | ||
export declare const CallbackMode: { | ||
Async: number; | ||
Interrupt: number; | ||
Both: number; | ||
}; | ||
/** | ||
* Add monitoring for v8 heap, heap profiler must already be started. | ||
* When an out of heap memory event occurs: | ||
* - an extension of heap memory of |heapLimitExtensionSize| bytes is | ||
* requested to v8. This extension can occur |maxHeapLimitExtensionCount| | ||
* number of times. If the extension amount is not enough to satisfy | ||
* memory allocation that triggers GC and OOM, process will abort. | ||
* - heap profile is dumped as folded stacks on stderr if | ||
* |dumpHeapProfileOnSdterr| is true | ||
* - heap profile is dumped in temporary file and a new process is spawned | ||
* with |exportCommand| arguments and profile path appended at the end. | ||
* - |callback| is called. Callback can be invoked only if | ||
* heapLimitExtensionSize is enough for the process to continue. Invocation | ||
* will be done by a RequestInterrupt if |callbackMode| is Interrupt or Both, | ||
* this might be unsafe since Isolate should not be reentered | ||
* from RequestInterrupt, but this allows to interrupt synchronous code. | ||
* Otherwise the callback is scheduled to be called asynchronously. | ||
* @param heapLimitExtensionSize - amount of bytes heap should be expanded | ||
* with upon OOM | ||
* @param maxHeapLimitExtensionCount - maximum number of times heap size | ||
* extension can occur | ||
* @param dumpHeapProfileOnSdterr - dump heap profile on stderr upon OOM | ||
* @param exportCommand - command to execute upon OOM, filepath of a | ||
* temporary file containing heap profile will be appended | ||
* @param callback - callback to call when OOM occurs | ||
* @param callbackMode | ||
*/ | ||
export declare function monitorOutOfMemory(heapLimitExtensionSize: number, maxHeapLimitExtensionCount: number, dumpHeapProfileOnSdterr: boolean, exportCommand?: Array<String>, callback?: NearHeapLimitCallback, callbackMode?: number): void; |
@@ -18,3 +18,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.stop = exports.start = exports.profile = exports.v8Profile = void 0; | ||
exports.monitorOutOfMemory = exports.CallbackMode = exports.stop = exports.start = exports.convertProfile = exports.profile = exports.v8Profile = void 0; | ||
const heap_profiler_bindings_1 = require("./heap-profiler-bindings"); | ||
@@ -46,4 +46,7 @@ const profile_serializer_1 = require("./profile-serializer"); | ||
function profile(ignoreSamplePath, sourceMapper) { | ||
return convertProfile(v8Profile(), ignoreSamplePath, sourceMapper); | ||
} | ||
exports.profile = profile; | ||
function convertProfile(rootNode, ignoreSamplePath, sourceMapper) { | ||
const startTimeNanos = Date.now() * 1000 * 1000; | ||
const result = v8Profile(); | ||
// Add node for external memory usage. | ||
@@ -61,7 +64,7 @@ // Current type definitions do not have external. | ||
}; | ||
result.children.push(externalNode); | ||
rootNode.children.push(externalNode); | ||
} | ||
return (0, profile_serializer_1.serializeHeapProfile)(result, startTimeNanos, heapIntervalBytes, ignoreSamplePath, sourceMapper); | ||
return (0, profile_serializer_1.serializeHeapProfile)(rootNode, startTimeNanos, heapIntervalBytes, ignoreSamplePath, sourceMapper); | ||
} | ||
exports.profile = profile; | ||
exports.convertProfile = convertProfile; | ||
/** | ||
@@ -93,2 +96,47 @@ * Starts heap profiling. If heap profiling has already been started with | ||
exports.stop = stop; | ||
exports.CallbackMode = { | ||
Async: 1, | ||
Interrupt: 2, | ||
Both: 3, | ||
}; | ||
/** | ||
* Add monitoring for v8 heap, heap profiler must already be started. | ||
* When an out of heap memory event occurs: | ||
* - an extension of heap memory of |heapLimitExtensionSize| bytes is | ||
* requested to v8. This extension can occur |maxHeapLimitExtensionCount| | ||
* number of times. If the extension amount is not enough to satisfy | ||
* memory allocation that triggers GC and OOM, process will abort. | ||
* - heap profile is dumped as folded stacks on stderr if | ||
* |dumpHeapProfileOnSdterr| is true | ||
* - heap profile is dumped in temporary file and a new process is spawned | ||
* with |exportCommand| arguments and profile path appended at the end. | ||
* - |callback| is called. Callback can be invoked only if | ||
* heapLimitExtensionSize is enough for the process to continue. Invocation | ||
* will be done by a RequestInterrupt if |callbackMode| is Interrupt or Both, | ||
* this might be unsafe since Isolate should not be reentered | ||
* from RequestInterrupt, but this allows to interrupt synchronous code. | ||
* Otherwise the callback is scheduled to be called asynchronously. | ||
* @param heapLimitExtensionSize - amount of bytes heap should be expanded | ||
* with upon OOM | ||
* @param maxHeapLimitExtensionCount - maximum number of times heap size | ||
* extension can occur | ||
* @param dumpHeapProfileOnSdterr - dump heap profile on stderr upon OOM | ||
* @param exportCommand - command to execute upon OOM, filepath of a | ||
* temporary file containing heap profile will be appended | ||
* @param callback - callback to call when OOM occurs | ||
* @param callbackMode | ||
*/ | ||
function monitorOutOfMemory(heapLimitExtensionSize, maxHeapLimitExtensionCount, dumpHeapProfileOnSdterr, exportCommand, callback, callbackMode) { | ||
if (!enabled) { | ||
throw new Error('Heap profiler must already be started to call monitorOutOfMemory'); | ||
} | ||
let newCallback; | ||
if (typeof callback !== 'undefined') { | ||
newCallback = (profile) => { | ||
callback(convertProfile(profile)); | ||
}; | ||
} | ||
(0, heap_profiler_bindings_1.monitorOutOfMemory)(heapLimitExtensionSize, maxHeapLimitExtensionCount, dumpHeapProfileOnSdterr, exportCommand || [], newCallback, typeof callbackMode !== 'undefined' ? callbackMode : exports.CallbackMode.Async); | ||
} | ||
exports.monitorOutOfMemory = monitorOutOfMemory; | ||
//# sourceMappingURL=heap-profiler.js.map |
@@ -16,3 +16,10 @@ import cpuProfiler from './cpu-profiler'; | ||
profile: typeof heapProfiler.profile; | ||
convertProfile: typeof heapProfiler.convertProfile; | ||
v8Profile: typeof heapProfiler.v8Profile; | ||
monitorOutOfMemory: typeof heapProfiler.monitorOutOfMemory; | ||
CallbackMode: { | ||
Async: number; | ||
Interrupt: number; | ||
Both: number; | ||
}; | ||
}; |
@@ -38,3 +38,6 @@ "use strict"; | ||
profile: heapProfiler.profile, | ||
convertProfile: heapProfiler.convertProfile, | ||
v8Profile: heapProfiler.v8Profile, | ||
monitorOutOfMemory: heapProfiler.monitorOutOfMemory, | ||
CallbackMode: heapProfiler.CallbackMode, | ||
}; | ||
@@ -41,0 +44,0 @@ // If loaded with --require, start profiling. |
@@ -180,10 +180,13 @@ "use strict"; | ||
function serializeTimeProfile(prof, intervalMicros, sourceMapper, recomputeSamplingInterval = false) { | ||
// If requested, recompute sampling interval it from profile duration and total number of hits, | ||
// since profile duration should be #hits x interval | ||
// If requested, recompute sampling interval from profile duration and total number of hits, | ||
// since profile duration should be #hits x interval. | ||
// Recomputing an average interval is more accurate, since in practice intervals between | ||
// samples are larger than the requested sampling interval (eg. 12.5ms vs 10ms requested). | ||
// For very short durations, computation becomes meaningless (eg. if there is only one hit), | ||
// therefore keep intervalMicros as a lower bound and 2 * intervalMicros as upper bound. | ||
if (recomputeSamplingInterval) { | ||
const totalHitCount = computeTotalHitCount(prof.topDownRoot); | ||
if (totalHitCount > 0) { | ||
intervalMicros = Math.floor((prof.endTime - prof.startTime) / computeTotalHitCount(prof.topDownRoot)); | ||
intervalMicros = Math.min(Math.max(Math.floor((prof.endTime - prof.startTime) / | ||
computeTotalHitCount(prof.topDownRoot)), intervalMicros), 2 * intervalMicros); | ||
} | ||
@@ -190,0 +193,0 @@ } |
@@ -177,7 +177,15 @@ "use strict"; | ||
} | ||
const generatedPos = { line: location.line, column: location.column }; | ||
const generatedPos = { | ||
line: location.line, | ||
column: location.column, | ||
bias: sourceMap.SourceMapConsumer.LEAST_UPPER_BOUND, | ||
}; | ||
// TODO: Determine how to remove the explicit cast here. | ||
const consumer = entry.mapConsumer; | ||
const pos = consumer.originalPositionFor(generatedPos); | ||
let pos = consumer.originalPositionFor(generatedPos); | ||
if (pos.source === null) { | ||
generatedPos.bias = sourceMap.SourceMapConsumer.GREATEST_LOWER_BOUND; | ||
pos = consumer.originalPositionFor(generatedPos); | ||
} | ||
if (pos.source === null) { | ||
return location; | ||
@@ -184,0 +192,0 @@ } |
{ | ||
"name": "@datadog/pprof", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"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
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12314718
1490