wgpu/benches
Nicolas Silva 4c6318c0d2
Expose gpu allocation configuration options (#5875)
* Expose gpu allocation configuration options

This commit adds hints to control memory allocations strategies to the configuration options. These hints allow for automatic profiles such as optimizing for performance (the default, makes sense for a game), optimizing for memory usage (typically more useful for a web browser or UI library) and specifying settings manually.

The details of gpu allocation are still in flux. The goal is to switch vulkan and metal to gpu_allocator which is currently used with d3d12. gpu_allocator will also likely receive more configuration options, in particular the ability to start with smaller memory block sizes and progressively grow the block size. So the manual settings already provision for this upcoming option. Another approach could be to wait and add the manual option after the dust settles.

The reason for providing presets and defining values in the backends is that I am convinced that optimal fonigurations should take hardware capabilities into consideration. It's a deep rabbithole, though, so that will be an exercise for later.

* changelog

* Update CHANGELOG.md

Co-authored-by: Andreas Reich <r_andreas2@web.de>

* Add a comment about not entirely knowing what we are doing

---------

Co-authored-by: Andreas Reich <r_andreas2@web.de>
2024-07-08 14:49:44 +02:00
..
benches Expose gpu allocation configuration options (#5875) 2024-07-08 14:49:44 +02:00
Cargo.toml Add Benchmarks (#5694) 2024-05-16 09:05:41 -04:00
README.md Add Benchmarks (#5694) 2024-05-16 09:05:41 -04:00

Collection of CPU benchmarks for wgpu.

These benchmarks are designed as a first line of defence against performance regressions and generally approximate the performance for users. They all do very little GPU work and are testing the CPU performance of the API.

Criterion will give you the end-to-end performance of the benchmark, but you can also use a profiler to get more detailed information about where time is being spent.

Usage

# Run all benchmarks
cargo bench -p wgpu-benchmark
# Run a specific benchmarks that contains "filter" in its name
cargo bench -p wgpu-benchmark -- "filter"

Benchmarks

Renderpass

This benchmark measures the performance of recording and submitting a render pass with a large number of draw calls and resources, emulating an intense, more traditional graphics application. By default it measures 10k draw calls, with 90k total resources.

Within this benchmark, both single threaded and multi-threaded recording are tested, as well as splitting the render pass into multiple passes over multiple command buffers.

Resource Creation

This benchmark measures the performance of creating large resources. By default it makes buffers that are 256MB. It tests this over a range of thread counts.

Shader Compilation

This benchmark measures the performance of naga parsing, validating, and generating shaders.

Comparing Against a Baseline

To compare the current benchmarks against a baseline, you can use the --save-baseline and --baseline flags.

For example, to compare v0.20 against trunk, you could run the following:

git checkout v0.20

# Run the baseline benchmarks
cargo bench -p wgpu-benchmark -- --save-baseline "v0.20"

git checkout trunk

# Run the current benchmarks
cargo bench -p wgpu-benchmark -- --baseline "v0.20"

You can use this for any bits of code you want to compare.

Integration with Profilers

The benchmarks can be run with a profiler to get more detailed information about where time is being spent. Integrations are available for tracy and superluminal. Due to some implementation details, you need to uncomment the features in the Cargo.toml to allow features to be used.

Tracy

Tracy is available prebuilt for Windows on github.

# Once this is running, you can connect to it with the Tracy Profiler
cargo bench -p wgpu-benchmark --features tracy

Superluminal

Superluminal is a paid product for windows available here.

# This command will build the benchmarks, and display the path to the executable
cargo bench -p wgpu-benchmark --features superluminal -- -h

# Have Superluminal run the following command (replacing with the path to the executable)
./target/release/deps/root-2c45d61b38a65438.exe --bench "filter"

perf and others

You can follow the same pattern as above to run the benchmarks with other profilers. For example, the command line tool perf can be used to profile the benchmarks.

# This command will build the benchmarks, and display the path to the executable
cargo bench -p wgpu-benchmark -- -h

# Run the benchmarks with perf
perf record ./target/release/deps/root-2c45d61b38a65438 --bench "filter"