Repository navigation
#2407: the debug allocator reports the peak live memory and its shape - #3070
Merged
Merged
Conversation
Beside the leak report: peak live bytes and blocks and the allocation that reached them, the peak split by origin kind, a log2 histogram of the blocks live at the peak, and the largest requests of the run. The runtime's own owners are tagged (HashMap, SlotMap, str, fmt) so the split names the table a block belongs to. An explicit exit (std.process.exit_code, std.compiler.exit, the compiler's own main) goes through with_exit, which prints the peak report without the leak walk: what is still allocated at an explicit exit is not a leak. Measured on the compiler checking src/main.w: 750 MB live payload at the peak in 2.4M blocks — List 393 MB, HashMap 280 MB, str 64 MB; 1.4M live blocks of 64 bytes or less; the largest single buffer a 41 MB List.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#2407: the debug allocator reports the peak live memory and its shape, beside its leak report.
That is the compiler checking
src/main.w(stage2 of this branch,WITH_DEBUG_ALLOC=1): 750 MB of live payload at the peak in 2.4 M blocks — List buffers 393 MB, HashMap tables 280 MB, strings 64 MB; 1.4 M of the live blocks are 64 bytes or smaller; the largest single buffer is a 41 MB List. The OS's max RSS for the same check is 773 MB, so the payload is the footprint; the 1.5 GB the issue measured is the stage compile, whose report is the next run.How. The ledger already held each block's size and origin;
dbg_account_alloc/dbg_account_freekeep live bytes and blocks, the per-origin split and a log2 histogram, and snapshot them at every new peak with the request ordinal; the eight largest distinct request sizes are kept with their owners. The runtime's own owners are tagged at theirrt_allocsites (HashMap,SlotMap,strfor NUL-terminated buffers,fmt), so the split names the table a block belongs to; the site of any block stays the address trap's (WITH_DEBUG_ALLOC_TRAP_FREEunder lldb).Explicit exits.
std.process.exit_code,std.compiler.exitand the compiler's ownmaingo throughwith_exit, which prints the peak report and not the leak walk: what is still allocated when a program chooses to stop is not a leak. The compiler'smainhad called libc'sexitthroughstd.libc, so no report of any kind ever printed for the compiler itself (a tool that stayed silent).Fixture
test/debug_alloc/da_2407_peak_report.w;debug-allocator.mdgains the report's section.