Skip to content

Fix display units of stats counters#1245

Closed
tmcdonell wants to merge 1 commit intomicrosoft:dev3from
dataparallel-swift:dev3-stats
Closed

Fix display units of stats counters#1245
tmcdonell wants to merge 1 commit intomicrosoft:dev3from
dataparallel-swift:dev3-stats

Conversation

@tmcdonell
Copy link
Copy Markdown

This PR fixes the units that stats are displayed in. Previously all counters were printed in binary mode, which is not always the natural unit (e.g. commits: 35.4 Ki vs commits: 40.5 K).

Example: env MIMALLOC_SHOW_STATS=1 ./build/mimalloc-test-stress

Before
subproc 0
 blocks          peak       total     current       block      total#   
  bin S    1:    21.4 KiB    73.2 MiB     0           8   B       9.6 M    ok
  bin S    4:    86.8 KiB   291.9 MiB     0          32   B       9.5 M    ok
  bin S    6:   133.9 KiB   437.9 MiB     0          48   B       9.5 M    ok
  bin S    9:   211.6 KiB   731.1 MiB     0          80   B       9.5 M    ok
  bin S   13:   409.5 KiB     1.4 GiB   160   B     160   B       9.5 M    not all freed
  bin S   17:    25.7 KiB   456.1 KiB     1.2 KiB   320   B       1.4 K    not all freed
  bin S   18:   384   B     384   B       0         384   B       1        ok
  bin S   21:     0           3.0 GiB     0         640   B       5.0 M    ok
  bin S   23:    28.1 KiB   165.1 MiB     0         896   B     193.3 K    ok
  bin S   25:     1.2 KiB     1.2 KiB     1.2 KiB     1.2 KiB     1        not all freed
  bin S   27:    40.4 KiB   338.3 MiB     0           1.7 KiB   198.0 K    ok
  bin S   31:   319.7 KiB   691.9 MiB     0           3.5 KiB   202.4 K    ok
  bin S   35:   576.2 KiB     1.2 GiB     0           7.0 KiB   191.1 K    ok
  bin M   39:     1.1 MiB     2.6 GiB     0          14.0 KiB   197.1 K    ok
  bin M   41:     3.5 MiB     8.3 MiB     0          20.0 KiB   429        ok
  bin M   43:     0           1.3 GiB     0          28.1 KiB    50.7 K    ok
  bin M   45:     0           7.8 MiB     0          40.1 KiB   200        ok
  bin M   47:     0           2.7 GiB     0          56.2 KiB    52.3 K    ok
  bin M   48:     0          12.5 MiB     0          64.2 KiB   200        ok
  bin M   49:     0          15.6 MiB     0          80.3 KiB   200        ok
  bin L   51:     0          21.8 MiB     0         112.4 KiB   200        ok
  bin L   52:     0          25.0 MiB     0         128.5 KiB   200        ok
  bin L   53:     0          62.5 MiB     0         160.6 KiB   400        ok

  binned    :     6.3 Mi     14.9 Gi      2.6 Ki                           not all freed
  huge      :     0           1.2 Gi      0                                ok
  total     :     6.3 MiB    16.2 GiB     2.6 KiB                          
  malloc req:                12.9 GiB

 pages           peak       total     current       block      total#   
  touched   :    11.6 GiB    11.6 GiB    11.6 GiB                          
  pages     :   550         106.4 Ki      3                                not all freed
  abandoned :   513         278.4 Ki      0                                ok
  reclaima  :    48.0 Ki 
  reclaimf  :   194.4 Ki 
  reabandon :    40.4 Ki 
  waits     :     0      
  extended  :     1.5 Mi 
  retire    :    13.4 Ki 
  searches  :     2.2 avg

 arenas          peak       total     current       block      total#   
  reserved  :   324.4 MiB   324.6 MiB   324.3 MiB                          
  committed :   286.8 MiB     8.4 GiB    37.6 MiB                          
  reset     :     0      
  purged    :     8.4 Gi 
  arenas    :     5      
  rollback  :     0      
  mmaps     :     8      
  commits   :    35.4 Ki 
  resets    :     0      
  purges    :    33.9 Ki 
  guarded   :     0      
  heaps     :     6          51           1                                

 process         peak       total     current       block      total#   
  threads   :    33           1.5 Ki      1                                
  numa nodes:     1
  elapsed   :    28.777 s
  process   : user: 151.844 s, system: 7.745 s, faults: 0, peak rss: 222.8 MiB, peak commit: 286.8 MiB
After

subproc 0
 blocks          peak       total     current       block      total#   
  bin S    1:    22.2 KiB    73.2 MiB     0           8   B       9.6 M    ok
  bin S    4:    88.7 KiB   291.9 MiB     0          32   B       9.5 M    ok
  bin S    6:   132.7 KiB   437.9 MiB     0          48   B       9.5 M    ok
  bin S    9:   205.0 KiB   731.1 MiB     0          80   B       9.5 M    ok
  bin S   13:   416.7 KiB     1.4 GiB   160   B     160   B       9.5 M    not all freed
  bin S   17:    25.7 KiB   456.1 KiB     1.2 KiB   320   B       1.4 K    not all freed
  bin S   18:   384   B     384   B       0         384   B       1        ok
  bin S   21:     0           3.0 GiB     0         640   B       5.0 M    ok
  bin S   23:    28.9 KiB   165.1 MiB     0         896   B     193.3 K    ok
  bin S   25:     1.2 KiB     1.2 KiB     1.2 KiB     1.2 KiB     1        not all freed
  bin S   27:    49.1 KiB   338.3 MiB     0           1.7 KiB   198.0 K    ok
  bin S   31:   365.4 KiB   691.9 MiB     0           3.5 KiB   202.4 K    ok
  bin S   35:   484.8 KiB     1.2 GiB     0           7.0 KiB   191.1 K    ok
  bin M   39:     1.1 MiB     2.6 GiB     0          14.0 KiB   197.1 K    ok
  bin M   41:     3.7 MiB     8.5 MiB     0          20.0 KiB   436        ok
  bin M   43:     0           1.3 GiB     0          28.1 KiB    50.7 K    ok
  bin M   45:     0           7.8 MiB     0          40.1 KiB   200        ok
  bin M   47:     0           2.7 GiB     0          56.2 KiB    52.3 K    ok
  bin M   48:     0          12.5 MiB     0          64.2 KiB   200        ok
  bin M   49:     0          15.6 MiB     0          80.3 KiB   200        ok
  bin L   51:     0          21.8 MiB     0         112.4 KiB   200        ok
  bin L   52:     0          25.0 MiB     0         128.5 KiB   200        ok
  bin L   53:     0          62.5 MiB     0         160.6 KiB   400        ok

  binned    :     6.4 MiB    14.9 GiB     2.6 KiB                          not all freed
  huge      :     0           1.2 GiB     0                                ok
  total     :     6.4 MiB    16.2 GiB     2.6 KiB                          
  malloc req:                12.9 GiB

 pages           peak       total     current       block      total#   
  touched   :    11.7 GiB    11.7 GiB    11.7 GiB                          
  pages     :   543   B     107.0 KiB     3   B                            not all freed
  abandoned :   504   B     278.3 KiB     0                                ok
  reclaima  :    48.0 K  
  reclaimf  :   198.2 K  
  reabandon :    40.9 K  
  waits     :     0      
  extended  :     1.6 M  
  retire    :    13.6 K  
  searches  :     2.1 avg

 arenas          peak       total     current       block      total#   
  reserved  :   388.4 MiB   388.7 MiB   388.3 MiB                          
  committed :   288.3 MiB     8.7 GiB    42.3 MiB                          
  reset     :     0      
  purged    :     8.6 GiB
  arenas    :     6      
  rollback  :     0      
  mmaps     :     9      
  commits   :    40.5 K  
  resets    :     0      
  purges    :    38.8 K  
  guarded   :     0      
  heaps     :     6          51                      1      

 process         peak       total     current       block      total#   
  threads   :    33           1.6 K                  1      
  numa nodes:     1
  elapsed   :    29.706 s
  process   : user: 153.935 s, system: 8.472 s, faults: 0, peak rss: 229.1 MiB, peak commit: 288.3 MiB

daanx added a commit that referenced this pull request Apr 12, 2026
@daanx
Copy link
Copy Markdown
Collaborator

daanx commented Apr 12, 2026

Thank you for the PR! I studied it but decided to take a slightly different approach. Let me know if this works for you. Thanks again!

@daanx daanx closed this Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants