Expand description
How many allocations a stretch of a blue program made, and how many bytes.
blue profile reports time per definition; this is the other half of what
a definition costs (theory/BLUE-MEMORY.md §VI M0: you cannot configure
what you cannot account for). One counter, read at two points: a caller
snapshots allocations when an activation enters and again when it
leaves, and the difference is what that activation allocated, everything it
called included. Subtracting what its callees allocated gives the
exclusive figure, exactly as the profiler does with time.
Counting is a GlobalAlloc over System that counts each allocation
on the thread that made it. A binary opts in with one line:
#[global_allocator]
static ALLOC: blue_lang_runtime::alloc::Counting = blue_lang_runtime::alloc::Counting;The count is per thread so a profile of one interpreter is not charged for
another thread’s work, and it costs two thread-local additions per
allocation, nothing on a free. Until a binary installs Counting,
allocations answers None: a program that was never counted reads as
unmeasured, never as having allocated nothing.
Structs§
- Allocations
- Allocations made and bytes requested on one thread, from its start.
- Counting
- The system allocator, counting what each thread allocates. See the module documentation for how a binary installs it.
Functions§
- allocations
- This thread’s running totals, or
NonewhenCountingis not the global allocator of this binary.