Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
c294b16
Memory & CPU Profiling.
sapatrjv Mar 21, 2026
062e1fb
Enable Memory & CPU profiling for df_engine.
sapatrjv Mar 24, 2026
f79dffd
Merge branch 'main' into dev/sapatr/memprofilingwithdhat
sapatrjv Mar 24, 2026
1ab21be
Enable Memory & CPU Profiling for df_engine
sapatrjv Mar 24, 2026
8c6daa6
Merge branch 'dev/sapatr/memprofilingwithdhat' of https://github.com/…
sapatrjv Mar 24, 2026
d23af0e
Enable Memory & CPU Profiling for df_engine
sapatrjv Mar 24, 2026
ad71e6b
Revert "Enable Memory & CPU Profiling for df_engine"
sapatrjv Mar 24, 2026
7482d31
Enable Memory & CPU Profiling for df_engine
sapatrjv Mar 24, 2026
aebde81
Enable Memory & CPU Profiling for df_engine
sapatrjv Mar 25, 2026
cc9e748
Enable Memory & CPU Profiling for df_engine
sapatrjv Mar 25, 2026
9222922
Merge branch 'main' into dev/sapatr/memprofilingwithdhat
sapatrjv Mar 25, 2026
6568f0d
Enable Memory & CPU Profiling for df_engine
sapatrjv Mar 25, 2026
a87c8fe
Enable Memory & CPU Profiling for df_engine.
sapatrjv Mar 30, 2026
157f5ab
Enable Memory & CPU Profiling for df_engine.
sapatrjv Mar 30, 2026
d73b21e
Enable Memory & CPU Profiling for df_engine
sapatrjv Mar 31, 2026
eed136f
Merge branch 'main' into dev/sapatr/memprofilingwithdhat
sapatrjv Mar 31, 2026
34c417c
Enable Memory & CPU Profiling for df_engine
sapatrjv Mar 31, 2026
0ad845f
Merge branch 'dev/sapatr/memprofilingwithdhat' of https://github.com/…
sapatrjv Mar 31, 2026
30b679a
Enable Memory & CPU Profiling for df_engine
sapatrjv Mar 31, 2026
a7c9240
Enable Memory & CPU Profiling for df_engine
sapatrjv Mar 31, 2026
12b6ba4
Enable Memory & CPU Profiling for df_engine
sapatrjv Mar 31, 2026
6e77031
Enable Memory & CPU Profiling for df_engine
sapatrjv Mar 31, 2026
37891c6
Enable Memory & CPU Profiling for df_engine
sapatrjv Apr 2, 2026
d95c7b7
Enable Memory & CPU Profiling for df_engine
sapatrjv Apr 2, 2026
b46664d
Enable Memory & CPU Profiling for df_engine
sapatrjv Apr 2, 2026
bba7248
Enable Memory & CPU Profiling for df_engine
sapatrjv Apr 2, 2026
64f7ec7
Enable Memory & CPU Profiling for df_engine
sapatrjv Apr 2, 2026
2af5ef7
Enable Memory & CPU Profiling for df_engine
sapatrjv Apr 2, 2026
8c9801b
Apply suggestion from @reyang
reyang Apr 2, 2026
7c28e45
Merge branch 'dev/sapatr/memprofilingwithdhat' of https://github.com/…
sapatrjv Apr 2, 2026
3897c66
Apply suggestions from code review
sapatrjv Apr 2, 2026
1720c5f
Enable Memory & CPU Profiling for df_engine
sapatrjv Apr 2, 2026
72377fb
Enable Memory & CPU Profiling for df_engine
sapatrjv Apr 2, 2026
42c08f2
Enable Memory & CPU Profiling for df_engine
sapatrjv Apr 2, 2026
6d6b315
Apply suggestions from code review
sapatrjv Apr 2, 2026
8856edc
Enable Memory & CPU Profiling for df_engine
sapatrjv Apr 3, 2026
d9e0bfd
Merge branch 'dev/sapatr/memprofilingwithdhat' of https://github.com/…
sapatrjv Apr 3, 2026
66f02a4
Enable Memory & CPU Profiling for df_engine
sapatrjv Apr 3, 2026
a9186cc
Enable Memory & CPU Profiling for df_engine
sapatrjv Apr 3, 2026
e533701
Enable Memory & CPU Profiling for df_engine
sapatrjv Apr 3, 2026
0358fa0
Enable Memory & CPU Profiling for df_engine
sapatrjv Apr 3, 2026
06111a1
Enable Memory & CPU Profiling for df_engine
sapatrjv Apr 3, 2026
ebdf8d4
Enable Memory & CPU Profiling for df_engine
sapatrjv Apr 3, 2026
cd8bf90
Enable Memory & CPU Profiling for df_engine
sapatrjv Apr 3, 2026
1b4185f
Enable Memory & CPU Profiling for df_engine.
sapatrjv Apr 14, 2026
600d336
Merge branch 'main' into dev/sapatr/memprofilingwithdhat
sapatrjv Apr 14, 2026
a6dad10
Merge branch 'main' into dev/sapatr/memprofilingwithdhat
jmacd Apr 15, 2026
658e151
Enable Memory & CPU Profiling for df_engine
sapatrjv Apr 15, 2026
285883f
Merge branch 'dev/sapatr/memprofilingwithdhat' of https://github.com/…
sapatrjv Apr 15, 2026
787bfa5
Remove code coverage on profiling path.
sapatrjv Apr 15, 2026
7c81041
Remove code coverage on profiling path.
sapatrjv Apr 15, 2026
7d2a092
Merge branch 'main' into dev/sapatr/memprofilingwithdhat
lalitb Apr 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions rust/otap-dataflow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ serde_json.workspace = true
clap.workspace = true
mimalloc = { workspace = true, optional = true }
sysinfo.workspace = true
dhat = "0.3.3"
ctrlc = "3"
once_cell = "1"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could of points here

  • These 3 crates should be optional and enabled only when dhat-heap feature is enabled.
  • Since this crate already targets Rust 1.87, could we use std::sync::LazyLock here instead of adding once_cell just for this static?


