Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backend-comparison] Rework burnbench output to be nicer and more compact #1568

Merged
merged 12 commits into from Apr 3, 2024

Conversation

syl20bnr
Copy link
Member

@syl20bnr syl20bnr commented Apr 1, 2024

To be merged after: #1567

Pull Request Template

Checklist

  • Confirmed that run-checks all script has been executed.
  • Made sure the book is up to date with changes in this PR.

Related Issues/PRs

n/a

Changes

Add a --verbose parameter which corresponds to normal output of cargo build and cargo bench commands.

By default (i.e. without the --verbose flag) a progress bar with status is displayed instead of just plain logs. The failed benchmarks are also now added in the reports.

Progress Bar:

image

Results OK:

image

image

Results with failure:

image

Testing

cargo run --release --bin burnbench -- run --benches unary binary --backends wgpu ndarray-blas-accelerate wgpu-fusion --share

Copy link

codecov bot commented Apr 1, 2024

Codecov Report

Attention: Patch coverage is 0% with 307 lines in your changes are missing coverage. Please review.

Project coverage is 86.34%. Comparing base (0978c8a) to head (98733d4).

Files Patch % Lines
backend-comparison/src/burnbenchapp/reports.rs 0.00% 92 Missing ⚠️
backend-comparison/src/burnbenchapp/runner.rs 0.00% 79 Missing ⚠️
backend-comparison/src/burnbenchapp/progressbar.rs 0.00% 70 Missing ⚠️
backend-comparison/src/burnbenchapp/base.rs 0.00% 66 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1568      +/-   ##
==========================================
- Coverage   86.53%   86.34%   -0.19%     
==========================================
  Files         684      686       +2     
  Lines       78248    78418     +170     
==========================================
  Hits        67713    67713              
- Misses      10535    10705     +170     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Base automatically changed from feat/add-all-choice-to-burnbench to main April 2, 2024 13:27
Comment on lines 148 to 149
// let total_combinations = backends.len() * benches.len();
// println!("Running {} benchmark(s)...\n", total_combinations);
Copy link
Member

Choose a reason for hiding this comment

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

Dead code?

Comment on lines 173 to 181
for bench in benches.iter() {
for backend in backends.iter() {
let bench_str = bench.to_string();
let backend_str = backend.to_string();
println!(
"{}Benchmarking {} on {}{}",
filler, bench_str, backend_str, filler
);
let url = format!("{}benchmarks", super::USER_BENCHMARK_SERVER_URL);
let nice_processor: Option<Arc<NiceProcessor>> = runner_pb.clone().map(|pb| {
Arc::new(NiceProcessor::new(
bench_str.clone(),
backend_str.clone(),
Copy link
Member

Choose a reason for hiding this comment

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

Would it be possible to refactor the inside of the two for loops into another function? That would be easier to read.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Comment on lines 85 to 97
#[derive(Clone, Default)]
struct CountTracker {
pub failed: u64,
pub succeeded: u64,
}

#[derive(Clone)]
struct ThreadSafeTracker {
inner: Arc<Mutex<CountTracker>>,
}
Copy link
Member

Choose a reason for hiding this comment

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

I would use two AtomicU64 instead of locking, though I'm unsure why we need inner mutability here.

Copy link
Member Author

@syl20bnr syl20bnr Apr 3, 2024

Choose a reason for hiding this comment

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

That's a bit more complicated than that but maybe I am mistaken.

I need to pass the tracker down to progress bar style but I also need to pass it to my runner so it can update its state. I tried with an Arc like that:

pub(crate) struct RunnerProgressBar {
    pb: ProgressBar,
    tracker: Arc<Mutex<CountTracker>>,
}

impl RunnerProgressBar {
    pub(crate) fn new(total: u64) -> Self {
        let tracker = Arc::new(Mutex::new(CountTracker::default()));
        let pb = ProgressBar::new(total);
        pb.set_style(
            ProgressStyle::default_spinner()
                .template("\n{msg}\n{spinner}{wide_bar:.yellow/red} {pos}/{len} {counter}\n ")
                .unwrap()
                .with_key("counter", tracker.clone())
                .progress_chars("▬▬―")
                .tick_strings(&[
                    "🕛 ", "🕐 ", "🕑 ", "🕒 ", "🕓 ", "🕔 ", "🕕 ", "🕖 ", "🕗 ", "🕘 ", "🕙 ",
                    "🕚 ",
                ]),
        );
        Self {
            pb,
            tracker: tracker.clone(),
        }
    }

But then the Tracker trait is not implemented for the Arc'd CountTracker type and did not find an easy way to do it so I wrapped it.

Thinking about it, maybe I can avoid owning the tracker at the runner level if the indicatif interface gives me access to the tracker somehow. I'll take a look at this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I refactored the tracker and use a ref counted Atomic64. Pretty happy about it, thank you for the suggestion. It is much cleaner. Note that I used the weakest form of ordering as I am not familiar with the concept yet and atomicity only seems to just fined.

backend-comparison/src/burnbenchapp/progressbar.rs Outdated Show resolved Hide resolved
backend-comparison/src/burnbenchapp/runner.rs Outdated Show resolved Hide resolved
backend-comparison/src/burnbenchapp/runner.rs Outdated Show resolved Hide resolved
@syl20bnr
Copy link
Member Author

syl20bnr commented Apr 3, 2024

@nathanielsimard ready for another round.

Copy link
Member

@nathanielsimard nathanielsimard left a comment

Choose a reason for hiding this comment

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

LGTM

@syl20bnr syl20bnr merged commit 9a14597 into main Apr 3, 2024
15 checks passed
@syl20bnr syl20bnr deleted the feat/nice-burnbench-output branch April 3, 2024 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants