bevyengine / bevyengine/bevy

Prefix benchmark names with module path

Open
#16,647 4 comments 0 reactions 0 assignees View on GitHub
A-Cross-Cutting C-Benchmarks C-Code-Quality D-Straightforward S-Ready-For-Implementation
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

# Problem

I've slowly been returning to [`bevy-bencher`](https://github.com/TheBevyFlock/bevy-bencher), and am trying to migrate it to use Bevy's in-tree benchmarks instead of custom ones. One of the original issues I had with this approach is that it's difficult to see what a benchmark is testing from its name alone. For example:

- `layers_intersect`
- `entity_hash`
- `easing_1000`
- `param/combinator_system/8_piped_systems`
- `concrete_list_clone_dynamic`
- `ray_mesh_intersection/1000_vertices`
- `despawn_world_recursive/100_entities`
- `overhead_par_iter/threads_4`
- `run_condition/yes_using_resource`

All of these names were pulled from our current benchmarks, and are the names that would be displayed in Bencher's UI. Can you guess what each benchmark tracks specifically? Probably not, unless you're deeply familiar with that specific subsystem.

# Solution

Now look at the same list again, but with a few changes:

- `render::render_layers::intersect`
- `ecs::world::entity_hash`
- `math::bezier::easing_1000`
- `ecs::param::combinator_system::8_piped_systems`
- `reflect::list::concrete_clone_dynamic`
- `picking::ray_mesh_intersection/1000_vertices`
- `ecs::world::despawn_recursive/100_entities`
- `tasks::overhead_par_iter/threads_4`
- `ecs::scheduling::run_condition/yes_using_resource`

This naming scheme includes the module path in the benchmark name, and removes any redundant words from the benchmark name. There are a few benefits to this approach:

1. The name is far clearer on what is being tested.
2. It's easy to locate the benchmark from the name alone.
- With the name `render::render_layers::intersect`, you know the benchmark is within `bevy_render/render_layers.rs`.
3. You can easily filter benchmarks to run by category.
- For instance, you can run `cargo bench -- ecs::world` to run all `World`-related benchmarks.

## Automation

We can automate this naming a little bit using macros, specifically with [`module_path!()`](https://doc.rust-lang.org/stable/std/macro.module_path.html). For a quick sketch, you may be able to do this:

```rust
// I may have messed up this syntax, but you get the idea :)
macro_rules! bench {
($name:lit) => {
concat!(module_path!(), $name)
}
}

// Crate: `bevy_math`
mod bezier {
fn easing(c: &mut Criterion) {
// Name is `bevy_math::bezier::easing`.
c.bench_function(bench!("easing"), |b| {
// ...
});
}
}
```

Contributor guide

Open the contributing guide

Research direction

Start by inventorying the existing benchmarks and compare their names with the examples in the issue, including bevy_render/render_layers.rs and the bevy_math bezier module. Investigate the module_path!() macro sketch, then run cargo bench with a category filter such as ecs::world. Done means benchmark names consistently expose their module paths and remain easy to filter and locate.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.