bevy-diagnostics-profiling
Skill29 starsChanged 11 days agoMITView on GitHub
Use when profiling Bevy 0.20 with `DiagnosticPath`, `DiagnosticsStore`, `info_span!`, `RenderDiagnosticsPlugin`, or the `RenderDebugOverlay`: custom metrics, CPU/GPU pass timings, queue/task/upload telemetry, stale-result counts, and native, Steam Deck, or WebGPU budgets.
In this repository34 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- bevy-a11ySkill
- bevy-animationSkill
- bevy-assetsSkill
- bevy-audioSkill
- bevy-camerasSkill
- bevy-captureSkill
- bevy-cargo-featuresSkill
- bevy-core-conceptsSkill
- bevy-custom-assetsSkill
- bevy-ecs-componentsSkill
- bevy-ecs-queriesSkill
- bevy-ecs-systemsSkill
- bevy-fluentSkill
- bevy-input-actionsSkill
- bevy-migration-0-17-to-0-18Skill
- bevy-migration-0-18-to-0-19Skill
- bevy-migration-0-19-to-0-20Skill
- bevy-pbr-materialsSkill
- bevy-physicsSkill
- bevy-portingSkill
- bevy-renderingSkill
- bevy-save-loadSkill
- bevySkill
- bevy-testingSkill
- bevy-uiSkill
- bevy-vfxSkill
- bevy-voxel-dataSkill
- bevy-voxel-pipelineSkill
- bevy-voxel-runtimeSkill
- bevy-wasm-webgpuSkill
- similarity-rsSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 23
Use all three, but do not treat any one of them as proof of a bottleneck.
- Very specific: line 82
Add RenderDiagnosticsPlugin from bevy::render::diagnostic.
- Distinctive: line 107
Avoid high-cardinality span names and per-element spans.
- Very specific: line 139
Every number has a type (gauge/counter/histogram), unit, scope, and sampling rule.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Bevy 0.20 — diagnostics and profiling
When to use this skill
- A frame, render pass, worker pipeline, or upload path needs causal evidence.
- A queue/task system needs stable gauges, counters, latency, and high-water marks.
- Performance claims must pass native, Steam Deck, or browser acceptance budgets.
- Render GPU diagnostics are absent or disagree with CPU traces.
Diagnostics answer “what is happening over time?” Tracing answers “where did this execution spend time?” Render diagnostics expose pass-level renderer measurements. Use all three, but do not treat any one of them as proof of a bottleneck.
Canonical pattern
use bevy::{
diagnostic::{
Diagnostic, DiagnosticPath, Diagnostics, RegisterDiagnostic,
},
prelude::*,
};
const REMESH_QUEUE_DEPTH: DiagnosticPath =
DiagnosticPath::const_new("voxel/remesh_queue_depth");
#[derive(Resource, Default)]
struct RemeshQueue {
valid_jobs: usize,
}
struct VoxelDiagnosticsPlugin;
impl Plugin for VoxelDiagnosticsPlugin {
fn build(&self, app: &mut App) {
app.init_resource::<RemeshQueue>()
.register_diagnostic(
Diagnostic::new(REMESH_QUEUE_DEPTH).with_suffix(" sections"),
)
.add_systems(Update, record_voxel_diagnostics);
}
}
fn record_voxel_diagnostics(
queue: Res<RemeshQueue>,
mut diagnostics: Diagnostics,
) {
diagnostics.add_measurement(&REMESH_QUEUE_DEPTH, || queue.valid_jobs as f64);
}Paths are an API: use namespaced, stable names with explicit units in suffixes or
documentation. Register before recording. DiagnosticsStore provides latest and
historical/smoothed values for displays and exporters. Measurements are deferred
telemetry, not a same-system synchronisation mechanism.
Built-in plugins
FrameTimeDiagnosticsPlugin: FPS, frame time, and frame count.EntityCountDiagnosticsPlugin: live entity count.SystemInformationDiagnosticsPlugin: process/system CPU and memory on supported native targets. It is unavailable/no-op for WASM, iOS, and dynamic-link builds.LogDiagnosticsPlugin: development output; filter paths and cadence to avoid noise.RenderDiagnosticsPlugin: CPU/GPU time per recorded render span and pipeline statistics where the backend supports them.RenderDebugOverlayPlugin(0.20): on-screen render debug overlay, inDefaultPluginsunder thedevfeature (bevy_dev_tools+render_dev_tools). Off untilRenderDebugOverlayKeybindings { enable_keybindings: true, .. }is inserted; F1 cycles mode, F2 cycles opacity.
Add RenderDiagnosticsPlugin from bevy::render::diagnostic. It creates dynamic
paths shaped like render/<span>/elapsed_cpu and, when supported,
render/<span>/elapsed_gpu plus invocation/primitive statistics.
Tracing for causality
Enable a backend in an optimised build:
cargo run --release --features bevy/trace_tracy
cargo run --release --features bevy/trace_chrometrace_tracy_memory adds allocation tracking with extra overhead. Add coarse spans
around work whose cause matters:
use bevy::prelude::*;
fn rebuild_visible_sections() {
let _span = info_span!("rebuild_visible_sections").entered();
// measured work
}Avoid high-cardinality span names and per-element spans. Record section/entity IDs as fields only during targeted captures. Keep a low-overhead diagnostic gauge/counter for continuous observability and switch on detailed traces for investigation.
Gotchas and platform truth
- 0.19→0.20:
Render,RenderGraph, andCore3dsets order withchain_weak. A diagnostic-recording render system that relied on an earlier set finishing via a channel or atomic needs an explicit.after(system). tracingis not a direct dependency: writebevy::log::tracing::field::Empty.- Stale output imports
RenderDebugOverlayPluginwithout thedevfeature; thebevy::dev_toolsmodule does not exist withoutbevy_dev_tools.
Bevy 0.20 render timestamp queries and pipeline statistics are supported on Vulkan
and DX12. Metal, WebGPU, and WebGL2 expose CPU render timings only through
RenderDiagnosticsPlugin. Missing elapsed_gpu is an unsupported measurement, not
zero GPU cost. Use vendor/platform GPU profilers where available; RenderDoc is a
graphics debugger, not a performance profiler.
Profile the shipping renderer, resolution, power mode, content, and build profile. Desktop results do not establish Steam Deck or browser budgets.
Choose the relevant deep dive
| Problem | Read |
| Metric types, stable paths, diagnostics store, tracing spans | Diagnostics and tracing |
| Render diagnostics, backend limitations, CPU/GPU tool choice | Render and platform profiling |
| Acceptance thresholds, replay design, queue/task/upload telemetry | Budgets and telemetry |
Review checklist
- Every number has a type (gauge/counter/histogram), unit, scope, and sampling rule.
- Queue depth excludes obsolete heap entries; latency timestamps use one clock.
- Spans cover queue wait, worker compute, main-thread apply, and render/upload costs.
- Captures are release-like, repeatable, warm, and made on each claimed target.
- Reports include percentiles and worst sustained intervals, not averages alone.
- Unsupported GPU values remain absent and are never converted to zero.
- Instrumentation overhead is measured and disabled/reduced in normal shipping runs.
See also
bevy-voxel-runtime— concrete queue, stale-result, and upload metrics.bevy-rendering— renderer architecture and custom render systems.bevy-testing— deterministic benchmark replays and visual captures.bevy-migration-0-19-to-0-20— weak ordering and render-world renames.- Bevy diagnostics
- Bevy render diagnostics
- Bevy 0.20 profiling guide
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

