heapprof.lowlevel: The low-level API

class heapprof.lowlevel.HPM(filebase: str)

Bases: object

HPM is the low-level interface to the .hpm file format.

property initialTime

Return the initial time of the profile.

property samplingRate

Return the sampling rate used when generating this heap profile. This is a dict from number of bytes to sampling probability; for an allocation of size X, the sampling probability is given by the entry for the smallest number of bytes in this dict > X. (If there is no such entry, the sampling probability is always 1)

rawTrace(traceindex: int) → Optional[List[heapprof.types.RawTraceLine]]

Given a traceindex (of the sort found in an HPDEvent), find the corresponding raw stack trace. Returns None if there is no known trace for this traceindex.

trace(traceindex: int) → Optional[List[heapprof.types.TraceLine]]

Given a traceindex (of the sort found in an HPDEvent), find the corresponding stack trace. Returns None if there is no known trace for this traceindex.

scaleFactor(eventSize: int) → float

Given an event size, find the appropriate scale factor for it.

warmRawTraceCache() → None

rawTrace() can be slow, because it may need to fetch traces out of the HPM file. Calling this function forces that entire load to happen at once.

close() → None
class heapprof.lowlevel.HPDEvent

Bases: tuple

A single event stored in a .hpd file.

property timestamp

Alias for field number 0

property traceindex

Alias for field number 1

property size

Alias for field number 2

property scaleFactor

Alias for field number 3

class heapprof.lowlevel.HPD(filebase: str, hpm: Optional[heapprof.lowlevel.HPM] = None)

Bases: collections.abc.Iterable, typing.Generic

HPD is the low-level interface to a .hpd file.

class heapprof.lowlevel.HPC(filebase: str, hpm: Optional[heapprof.lowlevel.HPM] = None)

Bases: collections.abc.Sequence, typing.Generic

HPC is the low-level interface to .hpc files.

close() → None
classmethod make(filebase: str, timeInterval: float, precision: float, verbose: bool) → None

Build a .hpc file out of a .hpm and .hpd file.

Parameters
  • filebase – The name of the hpx file to process.

  • timeInterval – The gap between consecutive snapshots, in seconds.

  • precision – The fraction of total bytes at any snapshot which can be stuffed into the “other” bin. Must be a number in [0, 1).

  • verbose – If set, prints out a lot of state to stderr.