[target.'cfg(not(windows))'.dependencies]
tikv-jemallocator = { workspace = true, optional = true }
Expand Down Expand Up @@ -217,6 +220,9 @@ aws = ["otap-df-otap/aws"]
unsafe-optimizations = ["unchecked-index", "unchecked-arithmetic"]
unchecked-index = []
unchecked-arithmetic = []
dhat-heap = [] # if you are doing heap profiling
dhat-ad-hoc = [] # if you are doing ad hoc profiling


# Dev/test tooling (fake data generator).
dev-tools = ["otap-df-core-nodes/dev-tools"]
Expand Down Expand Up @@ -300,6 +306,10 @@ missing_crate_level_docs = "deny"
[profile.release]
debug = "line-tables-only" # minimum required for profiling

[profile.profiling]
inherits = "release"
debug = 2

# A more in-depth analysis is necessary to determine the optimal parameters for the release profile.
#[profile.release]
#lto = "thin"
Expand Down
43 changes: 43 additions & 0 deletions rust/otap-dataflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,49 @@
docker build --build-context otel-arrow=../../ -f Dockerfile -t df_engine .
```

## Profiling
Comment thread
sapatrjv marked this conversation as resolved.

This section covers Memory & CPU Profiling for df_engine using dhat-rs and samply profilers respectively.

Check failure on line 389 in rust/otap-dataflow/README.md

View workflow job for this annotation

GitHub Actions / markdownlint

Line length

rust/otap-dataflow/README.md:389:81 MD013/line-length Line length [Expected: 80; Actual: 105] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md013.md

**Requirements**:

- dhat-rs (https://docs.rs/dhat/latest/dhat/)

Check failure on line 393 in rust/otap-dataflow/README.md

View workflow job for this annotation

GitHub Actions / markdownlint

Bare URL used

rust/otap-dataflow/README.md:393:12 MD034/no-bare-urls Bare URL used [Context: "https://docs.rs/dhat/latest/dh..."] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md034.md
- samply (https://github.com/mstange/samply)

Check failure on line 394 in rust/otap-dataflow/README.md

View workflow job for this annotation

GitHub Actions / markdownlint

Bare URL used

rust/otap-dataflow/README.md:394:11 MD034/no-bare-urls Bare URL used [Context: "https://github.com/mstange/sam..."] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md034.md

**Installation**

Check failure on line 396 in rust/otap-dataflow/README.md

View workflow job for this annotation

GitHub Actions / markdownlint

Emphasis used instead of a heading

rust/otap-dataflow/README.md:396 MD036/no-emphasis-as-heading Emphasis used instead of a heading [Context: "Installation"] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md036.md

cargo install --locked samply
Comment thread
sapatrjv marked this conversation as resolved.
Outdated

Note: dhat-rs is a library crate designed for heap profiling in Rust programs.
Hence it does not require explicit installation.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If this is not explicitly required, why would we want to document it under the "Requirements" section?


**Build**:

**Build for both CPU & Memory profiling**:
Comment thread
sapatrjv marked this conversation as resolved.
Outdated
cargo build --profile profiling --features dhat-heap --workspace

**Build for only CPU profiling**:
cargo build --profile profiling --workspace

**Run**:

**Run with both Memory & CPU profiling enabled**:
Comment thread
reyang marked this conversation as resolved.
Outdated
samply record ./target/profiling/df_engine.exe --config .\configs\otap-noop.yaml

**Run with only Memory profiling enabled**:
Comment thread
sapatrjv marked this conversation as resolved.
Outdated
./target/profiling/df_engine.exe --config .\configs\otap-noop.yaml
Comment thread
sapatrjv marked this conversation as resolved.
Outdated

**Result**

Check failure on line 419 in rust/otap-dataflow/README.md

View workflow job for this annotation

GitHub Actions / markdownlint

Emphasis used instead of a heading

rust/otap-dataflow/README.md:419 MD036/no-emphasis-as-heading Emphasis used instead of a heading [Context: "Result"] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md036.md

On successful termination of df_engine.exe, it will generate dhat-heap.json file
Comment thread
sapatrjv marked this conversation as resolved.
Outdated
for Memory profiling that need to be rendered by uploading it to:
Comment thread
sapatrjv marked this conversation as resolved.
Outdated
https://nnethercote.github.io/dh_view/.

Check failure on line 423 in rust/otap-dataflow/README.md

View workflow job for this annotation

GitHub Actions / markdownlint

Bare URL used

rust/otap-dataflow/README.md:423:1 MD034/no-bare-urls Bare URL used [Context: "https://nnethercote.github.io/..."] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md034.md

CPU profiling output will be automatically renderd on browser.
Comment thread
sapatrjv marked this conversation as resolved.
Outdated

Note: dhat needs a clean shutdown to generate dhat-heap.json file. In df_engine

Check failure on line 427 in rust/otap-dataflow/README.md

View workflow job for this annotation

GitHub Actions / markdownlint

Trailing spaces

rust/otap-dataflow/README.md:427:80 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md009.md
this can be done manually with Ctrl-C.

## Contributing

- [Contribution Guidelines](CONTRIBUTING.md)
Expand Down
25 changes: 25 additions & 0 deletions rust/otap-dataflow/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ use otap_df_core_nodes as _;
use otap_df_otap::OTAP_PIPELINE_FACTORY;
use std::path::PathBuf;
use sysinfo::System;
use ctrlc;
#[cfg(feature = "dhat-heap")]
Comment thread
sapatrjv marked this conversation as resolved.
use {
once_cell::sync::Lazy,
std::sync::Mutex,
dhat::Profiler,
};

#[cfg(all(
not(windows),
Expand Down Expand Up @@ -288,7 +295,25 @@ fn validate_engine_components(
Ok(())
}

#[cfg(feature = "dhat-heap")]
Comment thread
sapatrjv marked this conversation as resolved.
Outdated
#[global_allocator]
static ALLOC: dhat::Alloc = dhat::Alloc; // 1. The actual allocator
Comment thread
sapatrjv marked this conversation as resolved.
Outdated
#[cfg(feature = "dhat-heap")]
static DHAT_PROFILER: Lazy<Mutex<Option<Profiler>>> = Lazy::new(|| Mutex::new(None));
fn main() -> Result<(), Box<dyn std::error::Error>> {
#[cfg(feature = "dhat-heap")]
ctrlc::set_handler(|| {
Comment thread
sapatrjv marked this conversation as resolved.
Outdated
if let Ok(mut guard) = DHAT_PROFILER.lock() {
// This triggers the drop and the file write
guard.take();
}
std::process::exit(130);
})?;
#[cfg(feature = "dhat-heap")]
{
let mut profiler = DHAT_PROFILER.lock().unwrap();
*profiler = Some(dhat::Profiler::new_heap());
}
Comment thread
sapatrjv marked this conversation as resolved.
Outdated
// Install the rustls crypto provider selected by the crypto-* feature flag.
// This must happen before any TLS connections (reqwest, tonic, etc.).
otap_df_otap::crypto::install_crypto_provider()
Expand Down
Loading