pub struct Carved;Expand description
A size-classed free list that carves its blocks out of larger chunks, for a program that runs and ends.
The blocks a program keeps alive are carved, not asked for one at a
time (task-2191). Pooled asks the system for every block its lists do
not hold, and a statement that keeps what it builds, such as an .import of
50,000 rows held for one bulk build, empties every list at once and sends
each value to the Windows heap: the heap was 38% of the import. This takes
64 KiB from the system at a time and hands out blocks from it, so a block
costs a pointer bump.
Every small class carves from the same chunk. With a chunk per class, a one row query, which allocates 3,248 blocks in more than a hundred classes, touched at least one fresh 4 KiB page per class, and each first touch is a page fault. From one chunk, blocks of different sizes share pages, and the pages touched follow the bytes allocated. A class’s free list still holds only its own blocks.
Freed blocks are kept, not given back. A carved block is part of a chunk
and the system cannot take it alone, so a class keeps every block it has
carved, which is at most the most of that class the program held at once.
That is why the command line and the shell install it and the MCP server,
which runs for as long as its client does, keeps Pooled.
Page sized blocks are carved too, on page boundaries. Every buffer pool frame is a 32 KiB block, and a cold query from the command line reads tens of pages into frames used for the first time. Taken from the Windows heap one at a time, each block cost a heap call and nine first touch faults. Carved from a 512 KiB chunk aligned to a page, it costs a pointer bump and eight. In a new process, reading 64 pages of 32 KiB took 681 us into heap blocks and 473 us into one page aligned region.
Trait Implementations§
Source§impl GlobalAlloc for Carved
impl GlobalAlloc for Carved
Source§unsafe fn alloc(&self, layout: Layout) -> *mut u8
unsafe fn alloc(&self, layout: Layout) -> *mut u8
layout. Read more