microsoft / microsoft/mimalloc
Potential contribution - runtime stats output, using fmt library
- Dominant language
- C
- Stars
- 13.4k
- Forks
- 1.2k
- Avg merge
- 4d 45m
- Merged PRs (30d)
- 13
Description
We've got a long-running (a very, very long running) daemon process that uses the `fmt` library for logging, and it's handy to be able to ask the daemon to log heap and process statistics to the log on-demand (we use the `USR1` signal for this).
To that end, we've got a header-only `fmt::formatter` specialization for that, in the vein of `mi_stats_print_out()`, using a fluent table builder approach to allow for us to easily define and change what we want in that logged output, ends up being a very declarative approach:
https://gist.github.com/bazineta/3f5fa91e077239a53fec3c43370f34f0
We're on C++23, using mimalloc v3 and the latest version of the `fmt` library, so the code presumes that. Curious if this might be helpful to others.
Sample output:
```
heap stats | peak | total | current
------------+-------------+-------------+------------
reserved | 1.0 GiB | 1.0 GiB | 1.0 GiB
committed | 11.8 MiB | 12.1 MiB | 11.8 MiB
touched | 0 | 0 | 0
threads | 4 | 4 | 4
pages | 0 | 0 | 0
-abandoned | 0 | 0 | 0
-reclaima | 0
-reclaimf | 0
-reabandon | 0
-waits | 0
-extended | 0
-retire | 0
arenas | 1
-rollback | 0
mmaps | 11
commits | 0
resets | 0
purges | 0
reset | 0
purged | 0
searches | 0.0 avg
rss | 34.3 MiB
faults | 60
elapsed | 13.978 s
user | 0.040 s
system | 0.019 s
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing mi_stats_print_out() and the linked header-only fmt::formatter specialization, noting how the USR1-triggered daemon output is intended to work. Determine whether this runtime statistics formatter fits mimalloc's public interfaces; done would mean a maintainable contribution that produces the described heap and process statistics output for C++23 and current fmt users.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100