Skip to content

Commit 07544ea

Browse files
authored
Merge pull request #28 from arielb1/less-flaky
increase the number of threads in slow example to reduce flakiness
2 parents 518f45e + d7fcda0 commit 07544ea

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
test:
8484
name: Integration Test
8585
runs-on: ubuntu-latest
86-
needs: [build, build-for-testing, build-decoder, build-async-profiler]
86+
needs: [build-for-testing, build-decoder, build-async-profiler]
8787
steps:
8888
- uses: actions/checkout@v4
8989
- name: Download pollcatch-decoder

examples/simple/main.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,33 @@ struct Args {
5151
#[arg(long, default_value = "30s")]
5252
#[clap(value_parser = humantime::parse_duration)]
5353
reporting_interval: Duration,
54+
#[arg(long)]
55+
worker_threads: Option<usize>,
5456
}
5557

5658
#[allow(unexpected_cfgs)]
5759
pub fn main() -> anyhow::Result<()> {
60+
let args = Args::parse();
61+
5862
let mut rt: tokio::runtime::Builder = tokio::runtime::Builder::new_multi_thread();
5963
rt.enable_all();
64+
if let Some(worker_threads) = args.worker_threads {
65+
rt.worker_threads(worker_threads);
66+
}
6067

6168
#[cfg(tokio_unstable)]
6269
{
6370
rt.on_before_task_poll(|_| async_profiler_agent::pollcatch::before_poll_hook())
6471
.on_after_task_poll(|_| async_profiler_agent::pollcatch::after_poll_hook());
6572
}
6673
let rt = rt.build().unwrap();
67-
rt.block_on(main_internal())
74+
rt.block_on(main_internal(args))
6875
}
6976

70-
async fn main_internal() -> Result<(), anyhow::Error> {
77+
async fn main_internal(args: Args) -> Result<(), anyhow::Error> {
7178
set_up_tracing();
7279
tracing::info!("main started");
7380

74-
let args = Args::parse();
75-
7681
let profiler = ProfilerBuilder::default();
7782

7883
let profiler = match (

tests/integration.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ set -exuo pipefail
99

1010
mkdir -p profiles
1111
rm -f profiles/*.jfr
12-
./simple --local profiles --duration 60s --reporting-interval 15s
12+
# Pass --worker-threads 16 to make the test much less flaky since there is always some worker thread running
13+
./simple --local profiles --duration 60s --reporting-interval 15s --worker-threads 16
1314
for profile in profiles/*.jfr; do
1415
short_sleeps_100=$(./pollcatch-decoder longpolls --stack-depth=10 "$profile" 100us | ( grep -c short_sleep_2 || true ))
1516
short_sleeps_1000=$(./pollcatch-decoder longpolls --stack-depth=10 "$profile" 1000us | ( grep -c short_sleep_2 || true ))

0 commit comments

Comments
 (0)