Skip to content

Instrument asset loading and processing.#12988

Merged
alice-i-cecile merged 1 commit intobevyengine:mainfrom
chescock:instrument-asset-loading
Apr 16, 2024
Merged

Instrument asset loading and processing.#12988
alice-i-cecile merged 1 commit intobevyengine:mainfrom
chescock:instrument-asset-loading

Conversation

@chescock
Copy link
Contributor

Objective

As described in #12467, Bevy does not have any spans for any of the tasks scheduled onto the IO and async compute task pools.

Solution

Instrument all asset loads and asset processing. Since this change is restricted to asset tasks, it does not completely solve #12467, but it does mean we can record the asset path in the trace.

image


Changelog

Tracing will now include spans for asset loading and asset processing.

@alice-i-cecile alice-i-cecile added A-Assets Load files from disk to use for things like images, models, and sounds A-Diagnostics Logging, crash handling, error reporting and performance analysis labels Apr 16, 2024
@james7132 james7132 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 Apr 16, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Apr 16, 2024
Merged via the queue into bevyengine:main with commit e3f55d6 Apr 16, 2024
github-merge-queue bot pushed a commit that referenced this pull request Dec 22, 2025
…t keep the instrumentation. (#22213)

# Objective

- In #12988, we added tracing spans to asset loading and processing, by
creating wrapper structs `InstrumentedAssetLoader` and
`InstrumentedAssetProcessor`.
- Unfortunately, this causes an issue where
`ErasedAssetLoader::{default_meta, type_path}` and
`ErasedProcessor::default_meta` can return the wrong type path when
using the `trace` feature, and this type path could be written into a
meta file, which will be rendered unloadable/unprocessable.
- Note even though the loader/processor's type use to have the
instrumentation wrapper, when registering the loader/processor, we would
actually register the loader/processor under the original type names. So
you could still load non-`trace` written meta files, but `trace` written
meta files would fail to load whether `trace` was enabled or not!

## Solution

- Remove the wrapper loader/processor and instead just create the spans
at the callsites. I checked and there's a single callsite of `load` and
a single callsite of `process` - very good!
- I also added testing that was omitted in #17216 (due to missing test
utilities which have since been added). This is how I found out about
this problem! Score one for testing.

## Testing

- We still produce spans in the `asset_processing` example for both
loading and processing.

Note: We don't need a migration guide since users should really not be
using these directly, and any meta files using these would just be
broken.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Assets Load files from disk to use for things like images, models, and sounds A-Diagnostics Logging, crash handling, error reporting and performance analysis S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants