nodesource/massive-heap-snapshot-parser

Name: massive-heap-snapshot-parser

Owner: NodeSource

Description: small library for parsing massively massive snapshots and giving you a way to access its contents sanely

Created: 2017-01-12 18:31:18.0

Updated: 2017-12-29 11:39:34.0

Pushed: 2017-01-13 00:35:36.0

Homepage: null

Size: 21

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Massive Heap Snapshot Parser
Install

To install just do:

m install mhsp
Usage

This API will extract "snapshot", "nodes", "edges" and "strings" from very large snapshots in a way that allows you to continue working with them. It doesn't however show "trace_function_infos", "trace_tree" or "samples". Mainly because I don't need them right now. File an issue or open a PR if you'd like to help.

parseSnapshot(path)

This does all the magic. Just give it a path to a snapshot and it'll automatically do everything for you. Here's an example:

 strict';
t { parseSnapshot } = require('mhsp');

t accessor = parseSnapshot('./my-big.heapsnapshot');

Warning that for large snapshots this can take several minutes.

accessor.snapshot

This is the metadata object that contains various information about the snapshot.

accessor.nodes

This is a Uint32Array of all the nodes in the snapshot. Go ahead and access it by index.

accessor.edges

This is also a Uint32Array that can be accessed by index.

accessor.getString(index)

Returning strings from the "strings" field isn't as straight forward. Some fun index tracking is done under the hood so the entire "strings" section can live in one big Buffer.

accessor.writeToFile(path)

Since generating the accessor takes so long you can go ahead and write the entire thing to disk in the form of a binary blob. Can then use importBin() to read it back in later. Is much much faster.

importBin(path)

Read in files that have already been processed and written to disk as binary blobs. On my i7 the first time I process a 2GB snapshot can take over 1.5 minutes. But reading it back in this way only takes a few seconds. Highly recommended.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.