Skip to content

feat(profiling): opt-in dhat heap profiling for desktop binary#515

Open
beruro wants to merge 1 commit into
developfrom
feat/profiling-dhat
Open

feat(profiling): opt-in dhat heap profiling for desktop binary#515
beruro wants to merge 1 commit into
developfrom
feat/profiling-dhat

Conversation

@beruro

@beruro beruro commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add a developer-only, feature-gated (dhat-heap) Rust heap profiler for the desktop binary.
  • New dhat_profiling module installs DHAT as the global allocator, schedules timed captures from env, and flushes the profile on app exit; wired via #[cfg(feature = "dhat-heap")] hooks in lib.rs / main.rs.
  • Optional dhat dependency + dedicated profile.dhat build profile (inherits release, symbolized) so normal and release builds are unaffected.
  • Add scripts/dev/profile-rust-heap.sh, scripts/dev/profile-macos-memory.sh, and contributor docs.

Safety

  • Every profiler code path is #[cfg(feature = "dhat-heap")]; the allocator and the dhat dependency are never linked unless --features dhat-heap is explicitly requested. Default and release builds are unaffected.

Test plan

  • cargo clippy --lib -p org2 passes on default features (profiler excluded; no new warnings in changed files).
  • cargo build --profile dhat --features dhat-heap then run scripts/dev/profile-rust-heap.sh; confirm a dhat capture is produced.
  • Confirm a default release build does not link dhat.

Based on latest develop.

Developer-only, feature-gated (`dhat-heap`) Rust heap profiler:
- `dhat_profiling` module wires DHAT as the global allocator, schedules
  timed captures from env, and flushes the profile on app exit.
- `dhat` is an optional dependency; a dedicated `profile.dhat` build profile
  preserves symbolized backtraces without affecting normal release artifacts.
- Add profiling scripts (rust heap + macOS memory) and contributor docs.

Never linked or active unless `--features dhat-heap` is explicitly requested,
so default and release builds are unaffected.
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.

1 participant