Skip to content

Add a debug feature for tracking heap memory usage

Henrik Gramner requested to merge gramner/dav1d:track_heap_allocations into master

By tagging allocations we can keep track of how much memory is being used for different purposes.

Currently all the state is global because we don't have convenient context pointers around everywhere, but for basic development/debugging purposes that's probably good enough.

Example output:

$ tools/dav1d --muxer null -i Chimera-AV1-8bit-1920x1080-6736kbps.ivf --threads 4 --framedelay 1

 Type                    Allocs    Reuses    Share    Peak size
---------------------------------------------------------------------
 Picture buffers              9      9822    86.1%    29 860 416
 Reference mv data           10      9746     4.6%     1 603 648
 Thread context data          2         0     3.0%     1 044 304
 Loopfilter data              3         0     2.1%       737 247
 Dav1dData                 8929         0     1.9%       668 488
 Looprestoration data         2         0     0.8%       292 808
 CDEF line buffers            1         0     0.4%       138 304
 CDF contexts                 9      9822     0.4%       124 992
 Tile data                    5         0     0.2%        68 025
 Common context data         11         0     0.2%        63 688
 Intra pred edges             1         0     0.1%        51 840
 OBU headers                 11      9898     0.1%        18 712
 Picture context data         9      9822     0.0%         3 096
---------------------------------------------------------------------
                           9002     49110             34 675 568

$ tools/dav1d --muxer null -i Chimera-AV1-8bit-1920x1080-6736kbps.ivf --threads 16 --framedelay 4

 Type                    Allocs    Reuses    Share    Peak size
---------------------------------------------------------------------
 Picture buffers             12      9819    33.0%     39 813 888
 Coefficient data             4         0    22.0%     26 542 080
 Block data                   8         0    19.2%     23 224 320
 Palette data                16         0    14.7%     17 694 720
 Thread context data          3         0     3.5%      4 178 368
 Reference mv data           19      9743     3.0%      3 591 016
 Loopfilter data             12         0     2.4%      2 948 988
 Looprestoration data         8         0     1.0%      1 171 232
 Dav1dData                 8929         0     0.8%        922 336
 CDEF line buffers            4         0     0.5%        553 216
 Tile data                   25         0     0.3%        317 428
 Intra pred edges             4         0     0.2%        207 360
 CDF contexts                10      9821     0.1%        138 880
 Common context data         20         0     0.1%         66 624
 OBU headers                 15      9894     0.0%         25 656
 Picture context data        12      9819     0.0%          4 224
---------------------------------------------------------------------
                           9101     49096             120 658 968
Edited by Henrik Gramner

Merge request reports

Loading