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

Replace DiagnosticId by DiagnosticPath #9266

Merged
merged 5 commits into from
Jan 20, 2024

Conversation

LeshaInc
Copy link
Contributor

@LeshaInc LeshaInc commented Jul 24, 2023

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

- 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);

@alice-i-cecile alice-i-cecile added C-Usability A targeted quality-of-life change that makes Bevy easier to use A-Diagnostics Logging, crash handling, error reporting and performance analysis labels Jul 24, 2023
@JMS55 JMS55 requested review from mockersf and JMS55 August 15, 2023 06:24
@JMS55 JMS55 added this to the 0.12 milestone Aug 27, 2023
@alice-i-cecile alice-i-cecile removed this from the 0.12 milestone Sep 30, 2023
@JMS55 JMS55 added this to the 0.13 milestone Oct 28, 2023
@alice-i-cecile
Copy link
Member

Hey, can you resolve merge conflicts? I'd like to get this in and at first glance this seems well-made.

@LeshaInc
Copy link
Contributor Author

I've resolved merge conflicts. Examples seem to work.

}

/// Create a new `DiagnosticPath` from an iterator over components.
pub fn from_components<'a>(components: impl IntoIterator<Item = &'a str>) -> DiagnosticPath {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: can we swap "components" here to "parts" to be less confusing in a Bevy context?

Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest from_sections

@alice-i-cecile alice-i-cecile added the C-Breaking-Change A breaking change to Bevy's public API that needs to be noted in a migration guide label Jan 19, 2024
@matiqo15 matiqo15 added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Jan 20, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 20, 2024
Merged via the queue into bevyengine:main with commit 320ac65 Jan 20, 2024
28 checks passed
This was referenced Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Diagnostics Logging, crash handling, error reporting and performance analysis C-Breaking-Change A breaking change to Bevy's public API that needs to be noted in a migration guide C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants