Observation: purged and reset statistics types

Open
#1,151 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Stale
Tech stack
c
Domain
performance

Research direction

Start with the type definitions in include/mimalloc-stats.h, then inspect the two increments in src/os.c and the read in src/stats.c. Check the ABI-compatibility concern before changing the types; done means the representation matches the counter usage without breaking the existing statistics output.

Written by the indexing model from the issue text.

Description

The answer to this is probably "we know, it's for ABI compatibility", but just in case:

The statistics purged and reset variables are presently mi_stat_count_t, i.e., a 3-tuple of peak, current, and total.

https://github.com/microsoft/mimalloc/blob/09a27098aa6e9286518bd9c74e6ffa7199c3f04e/include/mimalloc-stats.h#L32

However, use of these variables is just as an increasing counter, i.e., their usage actually models a mi_stat_counter_t. They're only ever increased, in these two locations:

https://github.com/microsoft/mimalloc/blob/09a27098aa6e9286518bd9c74e6ffa7199c3f04e/src/os.c#L516
https://github.com/microsoft/mimalloc/blob/09a27098aa6e9286518bd9c74e6ffa7199c3f04e/src/os.c#L548

They're only read here:

https://github.com/microsoft/mimalloc/blob/09a27098aa6e9286518bd9c74e6ffa7199c3f04e/src/stats.c#L333

And that's literally the only use of mi_stat_peak_print(); it's just to extract the peak value from these, the total and current fields are never read, and those fields will always contain the same value. It seems these could be changed to be mi_stat_counter_t.

Dominant language
C
Stars
13.6k
Forks
1.2k
Avg merge
18h 12m
Merged PRs (30d)
20

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/mimalloc

All issues in microsoft/mimalloc

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.