Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ jobs:
- name: Run integration test
shell: bash
working-directory: tests
run: chmod +x simple pollcatch-decoder && LD_LIBRARY_PATH=$PWD ./integration.sh
run: chmod +x simple pollcatch-decoder && LD_LIBRARY_PATH=$PWD ./integration.sh && LD_LIBRARY_PATH=$PWD ./separate_runtime_integration.sh
Copy link
Collaborator

Choose a reason for hiding this comment

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

for ease of debugging we might want two separate targets / steps

Copy link
Contributor Author

@arielb1 arielb1 Sep 25, 2025

Choose a reason for hiding this comment

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

Feels overcomplicated to me. If we have a problem with a big step, we can always split it.

39 changes: 28 additions & 11 deletions examples/simple/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ struct S3BucketArgs {
}

/// Simple program to test the profiler agent
///
/// This program is intended for test purposes ONLY.
#[derive(Debug, Parser)]
#[command(group(
ArgGroup::new("options")
Expand All @@ -62,6 +64,9 @@ struct Args {
worker_threads: Option<usize>,
#[arg(long)]
native_mem: Option<String>,
/// Use the spawn_thread API instead of the Tokio API (does not demonstrate stopping)
#[arg(long)]
spawn_into_thread: bool,
}

impl Args {
Expand Down Expand Up @@ -95,6 +100,16 @@ pub fn main() -> anyhow::Result<()> {
rt.block_on(main_internal(args))
}

async fn run_slow(args: &Args) {
if let Some(timeout) = args.duration {
tokio::time::timeout(timeout, slow::run())
.await
.unwrap_err();
} else {
slow::run().await;
}
}

async fn main_internal(args: Args) -> Result<(), anyhow::Error> {
set_up_tracing();
tracing::info!("main started");
Expand Down Expand Up @@ -133,19 +148,21 @@ async fn main_internal(args: Args) -> Result<(), anyhow::Error> {
.with_profiler_options(profiler_options)
.build();

tracing::info!("starting profiler");
let handle = profiler.spawn_controllable()?;
tracing::info!("profiler started");

if let Some(timeout) = args.duration {
tokio::time::timeout(timeout, slow::run())
.await
.unwrap_err();
if args.spawn_into_thread {
tracing::info!("starting profiler");
std::thread::spawn(move || {
profiler.spawn_thread().unwrap();
});
run_slow(&args).await;
} else {
slow::run().await;
}
tracing::info!("starting profiler");
let handle = profiler.spawn_controllable()?;
tracing::info!("profiler started");

handle.stop().await;
run_slow(&args).await;

handle.stop().await;
}

Ok(())
}
Loading
Loading