snmalloc icon indicating copy to clipboard operation
snmalloc copied to clipboard

Object stats

Open mjp41 opened this issue 2 years ago • 2 comments

This adds some statistic for tracking

  • How many deallocations are in message queues.
  • How many allocators have been created.
  • Per sizeclass statistics
    • Number of objects allocated
    • Number of objects deallocated
    • Number of slabs allocated
    • Number of slabs deallocated

The per sizeclass statistics are tracked per allocator, and a racy read is done to combine the results for displaying.

These statistics were used to debug #615 to calculate the fragmentation.

The displayed statistics are intended for post processing to calculate the fragmentation/utilisation.

The interface just prints the results using message. This could be improved with a better logging infrastructure.

mjp41 avatar Jun 08 '23 11:06 mjp41

Generally looks quite nice. ISTR snmalloc of old had the ability to conditionally keep stats or not; perhaps it would be worth having an empty implementation of the Stat and MonotoneStat interfaces and either templating or having a namespace snmalloc-scoped using to pick between them?

I was going to profile to see how much the operations cost. If they are noticeable, then I will macro it away as you suggest.

mjp41 avatar Jun 08 '23 15:06 mjp41