Skip to content

procwatch: live heap by allocation site, for measuring builds (alloc-sites) - #744

Merged
Hona merged 1 commit into
devfrom
alloc-sites
Nov 12, 2026
Merged

Hona merged 1 commit into
devfrom
alloc-sites

Conversation

@Hona

@Hona Hona commented Nov 12, 2026

Copy link
Copy Markdown
Member

Where a native app's memory goes, by who asked for it, in a measuring build: procwatch/alloc-sites (and rune/alloc-sites for the GPU device's allocations by label).

  • Counting samples one in every 32 KiB a thread asks for (a block of 32 KiB or more always) and keeps the sampled block's call stack until it's freed.
  • With PROCWATCH_ALLOC_SITES=<folder>, setting the event Local\procwatch-alloc-sites-<pid> writes the live sites, the counted live and peak heap, every NT heap's regions and busy bytes, the loaded modules and the GPU allocations to a file (Windows).
  • Tables come from VirtualAlloc on the first sample; nothing is sampled inside the allocator; the dump thread is a raw thread that waits on its event (no wakes).
  • Ordinary builds compile none of it.

First use: OpenCode (Rune)'s Home holds about 43 MB of live Rust and Luau heap against 221 MB of private bytes; the dumps found the 4 MiB-per-VM Luau code blocks (#743) and mimalloc pages committed whole and never touched.

…sites)

Where a native app's memory goes, by who asked for it. Counting samples one in every 32 KiB a
thread asks for (a block of 32 KiB or more always), keeps the sampled block's call stack until it
is freed, and with PROCWATCH_ALLOC_SITES=<folder> writes the live sites, the counted live and peak
heap, every NT heap's regions and busy bytes, and the loaded modules to a file each time the event
Local\procwatch-alloc-sites-<pid> is set (Windows). rune's alloc-sites feature adds the GPU device's
allocations by label. Tables are made on the first sample with VirtualAlloc, nothing is sampled
inside the allocator, and the dump runs on a raw thread that waits on its event. Ordinary builds
compile none of it.
Copilot AI balanced review requested due to automatic review settings November 12, 2026 06:52
@Hona
Hona merged commit 929f031 into dev Nov 12, 2026
1 check passed
@Hona
Hona deleted the alloc-sites branch November 12, 2026 06:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Hona added a commit that referenced this pull request Nov 25, 2026
…une and procwatch (#2370)

A feature-set warning sweep across Linux, macOS, Windows, and wasm32 found
eight dead-code warnings under optional and non-default feature sets:

- `crates/rune/src/open_path.rs:203` (`file_uri_from_bytes`, added in #1947):
  used on Unix only under `feature = "dbus"` (FileManager1) and tests; gate
  with `feature = "dbus"` alongside `test`.
- `crates/rune/src/platform/preferences.rs:77` (`DEFAULT_DOUBLE_CLICK_SECS`,
  added in #1923/#2128): used on Linux only under `feature = "dbus"` and tests;
  gate with `all(target_os = "linux", feature = "dbus")` alongside `test`.
- `crates/rune/src/window/titlebar/linux.rs:82` (`Sides::ALL`, added in #2244):
  used only in `linux_tests.rs`; gate with `#[cfg(test)]`.
- `crates/rune/src/frame/live_log.rs:33` (`CAPTURED` / `capture_frames`, added
  in #2309): used only in `window/win32/resize_sync/tests.rs` under
  `frame-profile`; gate with `#[cfg(all(test, target_os = "windows"))]`.
- `crates/procwatch/src/alloc/sites.rs:222,271,413,418` (`report`, `unsampled`,
  `os::modules`, `os::nt_heaps`, added in #744): `alloc-sites` sampling and
  dumper are Windows-only; gate the implementation behind `#[cfg(windows)]`
  with clean `#[cfg(not(windows))]` no-op stubs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants