Donner SVG 0.8.0-pre
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
HeapSizeHistogram.h File Reference

Live-heap histogram by allocation size (the single-canvas presenter work investigation). More...

#include <cstddef>
#include <cstdint>
Include dependency graph for HeapSizeHistogram.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  donner::AllocTagTotals
 Live large-block bytes attributed to each AllocTag. More...
class  donner::ScopedAllocTag
 Sets the calling thread's AllocTag for the lifetime of the scope, restoring the previous one on exit so guards nest. More...
struct  donner::HeapSizeHistogram
 Live allocation totals split by block size. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

Enumerations

enum class  donner::AllocTag : std::uint8_t {
  donner::Untagged = 0 ,
  donner::WorkerRenderFrame = 1 ,
  donner::WorkerBuildPreview = 2 ,
  donner::WorkerFinalSnapshot = 3 ,
  donner::WorkerOther = 4 ,
  donner::AppPollResult = 5 ,
  donner::AppUiFrame = 6 ,
  donner::AppHostFrame = 7 ,
  donner::AppInput = 8 ,
  donner::RenderTileRaster = 9 ,
  donner::GpuReadbackStaging = 10 ,
  donner::CompositorBitmap = 11 ,
  donner::PresentationUpload = 12 ,
  donner::ImGuiDrawLists = 13
}
 Who was on the stack when a large block was allocated. More...

Functions

const char * donner::AllocTagName (AllocTag tag)
 Stable short names for AllocTag, indexed by the enum value.
AllocTagTotals donner::SampleAllocTagTotals ()
 Read the per-tag live large-block totals.
HeapSizeHistogram donner::SampleHeapSizeHistogram ()
 Read the histogram. Cheap: a load per bucket.
bool donner::HeapSizeHistogramEnabled ()
 Whether the allocator wrappers are linked in. False in shipping builds.

Variables

constexpr std::size_t donner::kHeapSizeBucketCount = 32
 Number of power-of-two size buckets. Bucket k covers [2^k, 2^(k+1)) bytes, so 32 buckets reach 2 GiB, past anything a 512 MiB wasm heap can hold.
constexpr std::size_t donner::kLargeAllocationBytes = 4u * 1024u * 1024u
 Requested byte size at or above which an allocation is recorded in HeapSizeHistogram::recentLargeBytes. Chosen to catch anything canvas-scale while ignoring ordinary containers.
constexpr std::size_t donner::kRecentLargeAllocationCount = 16
 Number of recent large allocation sizes retained.
constexpr std::size_t donner::kLiveLargeBlockCount = 48
 Capacity of the live large-block table.
constexpr std::size_t donner::kAllocTagCount = 14
 Number of distinct AllocTag values.

Detailed Description

Live-heap histogram by allocation size (the single-canvas presenter work investigation).

See HeapSizeHistogram.cc for what this measures and how to turn it on. The header compiles and the accessors link in every configuration; without DONNER_HEAP_SIZE_HISTOGRAM they report an empty histogram and HeapSizeHistogramEnabled returns false, so callers never need their own preprocessor guard.


Class Documentation

◆ donner::AllocTagTotals

struct donner::AllocTagTotals

Live large-block bytes attributed to each AllocTag.

Class Members
int64_t liveBlocks[kAllocTagCount] = {} Live large blocks tagged with this value.
int64_t liveBytes[kAllocTagCount] = {} Bytes in live large blocks tagged with this value.
int64_t peakLiveBytes[kAllocTagCount] = {} Highest liveBytes seen for this tag.
int64_t totalAllocations[kAllocTagCount] = {} Large allocations ever made under this tag.

◆ donner::HeapSizeHistogram

struct donner::HeapSizeHistogram

Live allocation totals split by block size.

Class Members
int64_t largeAllocationCount = 0 Total large allocations seen since boot.
int64_t liveBlocks[kHeapSizeBucketCount] = {} Currently allocated block count in each bucket.
int64_t liveBytes[kHeapSizeBucketCount] = {} Currently allocated bytes in each bucket, measured as usable size.
int64_t liveLargeBytes[kLiveLargeBlockCount] = {} Usable sizes of the large blocks that are live right now; zero entries are empty slots.
int64_t liveLargeTags[kLiveLargeBlockCount] = {} AllocTag in force when the corresponding liveLargeBytes entry was allocated, as its integer value.
int64_t peakLiveBytes[kHeapSizeBucketCount] = {} Highest liveBytes seen in each bucket.
int64_t recentLargeBytes[kRecentLargeAllocationCount] = {} Requested sizes of the most recent large allocations, newest last. A bucket says a block is "16 to 32 MiB"; this says it is exactly 19,120,128 bytes, which is a 2186-pixel-wide RGBA surface and therefore identifies its owner by arithmetic instead of by guesswork.
int64_t tableOverflows = 0 Large allocations that found the live-block table full. Non-zero means the per-tag totals under-count and kLiveLargeBlockCount needs raising.