-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Nested diagnostics #9216
Comments
I've been wanting "categories" for diagnostics for awhile. I like that this takes that one step further by making it a "folder hierarchy". Seems useful / valuable, especially once we have UI to visualize things. The biggest downside of replacing DiagnosticId with DiagnosticPath is that we're doing string hashing of potentially long paths to look up and insert diagnostics. Across hundreds of of diagnostics produced once a frame (or more) that might start showing up meaningfully on benchmarks. Maybe we should have an "exchange" system where we have efficient dense runtime generated ids that you can look up and generate using paths. Core systems could do that lookup / store the dense index in the interest of efficiency. Then we could also have variants that do the look up / generation automatically for users that dont care / want quick results. |
Generally on board for this idea though! |
The downside is that we won't have const An alternative is to have pub struct DiagnosticPath {
components: SmallVec<[Cow<'static, str>; 4]>,
hash: u64,
} with a |
You don't need to "componentize" the path until displaying it. Since there is no meaningful data associated with non-terminal diagnostics beside the name. So there isn't much point in parsing/hashing individual components. Keeping If we want to replace |
If I understood you correctly, you propose replacing the list of path components by a single string (where path components are separated by "/")? I think it's a good idea.
The problem is, its cumbersome to allocate let pass_span = diagnostics.pass_span(&mut render_pass, view_light.pass_name.clone());
shadow_phase.render(...);
pass_span.end(&mut render_pass); Here
We could use |
# Objective Implements #9216 ## Solution - Replace `DiagnosticId` by `DiagnosticPath`. It's pre-hashed using `const-fnv1a-hash` crate, so it's possible to create path in const contexts. --- ## Changelog - Replaced `DiagnosticId` by `DiagnosticPath` - Set default history length to 120 measurements (2 seconds on 60 fps). I've noticed hardcoded constant 20 everywhere and decided to change it to `DEFAULT_MAX_HISTORY_LENGTH` , which is set to new diagnostics by default. To override it, use `with_max_history_length`. ## Migration Guide ```diff - const UNIQUE_DIAG_ID: DiagnosticId = DiagnosticId::from_u128(42); + const UNIQUE_DIAG_PATH: DiagnosticPath = DiagnosticPath::const_new("foo/bar"); - Diagnostic::new(UNIQUE_DIAG_ID, "example", 10) + Diagnostic::new(UNIQUE_DIAG_PATH).with_max_history_length(10) - diagnostics.add_measurement(UNIQUE_DIAG_ID, || 42); + diagnostics.add_measurement(&UNIQUE_DIAG_ID, || 42); ```
This should be closed now as #9266 has been merged |
What problem does this solve or what need does it fill?
bevy_diagnostic
should support arbitrarily nested trees like this:This would be very useful for #9135
What solution would you like?
I would imagine an API like this:
DiagnosticStore
now takeDiagnosticPath
instead ofDiagnosticId
.DiagnosticId
is removed in favor ofDiagnosticPath
. It already was painful to use due to UUIDs, especially when the names aren't known at runtime (which is the case for shadow passes)DiagnosticStore
What alternative(s) have you considered?
An alternative is to generate
DiagnosticId
using the hash of all path components, and setDiagnostic::name
to something likerender/prepass/elapsed_gpu
. This is error-prone and may cause collisions if a bad hash function is used.Future work
A plugin for displaying this tree would be nice. Until
bevy_ui
matures, this visualization could just show a textual representation (as shown above), rendered using a monospace font. In the future, collapsible tree entries and filters would be nice to have.The text was updated successfully, but these errors were encountered: