Skip to content

Expose allocation statistics for memory provideres (and pools?) #282

@igchor

Description

@igchor

Rationale

When debugging/profiling applications it's often useful to know how many coarse-grain and/or fine-grain allocations there were (and size of those allocations). We should add a possibility to print those stats to stdout or a log file.

Description

Must-have stats:

  • number of allocs
  • number of frees
  • total allocated memory size

Nice-to-have stats:

  • distribution of allocation sizes (histogram)
  • latency of allocations (p50, p90, p99), possibly per allocation size range (predefined, or specified by the user)

Stats collection and printing should be toggled using an env variable. We might want to specify how often the stats are printed (e.g. every Nth allocation/free or only when the provider/pool is destroyed). Whenever we print stats, we should also print a timestamp (this could allow visualizing memory usage).

API Changes

New env variable.

Implementation details

The implementation can be put in memory_provider.c / memory_pool.c so that we don't have to duplicate the logic for each pool/provider.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions