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

Benchmarking #1729

Merged
merged 7 commits into from
Feb 17, 2022
Merged

Benchmarking #1729

merged 7 commits into from
Feb 17, 2022

Conversation

kvark
Copy link
Member

@kvark kvark commented Feb 16, 2022

Integrates Criterion and also adds support for bincode-encoded IR form. The purpose here is to see the upper bound for shader loading performance. Today, bincode IR deserialization is roughly 7x faster than WGSL parsing.

@kvark kvark requested a review from jimblandy February 16, 2022 02:48
@kvark
Copy link
Member Author

kvark commented Feb 16, 2022

Results from my machine:

Gnuplot not found, using plotters backend
front/bin               time:   [143.70 us 146.65 us 149.74 us]                      
Found 4 outliers among 100 measurements (4.00%)
  3 (3.00%) high mild
  1 (1.00%) high severe
Benchmarking front/wgsl: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 5.7s, enable flat sampling, or reduce sample count to 60.
front/wgsl              time:   [1.1065 ms 1.1268 ms 1.1453 ms]                        
front/spv               time:   [56.855 us 58.214 us 59.836 us]                      
Found 14 outliers among 100 measurements (14.00%)
  5 (5.00%) high mild
  9 (9.00%) high severe
front/glsl              time:   [3.7642 ms 3.8215 ms 3.8864 ms]                        
Found 11 outliers among 100 measurements (11.00%)
  5 (5.00%) high mild
  6 (6.00%) high severe

valid/safe              time:   [122.50 us 123.12 us 123.97 us]                       
Found 2 outliers among 100 measurements (2.00%)
  2 (2.00%) high severe
valid/unsafe            time:   [86.239 us 86.530 us 86.842 us]                         
Found 2 outliers among 100 measurements (2.00%)
  1 (1.00%) high mild
  1 (1.00%) high severe

back/wgsl               time:   [637.90 us 640.21 us 642.65 us]                      
back/spv                time:   [402.15 us 403.86 us 405.86 us]                     
Found 5 outliers among 100 measurements (5.00%)
  2 (2.00%) high mild
  3 (3.00%) high severe
back/spv-separate       time:   [323.96 us 324.86 us 325.73 us]                              
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high severe
back/msl                time:   [895.71 us 900.71 us 906.08 us]                     
Found 3 outliers among 100 measurements (3.00%)
  3 (3.00%) high mild
back/hlsl               time:   [774.44 us 778.98 us 784.89 us]                      
Found 4 outliers among 100 measurements (4.00%)
  1 (1.00%) high mild
  3 (3.00%) high severe
back/glsl-separate      time:   [930.78 us 932.80 us 934.88 us]                               
Found 6 outliers among 100 measurements (6.00%)
  3 (3.00%) high mild
  3 (3.00%) high severe

Copy link
Member

@jimblandy jimblandy left a comment

Choose a reason for hiding this comment

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

Looks good!

I think we should do better with feature handling; see comments.

.github/workflows/pipeline.yml Outdated Show resolved Hide resolved
.unwrap();
for file_entry in read_dir {
match file_entry {
Ok(entry) => match entry.path().extension() {
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't this just be:

Ok(entry) => if entry.path().extension() == extension {
    ...
}

?

Copy link
Member Author

Choose a reason for hiding this comment

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

That would require some shenanigans on going from OSStr to str to be able to compare them

benches/criterion.rs Outdated Show resolved Hide resolved
Comment on lines +108 to +114
#[cfg(not(feature = "wgsl-in"))]
fn gather_modules() -> Vec<naga::Module> {
Vec::new()
}
Copy link
Member

Choose a reason for hiding this comment

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

It's a little confusing that when necessary features aren't available, we do still run benchmarks and get meaningless numbers. The loop over the modules is inside the b.iter call, not outside it. It would be clearer to somehow just not run benchmarks that require features we don't have.

Copy link
Member Author

Choose a reason for hiding this comment

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

that's a bit of an edge case. We don't really care about the numbers when features aren't enabled. What I did was a minimal thing to make it compile for these cases

.collect::<Vec<_>>()
};
#[cfg(not(feature = "validate"))]
let inputs = Vec::<(naga::Module, naga::valid::ModuleInfo)>::new();
Copy link
Member

Choose a reason for hiding this comment

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

Again, we shouldn't run benchmarks on empty input lists because a feature was turned off.

Copy link
Member Author

Choose a reason for hiding this comment

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

similar reasoning to the last one - this is the minimal change to compile

src/front/wgsl/mod.rs Outdated Show resolved Hide resolved
@kvark
Copy link
Member Author

kvark commented Feb 17, 2022

Thanks for the review! Some of the notes are addressed, other left for follow-ups

@kvark kvark enabled auto-merge (rebase) February 17, 2022 14:47
@kvark kvark merged commit 8fd8e7d into gfx-rs:master Feb 17, 2022
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.

2 participants