From 532f87b2b7927bf38f61990ae8a991b35f14a0fb Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Wed, 31 May 2023 09:02:38 +0200 Subject: [PATCH 1/4] introduce re_tracing --- Cargo.lock | 30 +++++++++++++++++++----------- Cargo.toml | 1 + crates/re_tracing/Cargo.toml | 21 +++++++++++++++++++++ crates/re_tracing/README.md | 10 ++++++++++ crates/re_tracing/src/lib.rs | 23 +++++++++++++++++++++++ 5 files changed, 74 insertions(+), 11 deletions(-) create mode 100644 crates/re_tracing/Cargo.toml create mode 100644 crates/re_tracing/README.md create mode 100644 crates/re_tracing/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index d4ef75b75afd..64724a45337c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3863,12 +3863,12 @@ dependencies = [ "parking_lot 0.12.1", "polars-core", "polars-ops", - "puffin", "rand", "re_components", "re_format", "re_log", "re_log_types", + "re_tracing", "smallvec", "thiserror", "tinyvec", @@ -3916,10 +3916,10 @@ dependencies = [ "lazy_static", "ndarray", "nohash-hasher", - "puffin", "rand", "re_log", "re_log_types", + "re_tracing", "rmp-serde", "serde", "similar-asserts", @@ -3949,7 +3949,6 @@ dependencies = [ "itertools", "mimalloc", "nohash-hasher", - "puffin", "rand", "re_arrow_store", "re_components", @@ -3959,6 +3958,7 @@ dependencies = [ "re_log_encoding", "re_log_types", "re_smart_channel", + "re_tracing", "serde", "thiserror", ] @@ -3974,7 +3974,6 @@ dependencies = [ "image", "itertools", "nohash-hasher", - "puffin", "re_arrow_store", "re_components", "re_data_store", @@ -3984,6 +3983,7 @@ dependencies = [ "re_log_types", "re_query", "re_renderer", + "re_tracing", "re_ui", "re_viewer_context", "rfd", @@ -4041,13 +4041,13 @@ dependencies = [ "lz4_flex", "mimalloc", "parking_lot 0.12.1", - "puffin", "re_build_info", "re_components", "re_error", "re_log", "re_log_types", "re_smart_channel", + "re_tracing", "rmp-serde", "serde_test", "thiserror", @@ -4071,10 +4071,10 @@ dependencies = [ "nohash-hasher", "num-derive", "num-traits", - "puffin", "re_format", "re_log", "re_string_interner", + "re_tracing", "re_tuid", "rmp-serde", "serde", @@ -4118,13 +4118,13 @@ dependencies = [ "itertools", "mimalloc", "polars-core", - "puffin", "re_arrow_store", "re_components", "re_data_store", "re_format", "re_log", "re_log_types", + "re_tracing", "thiserror", ] @@ -4158,10 +4158,10 @@ dependencies = [ "parking_lot 0.12.1", "pathdiff", "pollster", - "puffin", "rand", "re_error", "re_log", + "re_tracing", "serde", "slotmap", "smallvec", @@ -4255,18 +4255,25 @@ version = "0.7.0-alpha.0" dependencies = [ "egui", "itertools", - "puffin", "re_arrow_store", "re_data_store", "re_data_ui", "re_format", "re_log_types", + "re_tracing", "re_ui", "re_viewer_context", "serde", "vec1", ] +[[package]] +name = "re_tracing" +version = "0.7.0-alpha.0" +dependencies = [ + "puffin", +] + [[package]] name = "re_tuid" version = "0.7.0-alpha.0" @@ -4334,6 +4341,7 @@ dependencies = [ "re_renderer", "re_smart_channel", "re_time_panel", + "re_tracing", "re_ui", "re_viewer_context", "re_viewport", @@ -4365,7 +4373,6 @@ dependencies = [ "macaw", "ndarray", "nohash-hasher", - "puffin", "re_arrow_store", "re_components", "re_data_store", @@ -4373,6 +4380,7 @@ dependencies = [ "re_log_types", "re_query", "re_renderer", + "re_tracing", "re_ui", "serde", "slotmap", @@ -4403,7 +4411,6 @@ dependencies = [ "macaw", "ndarray", "nohash-hasher", - "puffin", "re_arrow_store", "re_components", "re_data_store", @@ -4415,6 +4422,7 @@ dependencies = [ "re_query", "re_renderer", "re_tensor_ops", + "re_tracing", "re_ui", "re_viewer_context", "serde", diff --git a/Cargo.toml b/Cargo.toml index 2074f50993c8..c80f44e6a326 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,6 +47,7 @@ re_smart_channel = { path = "crates/re_smart_channel", version = "0.7.0-alpha.0" re_string_interner = { path = "crates/re_string_interner", version = "0.7.0-alpha.0", default-features = false } re_tensor_ops = { path = "crates/re_tensor_ops", version = "0.7.0-alpha.0", default-features = false } re_time_panel = { path = "crates/re_time_panel", version = "=0.7.0-alpha.0", default-features = false } +re_tracing = { path = "crates/re_tracing", version = "0.7.0-alpha.0", default-features = false } re_tuid = { path = "crates/re_tuid", version = "0.7.0-alpha.0", default-features = false } re_ui = { path = "crates/re_ui", version = "0.7.0-alpha.0", default-features = false } re_viewer = { path = "crates/re_viewer", version = "0.7.0-alpha.0", default-features = false } diff --git a/crates/re_tracing/Cargo.toml b/crates/re_tracing/Cargo.toml new file mode 100644 index 000000000000..a6b95b895884 --- /dev/null +++ b/crates/re_tracing/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "re_tracing" +authors.workspace = true +description = "Helpers for tracing/spans/flamegraphs and such." +edition.workspace = true +homepage.workspace = true +include.workspace = true +license.workspace = true +publish = true +readme = "README.md" +repository.workspace = true +rust-version.workspace = true +version.workspace = true + + +[package.metadata.docs.rs] +all-features = true + + +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +puffin.workspace = true diff --git a/crates/re_tracing/README.md b/crates/re_tracing/README.md new file mode 100644 index 000000000000..6079205ca9ad --- /dev/null +++ b/crates/re_tracing/README.md @@ -0,0 +1,10 @@ +# re_tracing + +Part of the [`rerun`](https://github.com/rerun-io/rerun) family of crates. + +[![Latest version](https://img.shields.io/crates/v/re_tracing.svg)](https://crates.io/crates/re_tracing) +[![Documentation](https://docs.rs/re_tracing/badge.svg)](https://docs.rs/re_tracing) +![MIT](https://img.shields.io/badge/license-MIT-blue.svg) +![Apache](https://img.shields.io/badge/license-Apache-blue.svg) + +Helpers for tracing/spans/flamegraphs and such. diff --git a/crates/re_tracing/src/lib.rs b/crates/re_tracing/src/lib.rs new file mode 100644 index 000000000000..dfa0d7237ef8 --- /dev/null +++ b/crates/re_tracing/src/lib.rs @@ -0,0 +1,23 @@ +//! Helpers for tracing/spans/flamegraphs and such. + +pub mod reexports { + pub use puffin; +} + +/// Wrapper around puffin profiler on native, no-op on wasm. +#[macro_export] +macro_rules! profile_function { + ($($arg: tt)*) => { + #[cfg(not(target_arch = "wasm32"))] + $crate::reexports::puffin::profile_function!($($arg)*); + }; +} + +/// Wrapper around puffin profiler on native, no-op on wasm. +#[macro_export] +macro_rules! profile_scope { + ($($arg: tt)*) => { + #[cfg(not(target_arch = "wasm32"))] + $crate::reexports::puffin::profile_scope!($($arg)*); + }; +} From 7f60016a6ed4c3ad1bf11df6c7aba674c6f7e5c7 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Wed, 31 May 2023 09:02:42 +0200 Subject: [PATCH 2/4] use re_tracing everywhere --- crates/re_arrow_store/Cargo.toml | 5 +- crates/re_arrow_store/src/lib.rs | 22 --------- crates/re_arrow_store/src/store.rs | 2 +- crates/re_arrow_store/src/store_arrow.rs | 10 ++-- crates/re_arrow_store/src/store_dump.rs | 10 ++-- crates/re_arrow_store/src/store_gc.rs | 8 ++-- crates/re_arrow_store/src/store_helpers.rs | 10 ++-- crates/re_arrow_store/src/store_polars.rs | 14 +++--- crates/re_arrow_store/src/store_read.rs | 48 +++++++++---------- crates/re_arrow_store/src/store_sanity.rs | 8 ++-- crates/re_arrow_store/src/store_stats.rs | 32 ++++++------- crates/re_arrow_store/src/store_write.rs | 18 +++---- crates/re_components/Cargo.toml | 2 +- crates/re_components/src/lib.rs | 22 --------- crates/re_components/src/tensor.rs | 18 +++---- crates/re_data_store/Cargo.toml | 6 +-- crates/re_data_store/src/entity_tree.rs | 12 ++--- crates/re_data_store/src/log_db.rs | 14 +++--- crates/re_data_store/src/util.rs | 2 +- crates/re_data_ui/Cargo.toml | 6 +-- crates/re_data_ui/src/component.rs | 2 +- crates/re_data_ui/src/image.rs | 8 ++-- crates/re_data_ui/src/lib.rs | 24 +--------- crates/re_log_encoding/Cargo.toml | 5 +- crates/re_log_encoding/src/decoder.rs | 8 ++-- crates/re_log_encoding/src/lib.rs | 22 --------- crates/re_log_types/Cargo.toml | 2 +- crates/re_log_types/src/data_table.rs | 22 ++++----- crates/re_log_types/src/serde_field.rs | 4 +- crates/re_query/Cargo.toml | 7 +-- crates/re_query/src/lib.rs | 22 --------- crates/re_query/src/query.rs | 2 +- crates/re_query/src/range.rs | 2 +- crates/re_query/src/visit.rs | 2 +- crates/re_renderer/Cargo.toml | 2 +- .../src/allocator/cpu_write_gpu_read_belt.rs | 6 +-- .../src/allocator/gpu_readback_belt.rs | 6 +-- crates/re_renderer/src/context.rs | 12 ++--- .../re_renderer/src/draw_phases/outlines.rs | 2 +- .../src/draw_phases/picking_layer.rs | 2 +- .../re_renderer/src/draw_phases/screenshot.rs | 2 +- crates/re_renderer/src/file_resolver.rs | 2 +- crates/re_renderer/src/importer/gltf.rs | 10 ++-- crates/re_renderer/src/importer/obj.rs | 2 +- crates/re_renderer/src/lib.rs | 24 +--------- crates/re_renderer/src/mesh.rs | 2 +- crates/re_renderer/src/point_cloud_builder.rs | 8 ++-- .../re_renderer/src/renderer/depth_cloud.rs | 6 +-- .../src/renderer/generic_skybox.rs | 4 +- .../re_renderer/src/renderer/mesh_renderer.rs | 6 +-- .../re_renderer/src/renderer/point_cloud.rs | 6 +-- crates/re_renderer/src/renderer/rectangles.rs | 6 +-- .../src/resource_managers/texture_manager.rs | 6 +-- crates/re_renderer/src/texture_info.rs | 4 +- crates/re_renderer/src/view_builder.rs | 16 +++---- .../src/wgpu_resources/buffer_pool.rs | 4 +- .../wgpu_resources/dynamic_resource_pool.rs | 6 +-- .../wgpu_resources/render_pipeline_pool.rs | 2 +- .../wgpu_resources/static_resource_pool.rs | 7 ++- .../src/wgpu_resources/texture_pool.rs | 2 +- crates/re_time_panel/Cargo.toml | 4 +- .../re_time_panel/src/data_density_graph.rs | 12 ++--- crates/re_time_panel/src/lib.rs | 30 ++---------- crates/re_time_panel/src/paint_ticks.rs | 2 +- crates/re_time_panel/src/time_axis.rs | 10 ++-- crates/re_time_panel/src/time_ranges_ui.rs | 2 +- crates/re_viewer/Cargo.toml | 1 + crates/re_viewer/src/app.rs | 22 ++++----- crates/re_viewer/src/lib.rs | 22 --------- crates/re_viewer/src/ui/blueprint.rs | 2 +- crates/re_viewer/src/ui/memory_panel.rs | 6 +-- crates/re_viewer/src/ui/selection_panel.rs | 4 +- crates/re_viewer_context/Cargo.toml | 2 +- crates/re_viewer_context/src/annotations.rs | 2 +- .../src/component_ui_registry.rs | 2 +- .../re_viewer_context/src/gpu_bridge/mod.rs | 6 +-- .../src/gpu_bridge/tensor_to_gpu.rs | 12 ++--- crates/re_viewer_context/src/lib.rs | 22 --------- .../src/selection_history.rs | 2 +- .../re_viewer_context/src/selection_state.rs | 4 +- .../src/tensor/tensor_decode_cache.rs | 4 +- .../src/tensor/tensor_stats.rs | 6 +-- crates/re_viewport/Cargo.toml | 4 +- crates/re_viewport/src/auto_layout.rs | 2 +- crates/re_viewport/src/data_blueprint.rs | 6 +-- crates/re_viewport/src/lib.rs | 22 --------- crates/re_viewport/src/mesh_cache.rs | 2 +- crates/re_viewport/src/mesh_loader.rs | 6 +-- crates/re_viewport/src/space_info.rs | 4 +- crates/re_viewport/src/space_view.rs | 6 +-- .../re_viewport/src/space_view_heuristics.rs | 8 ++-- .../re_viewport/src/space_view_highlights.rs | 2 +- crates/re_viewport/src/transform_cache.rs | 2 +- .../re_viewport/src/view_bar_chart/scene.rs | 4 +- crates/re_viewport/src/view_category.rs | 2 +- .../re_viewport/src/view_spatial/scene/mod.rs | 4 +- .../src/view_spatial/scene/picking.rs | 8 ++-- .../src/view_spatial/scene/primitives.rs | 4 +- .../view_spatial/scene/scene_part/arrows3d.rs | 2 +- .../view_spatial/scene/scene_part/boxes2d.rs | 2 +- .../view_spatial/scene/scene_part/boxes3d.rs | 2 +- .../view_spatial/scene/scene_part/cameras.rs | 2 +- .../view_spatial/scene/scene_part/images.rs | 12 ++--- .../view_spatial/scene/scene_part/lines2d.rs | 2 +- .../view_spatial/scene/scene_part/lines3d.rs | 2 +- .../view_spatial/scene/scene_part/meshes.rs | 2 +- .../src/view_spatial/scene/scene_part/mod.rs | 6 +-- .../view_spatial/scene/scene_part/points2d.rs | 10 ++-- .../view_spatial/scene/scene_part/points3d.rs | 10 ++-- crates/re_viewport/src/view_spatial/ui.rs | 6 +-- crates/re_viewport/src/view_spatial/ui_2d.rs | 2 +- crates/re_viewport/src/view_spatial/ui_3d.rs | 2 +- .../src/view_spatial/ui_renderer_bridge.rs | 2 +- crates/re_viewport/src/view_tensor/scene.rs | 2 +- .../src/view_tensor/tensor_slice_to_gpu.rs | 10 ++-- crates/re_viewport/src/view_tensor/ui.rs | 6 +-- crates/re_viewport/src/view_text/scene.rs | 2 +- crates/re_viewport/src/view_text/ui.rs | 10 ++-- crates/re_viewport/src/view_text_box/scene.rs | 2 +- crates/re_viewport/src/view_text_box/ui.rs | 4 +- .../re_viewport/src/view_time_series/scene.rs | 6 +-- crates/re_viewport/src/view_time_series/ui.rs | 2 +- crates/re_viewport/src/viewport.rs | 8 ++-- 123 files changed, 351 insertions(+), 586 deletions(-) diff --git a/crates/re_arrow_store/Cargo.toml b/crates/re_arrow_store/Cargo.toml index 5ee21ebf159f..1bda557cdb27 100644 --- a/crates/re_arrow_store/Cargo.toml +++ b/crates/re_arrow_store/Cargo.toml @@ -35,6 +35,7 @@ core_benchmarks_only = [] re_format.workspace = true re_log_types.workspace = true re_log.workspace = true +re_tracing.workspace = true # External dependencies: ahash.workspace = true @@ -48,10 +49,6 @@ parking_lot.workspace = true smallvec.workspace = true thiserror.workspace = true -# Native dependencies: -[target.'cfg(not(target_arch = "wasm32"))'.dependencies] -puffin.workspace = true - # Optional dependencies: polars-core = { workspace = true, optional = true, features = [ "diagonal_concat", diff --git a/crates/re_arrow_store/src/lib.rs b/crates/re_arrow_store/src/lib.rs index 5d7b90596cf5..0f3c86c464bb 100644 --- a/crates/re_arrow_store/src/lib.rs +++ b/crates/re_arrow_store/src/lib.rs @@ -56,25 +56,3 @@ pub use re_log_types::{TimeInt, TimeRange, TimeType, Timeline}; // for politenes pub mod external { pub use arrow2; } - -// --- - -/// Native-only profiling macro for puffin. -#[doc(hidden)] -#[macro_export] -macro_rules! profile_function { - ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_function!($($arg)*); - }; -} - -/// Native-only profiling macro for puffin. -#[doc(hidden)] -#[macro_export] -macro_rules! profile_scope { - ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_scope!($($arg)*); - }; -} diff --git a/crates/re_arrow_store/src/store.rs b/crates/re_arrow_store/src/store.rs index 81a715a20d83..eb99d22525ae 100644 --- a/crates/re_arrow_store/src/store.rs +++ b/crates/re_arrow_store/src/store.rs @@ -286,7 +286,7 @@ impl DataStore { /// /// Useful to call after a gc. pub fn oldest_time_per_timeline(&self) -> BTreeMap { - crate::profile_function!(); + re_tracing::profile_function!(); let mut oldest_time_per_timeline = BTreeMap::default(); diff --git a/crates/re_arrow_store/src/store_arrow.rs b/crates/re_arrow_store/src/store_arrow.rs index d62d8c3b8f3b..4085026eaab5 100644 --- a/crates/re_arrow_store/src/store_arrow.rs +++ b/crates/re_arrow_store/src/store_arrow.rs @@ -22,7 +22,7 @@ impl IndexedBucket { /// - `$cluster_key` /// - rest of component columns in ascending lexical order pub fn serialize(&self) -> DataTableResult<(Schema, Chunk>)> { - crate::profile_function!(); + re_tracing::profile_function!(); let Self { timeline, @@ -63,7 +63,7 @@ impl PersistentIndexedTable { /// - `$cluster_key` /// - rest of component columns in ascending lexical order pub fn serialize(&self) -> DataTableResult<(Schema, Chunk>)> { - crate::profile_function!(); + re_tracing::profile_function!(); let Self { ent_path: _, @@ -95,7 +95,7 @@ fn serialize( col_num_instances: &[u32], table: &IntMap, ) -> DataTableResult<(Schema, Chunk>)> { - crate::profile_function!(); + re_tracing::profile_function!(); let mut schema = Schema::default(); let mut columns = Vec::new(); @@ -129,7 +129,7 @@ fn serialize_control_columns( col_row_id: &[RowId], col_num_instances: &[u32], ) -> DataTableResult<(Schema, Vec>)> { - crate::profile_function!(); + re_tracing::profile_function!(); let mut schema = Schema::default(); let mut columns = Vec::new(); @@ -175,7 +175,7 @@ fn serialize_data_columns( cluster_key: &ComponentName, table: &IntMap, ) -> DataTableResult<(Schema, Vec>)> { - crate::profile_function!(); + re_tracing::profile_function!(); let mut schema = Schema::default(); let mut columns = Vec::new(); diff --git a/crates/re_arrow_store/src/store_dump.rs b/crates/re_arrow_store/src/store_dump.rs index e83690a478cf..d6962831da0c 100644 --- a/crates/re_arrow_store/src/store_dump.rs +++ b/crates/re_arrow_store/src/store_dump.rs @@ -32,7 +32,7 @@ impl DataStore { fn dump_timeless_tables(&self) -> impl Iterator + '_ { self.timeless_tables.values().map(|table| { - crate::profile_scope!("timeless_table"); + re_tracing::profile_scope!("timeless_table"); let PersistentIndexedTable { ent_path, @@ -58,10 +58,10 @@ impl DataStore { fn dump_temporal_tables(&self) -> impl Iterator + '_ { self.tables.values().flat_map(|table| { - crate::profile_scope!("temporal_table"); + re_tracing::profile_scope!("temporal_table"); table.buckets.values().map(move |bucket| { - crate::profile_scope!("temporal_bucket"); + re_tracing::profile_scope!("temporal_bucket"); bucket.sort_indices_if_needed(); @@ -105,14 +105,14 @@ impl DataStore { self.tables .values() .filter_map(move |table| { - crate::profile_scope!("temporal_table_filtered"); + re_tracing::profile_scope!("temporal_table_filtered"); if table.timeline != timeline_filter { return None; } Some(table.buckets.values().filter_map(move |bucket| { - crate::profile_scope!("temporal_bucket_filtered"); + re_tracing::profile_scope!("temporal_bucket_filtered"); bucket.sort_indices_if_needed(); diff --git a/crates/re_arrow_store/src/store_gc.rs b/crates/re_arrow_store/src/store_gc.rs index e418763eac33..8f33f90e3490 100644 --- a/crates/re_arrow_store/src/store_gc.rs +++ b/crates/re_arrow_store/src/store_gc.rs @@ -64,7 +64,7 @@ impl DataStore { // // TODO(#1823): Workload specific optimizations. pub fn gc(&mut self, target: GarbageCollectionTarget) -> (Vec, DataStoreStats) { - crate::profile_function!(); + re_tracing::profile_function!(); self.gc_id += 1; @@ -126,7 +126,7 @@ impl DataStore { /// /// Returns the list of `RowId`s that were purged from the store. fn gc_drop_at_least_num_bytes(&mut self, mut num_bytes_to_drop: f64) -> Vec { - crate::profile_function!(); + re_tracing::profile_function!(); let mut row_ids = Vec::new(); @@ -165,7 +165,7 @@ impl IndexedTable { /// /// Returns how many bytes were actually dropped, or zero if the row wasn't found. fn try_drop_row(&mut self, row_id: RowId, time: i64) -> u64 { - crate::profile_function!(); + re_tracing::profile_function!(); let table_has_more_than_one_bucket = self.buckets.len() > 1; @@ -211,7 +211,7 @@ impl IndexedBucketInner { /// /// Returns how many bytes were actually dropped, or zero if the row wasn't found. fn try_drop_row(&mut self, row_id: RowId, time: i64) -> u64 { - crate::profile_function!(); + re_tracing::profile_function!(); self.sort(); diff --git a/crates/re_arrow_store/src/store_helpers.rs b/crates/re_arrow_store/src/store_helpers.rs index 2bf1c938852a..8992390fb375 100644 --- a/crates/re_arrow_store/src/store_helpers.rs +++ b/crates/re_arrow_store/src/store_helpers.rs @@ -24,7 +24,7 @@ impl DataStore { where for<'b> &'b C::ArrayType: IntoIterator, { - crate::profile_function!(); + re_tracing::profile_function!(); let (_, cells) = self.latest_at(query, entity_path, C::name(), &[C::name()])?; let cell = cells.get(0)?.as_ref()?; @@ -57,7 +57,7 @@ impl DataStore { where for<'b> &'b C::ArrayType: IntoIterator, { - crate::profile_function!(); + re_tracing::profile_function!(); let mut cur_path = Some(entity_path.clone()); while let Some(path) = cur_path { @@ -84,7 +84,7 @@ impl DataStore { where for<'b> &'b C::ArrayType: IntoIterator, { - crate::profile_function!(); + re_tracing::profile_function!(); let query = LatestAtQuery::latest(Timeline::default()); self.query_latest_component(entity_path, &query) @@ -103,7 +103,7 @@ impl DataStore { timepoint: &TimePoint, component: C, ) { - crate::profile_function!(); + re_tracing::profile_function!(); let mut row = match DataRow::try_from_cells1( RowId::random(), @@ -140,7 +140,7 @@ impl DataStore { timepoint: &TimePoint, component: ComponentName, ) { - crate::profile_function!(); + re_tracing::profile_function!(); if let Some(datatype) = self.lookup_datatype(&component) { let cell = DataCell::from_arrow_empty(component, datatype.clone()); diff --git a/crates/re_arrow_store/src/store_polars.rs b/crates/re_arrow_store/src/store_polars.rs index 73ad746c48c4..c6d7c43ddc58 100644 --- a/crates/re_arrow_store/src/store_polars.rs +++ b/crates/re_arrow_store/src/store_polars.rs @@ -27,7 +27,7 @@ impl DataStore { /// This cannot fail: it always tries to yield as much valuable information as it can, even in /// the face of errors. pub fn to_dataframe(&self) -> DataFrame { - crate::profile_function!(); + re_tracing::profile_function!(); const TIMELESS_COL: &str = "_is_timeless"; @@ -167,7 +167,7 @@ impl PersistentIndexedTable { /// This cannot fail: it always tries to yield as much valuable information as it can, even in /// the face of errors. pub fn to_dataframe(&self, store: &DataStore, config: &DataStoreConfig) -> DataFrame { - crate::profile_function!(); + re_tracing::profile_function!(); let Self { ent_path: _, @@ -206,7 +206,7 @@ impl IndexedBucket { /// This cannot fail: it always tries to yield as much valuable information as it can, even in /// the face of errors. pub fn to_dataframe(&self, store: &DataStore, config: &DataStoreConfig) -> DataFrame { - crate::profile_function!(); + re_tracing::profile_function!(); let IndexedBucketInner { is_sorted: _, @@ -260,7 +260,7 @@ impl IndexedBucket { // --- fn insert_ids_as_series(col_insert_id: &InsertIdVec) -> Series { - crate::profile_function!(); + re_tracing::profile_function!(); let insert_ids = arrow2::array::UInt64Array::from_slice(col_insert_id.as_slice()); new_infallible_series( @@ -277,7 +277,7 @@ fn column_as_series( component: ComponentName, cells: &[Option], ) -> Series { - crate::profile_function!(); + re_tracing::profile_function!(); // Computing the validity bitmap is just a matter of checking whether the data was // available in the component tables. @@ -316,7 +316,7 @@ fn column_as_series( // --- fn new_infallible_series(name: &str, data: &dyn Array, len: usize) -> Series { - crate::profile_function!(); + re_tracing::profile_function!(); Series::try_from((name, data.as_ref().clean_for_polars())).unwrap_or_else(|_| { let errs = Utf8Array::::from(vec![Some(""); len]); @@ -335,7 +335,7 @@ fn sort_df_columns( store_insert_ids: bool, timelines: &BTreeSet<&str>, ) -> DataFrame { - crate::profile_function!(); + re_tracing::profile_function!(); let columns: Vec<_> = { let mut all = df.get_column_names(); diff --git a/crates/re_arrow_store/src/store_read.rs b/crates/re_arrow_store/src/store_read.rs index c0f24b976e30..2b036e48ad7d 100644 --- a/crates/re_arrow_store/src/store_read.rs +++ b/crates/re_arrow_store/src/store_read.rs @@ -93,7 +93,7 @@ impl DataStore { timeline: &Timeline, ent_path: &EntityPath, ) -> Option> { - crate::profile_function!(); + re_tracing::profile_function!(); // TODO(cmc): kind & query_id need to somehow propagate through the span system. self.query_id.fetch_add(1, Ordering::Relaxed); @@ -201,7 +201,7 @@ impl DataStore { primary: ComponentName, components: &[ComponentName; N], ) -> Option<(RowId, [Option; N])> { - crate::profile_function!(); + re_tracing::profile_function!(); // TODO(cmc): kind & query_id need to somehow propagate through the span system. self.query_id.fetch_add(1, Ordering::Relaxed); @@ -391,7 +391,7 @@ impl DataStore { ) -> impl Iterator, RowId, [Option; N])> + 'a { // Beware! This merely measures the time it takes to gather all the necessary metadata // for building the returned iterator. - crate::profile_function!(); + re_tracing::profile_function!(); // TODO(cmc): kind & query_id need to somehow propagate through the span system. self.query_id.fetch_add(1, Ordering::Relaxed); @@ -433,7 +433,7 @@ impl DataStore { } pub fn get_msg_metadata(&self, row_id: &RowId) -> Option<&TimePoint> { - crate::profile_function!(); + re_tracing::profile_function!(); self.metadata_registry.get(row_id) } @@ -460,7 +460,7 @@ impl IndexedTable { primary: ComponentName, components: &[ComponentName; N], ) -> Option<(RowId, [Option; N])> { - crate::profile_function!(); + re_tracing::profile_function!(); // Early-exit if this entire table is unaware of this component. if !self.all_components.contains(&primary) { @@ -516,7 +516,7 @@ impl IndexedTable { ) -> impl Iterator; N])> + '_ { // Beware! This merely measures the time it takes to gather all the necessary metadata // for building the returned iterator. - crate::profile_function!(); + re_tracing::profile_function!(); let timeline = self.timeline; @@ -549,7 +549,7 @@ impl IndexedTable { /// /// See [`IndexedTable::buckets`] for more information. pub fn find_bucket(&self, time: TimeInt) -> (TimeInt, &IndexedBucket) { - crate::profile_function!(); + re_tracing::profile_function!(); // This cannot fail, `iter_bucket` is guaranteed to always yield at least one bucket, // since indexed tables always spawn with a default bucket that covers [-∞;+∞]. @@ -563,7 +563,7 @@ impl IndexedTable { /// /// See [`IndexedTable::buckets`] for more information. pub fn find_bucket_mut(&mut self, time: TimeInt) -> (TimeInt, &mut IndexedBucket) { - crate::profile_function!(); + re_tracing::profile_function!(); // This cannot fail, `iter_bucket_mut` is guaranteed to always yield at least one bucket, // since indexed tables always spawn with a default bucket that covers [-∞;+∞]. @@ -585,7 +585,7 @@ impl IndexedTable { ) -> impl Iterator { // Beware! This merely measures the time it takes to gather all the necessary metadata // for building the returned iterator. - crate::profile_function!(); + re_tracing::profile_function!(); self.buckets .range(time_range) @@ -607,7 +607,7 @@ impl IndexedTable { ) -> impl Iterator { // Beware! This merely measures the time it takes to gather all the necessary metadata // for building the returned iterator. - crate::profile_function!(); + re_tracing::profile_function!(); self.buckets .range(time_range) @@ -630,7 +630,7 @@ impl IndexedTable { ) -> impl Iterator { // Beware! This merely measures the time it takes to gather all the necessary metadata // for building the returned iterator. - crate::profile_function!(); + re_tracing::profile_function!(); self.buckets .range_mut(time_range) @@ -653,7 +653,7 @@ impl IndexedBucket { return; // early read-only exit } - crate::profile_scope!("sort"); + re_tracing::profile_scope!("sort"); self.inner.write().sort(); } @@ -668,7 +668,7 @@ impl IndexedBucket { primary: ComponentName, components: &[ComponentName; N], ) -> Option<(RowId, [Option; N])> { - crate::profile_function!(); + re_tracing::profile_function!(); self.sort_indices_if_needed(); @@ -809,7 +809,7 @@ impl IndexedBucket { // Beware! This merely measures the time it takes to gather all the necessary metadata // for building the returned iterator. - crate::profile_function!(); + re_tracing::profile_function!(); trace!( kind = "range", @@ -912,10 +912,10 @@ impl IndexedBucketInner { return; } - crate::profile_function!(); + re_tracing::profile_function!(); let swaps = { - crate::profile_scope!("swaps"); + re_tracing::profile_scope!("swaps"); let mut swaps = (0..col_time.len()).collect::>(); swaps.sort_by_key(|&i| &col_time[i]); swaps @@ -930,18 +930,18 @@ impl IndexedBucketInner { // TODO(#442): re_datastore: implement efficient shuffling on the read path. { - crate::profile_scope!("control"); + re_tracing::profile_scope!("control"); fn reshuffle_control_column( column: &mut SmallVec<[T; N]>, swaps: &[(usize, usize)], ) { let source = { - crate::profile_scope!("clone"); + re_tracing::profile_scope!("clone"); column.clone() }; { - crate::profile_scope!("rotate"); + re_tracing::profile_scope!("rotate"); for (from, to) in swaps.iter().copied() { column[to] = source[from]; } @@ -957,15 +957,15 @@ impl IndexedBucketInner { } { - crate::profile_scope!("data"); + re_tracing::profile_scope!("data"); // shuffle component columns back into a sorted state for column in columns.values_mut() { let mut source = { - crate::profile_scope!("clone"); + re_tracing::profile_scope!("clone"); column.clone() }; { - crate::profile_scope!("rotate"); + re_tracing::profile_scope!("rotate"); for (from, to) in swaps.iter().copied() { column[to] = source[from].take(); } @@ -997,7 +997,7 @@ impl PersistentIndexedTable { // Early-exit if this bucket is unaware of this component. let column = self.columns.get(&primary)?; - crate::profile_function!(); + re_tracing::profile_function!(); trace!( kind = "latest_at", @@ -1090,7 +1090,7 @@ impl PersistentIndexedTable { // Beware! This merely measures the time it takes to gather all the necessary metadata // for building the returned iterator. - crate::profile_function!(); + re_tracing::profile_function!(); let cells = (0..self.num_rows()).filter_map(move |row_nr| { let mut cells = [(); N].map(|_| None); diff --git a/crates/re_arrow_store/src/store_sanity.rs b/crates/re_arrow_store/src/store_sanity.rs index eba65eb70011..0c5aa5f8be58 100644 --- a/crates/re_arrow_store/src/store_sanity.rs +++ b/crates/re_arrow_store/src/store_sanity.rs @@ -62,7 +62,7 @@ impl DataStore { /// /// Returns an error if anything looks wrong. pub fn sanity_check(&self) -> SanityResult<()> { - crate::profile_function!(); + re_tracing::profile_function!(); for table in self.timeless_tables.values() { table.sanity_check()?; @@ -83,7 +83,7 @@ impl IndexedTable { /// /// Returns an error if anything looks wrong. pub fn sanity_check(&self) -> SanityResult<()> { - crate::profile_function!(); + re_tracing::profile_function!(); // No two buckets should ever overlap time-range-wise. { @@ -145,7 +145,7 @@ impl IndexedBucket { /// /// Returns an error if anything looks wrong. pub fn sanity_check(&self) -> SanityResult<()> { - crate::profile_function!(); + re_tracing::profile_function!(); let Self { timeline: _, @@ -253,7 +253,7 @@ impl PersistentIndexedTable { /// /// Returns an error if anything looks wrong. pub fn sanity_check(&self) -> SanityResult<()> { - crate::profile_function!(); + re_tracing::profile_function!(); let Self { ent_path: _, diff --git a/crates/re_arrow_store/src/store_stats.rs b/crates/re_arrow_store/src/store_stats.rs index a18f6c7b3485..e3affdb89c90 100644 --- a/crates/re_arrow_store/src/store_stats.rs +++ b/crates/re_arrow_store/src/store_stats.rs @@ -81,10 +81,10 @@ impl std::ops::Add for DataStoreStats { impl DataStoreStats { pub fn from_store(store: &DataStore) -> Self { - crate::profile_function!(); + re_tracing::profile_function!(); let type_registry = { - crate::profile_scope!("type_registry"); + re_tracing::profile_scope!("type_registry"); DataStoreRowStats { num_rows: store.type_registry.len() as _, num_bytes: store.type_registry.total_size_bytes(), @@ -92,7 +92,7 @@ impl DataStoreStats { }; let metadata_registry = { - crate::profile_scope!("metadata_registry"); + re_tracing::profile_scope!("metadata_registry"); DataStoreRowStats { num_rows: store.metadata_registry.len() as _, num_bytes: store.metadata_registry.total_size_bytes(), @@ -100,7 +100,7 @@ impl DataStoreStats { }; let autogenerated = { - crate::profile_scope!("autogenerated"); + re_tracing::profile_scope!("autogenerated"); DataStoreRowStats { num_rows: store.cluster_cell_cache.len() as _, num_bytes: store.cluster_cell_cache.total_size_bytes(), @@ -108,7 +108,7 @@ impl DataStoreStats { }; let timeless = { - crate::profile_scope!("timeless"); + re_tracing::profile_scope!("timeless"); DataStoreRowStats { num_rows: store.num_timeless_rows(), num_bytes: store.timeless_size_bytes(), @@ -116,7 +116,7 @@ impl DataStoreStats { }; let (temporal, temporal_buckets) = { - crate::profile_scope!("temporal"); + re_tracing::profile_scope!("temporal"); ( DataStoreRowStats { num_rows: store.num_temporal_rows(), @@ -185,7 +185,7 @@ impl DataStore { /// the number of rows across all of its timeless indexed tables. #[inline] pub fn num_timeless_rows(&self) -> u64 { - crate::profile_function!(); + re_tracing::profile_function!(); self.timeless_tables .values() .map(|table| table.num_rows()) @@ -196,7 +196,7 @@ impl DataStore { /// of the size of the data stored across all of its timeless indexed tables, in bytes. #[inline] pub fn timeless_size_bytes(&self) -> u64 { - crate::profile_function!(); + re_tracing::profile_function!(); self.timeless_tables .values() .map(|table| table.total_size_bytes()) @@ -207,7 +207,7 @@ impl DataStore { /// the number of rows across all of its temporal indexed tables. #[inline] pub fn num_temporal_rows(&self) -> u64 { - crate::profile_function!(); + re_tracing::profile_function!(); self.tables.values().map(|table| table.num_rows()).sum() } @@ -215,7 +215,7 @@ impl DataStore { /// of the size of the data stored across all of its temporal indexed tables, in bytes. #[inline] pub fn temporal_size_bytes(&self) -> u64 { - crate::profile_function!(); + re_tracing::profile_function!(); self.tables .values() .map(|table| table.total_size_bytes()) @@ -225,7 +225,7 @@ impl DataStore { /// Returns the number of temporal indexed buckets stored across this entire store. #[inline] pub fn num_temporal_buckets(&self) -> u64 { - crate::profile_function!(); + re_tracing::profile_function!(); self.tables.values().map(|table| table.num_buckets()).sum() } } @@ -246,13 +246,13 @@ impl IndexedTable { /// Recomputed from scratch, for sanity checking. #[inline] pub(crate) fn num_rows_uncached(&self) -> u64 { - crate::profile_function!(); + re_tracing::profile_function!(); self.buckets.values().map(|bucket| bucket.num_rows()).sum() } #[inline] pub(crate) fn size_bytes_uncached(&self) -> u64 { - crate::profile_function!(); + re_tracing::profile_function!(); self.stack_size_bytes() + self .buckets @@ -279,7 +279,7 @@ impl IndexedBucket { /// Returns the number of rows stored across this bucket. #[inline] pub fn num_rows(&self) -> u64 { - crate::profile_function!(); + re_tracing::profile_function!(); self.inner.read().col_time.len() as u64 } } @@ -299,7 +299,7 @@ impl IndexedBucketInner { /// triggering GCs, ...). #[inline] pub fn compute_size_bytes(&mut self) -> u64 { - crate::profile_function!(); + re_tracing::profile_function!(); let Self { is_sorted, @@ -338,7 +338,7 @@ impl PersistentIndexedTable { impl SizeBytes for PersistentIndexedTable { #[inline] fn heap_size_bytes(&self) -> u64 { - crate::profile_function!(); + re_tracing::profile_function!(); let Self { ent_path, diff --git a/crates/re_arrow_store/src/store_write.rs b/crates/re_arrow_store/src/store_write.rs index ad61c9a0a5f0..cb04fa9dbca5 100644 --- a/crates/re_arrow_store/src/store_write.rs +++ b/crates/re_arrow_store/src/store_write.rs @@ -76,7 +76,7 @@ impl DataStore { return Ok(()); } - crate::profile_function!(); + re_tracing::profile_function!(); // Update type registry and do typechecking if enabled if self.config.enable_typecheck { @@ -199,7 +199,7 @@ impl DataStore { /// transparently handles caching. // TODO(#1777): shared slices for auto generated keys fn generate_cluster_cell(&mut self, num_instances: u32) -> DataCell { - crate::profile_function!(); + re_tracing::profile_function!(); if let Some(cell) = self.cluster_cell_cache.get(&num_instances) { // Cache hit! @@ -277,7 +277,7 @@ impl IndexedTable { generated_cluster_cell: Option, row: &DataRow, ) { - crate::profile_function!(); + re_tracing::profile_function!(); let components: IntSet<_> = row.component_names().collect(); @@ -415,7 +415,7 @@ impl IndexedBucket { row: &DataRow, components: &IntSet, ) -> u64 { - crate::profile_function!(); + re_tracing::profile_function!(); let mut size_bytes_added = 0u64; let num_rows = self.num_rows() as usize; @@ -561,7 +561,7 @@ impl IndexedBucket { return None; } - crate::profile_function!(); + re_tracing::profile_function!(); let timeline = *timeline; @@ -585,7 +585,7 @@ impl IndexedBucket { let split_idx = find_split_index(col_time1).expect("must be splittable at this point"); let (time_range2, col_time2, col_insert_id2, col_row_id2, col_num_instances2) = { - crate::profile_scope!("control"); + re_tracing::profile_scope!("control"); ( // this updates `time_range1` in-place! split_time_range_off(split_idx, col_time1, time_range1), @@ -602,7 +602,7 @@ impl IndexedBucket { // this updates `columns1` in-place! let columns2: IntMap<_, _> = { - crate::profile_scope!("data"); + re_tracing::profile_scope!("data"); columns1 .iter_mut() .map(|(name, column1)| { @@ -685,7 +685,7 @@ fn find_split_index(times: &[i64]) -> Option { return None; // early exit: unsplittable } - crate::profile_function!(); + re_tracing::profile_function!(); // This can never be lesser than 1 as we never split buckets smaller than 2 entries. let halfway_idx = times.len() / 2; @@ -793,7 +793,7 @@ impl PersistentIndexedTable { generated_cluster_cell: Option, row: &DataRow, ) { - crate::profile_function!(); + re_tracing::profile_function!(); let num_rows = self.num_rows() as usize; diff --git a/crates/re_components/Cargo.toml b/crates/re_components/Cargo.toml index f78251063034..0da6efbd4e72 100644 --- a/crates/re_components/Cargo.toml +++ b/crates/re_components/Cargo.toml @@ -41,6 +41,7 @@ serde = ["dep:serde", "half/serde", "re_log_types/serde"] # Rerun re_log_types.workspace = true re_log.workspace = true +re_tracing.workspace = true # External ahash.workspace = true @@ -70,7 +71,6 @@ serde = { version = "1", optional = true, features = ["derive", "rc"] } # Native dependencies: [target.'cfg(not(target_arch = "wasm32"))'.dependencies] crossbeam.workspace = true -puffin.workspace = true [dev-dependencies] diff --git a/crates/re_components/src/lib.rs b/crates/re_components/src/lib.rs index 01133aab1144..601327cbe121 100644 --- a/crates/re_components/src/lib.rs +++ b/crates/re_components/src/lib.rs @@ -332,25 +332,3 @@ where v } } - -// --------------------------------------------------------------------------- - -/// Wrapper around puffin profiler on native, no-op on weasm -#[doc(hidden)] -#[macro_export] -macro_rules! profile_function { - ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_function!($($arg)*); - }; -} - -/// Wrapper around puffin profiler on native, no-op on weasm -#[doc(hidden)] -#[macro_export] -macro_rules! profile_scope { - ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_scope!($($arg)*); - }; -} diff --git a/crates/re_components/src/tensor.rs b/crates/re_components/src/tensor.rs index 91364b2e6d93..39cdb38d7d87 100644 --- a/crates/re_components/src/tensor.rs +++ b/crates/re_components/src/tensor.rs @@ -839,10 +839,10 @@ impl Tensor { /// Requires the `image` feature. #[cfg(not(target_arch = "wasm32"))] pub fn from_image_file(path: &std::path::Path) -> Result { - crate::profile_function!(path.to_string_lossy()); + re_tracing::profile_function!(path.to_string_lossy()); let img_bytes = { - crate::profile_scope!("fs::read"); + re_tracing::profile_scope!("fs::read"); std::fs::read(path)? }; @@ -864,9 +864,9 @@ impl Tensor { /// Requires the `image` feature. #[cfg(not(target_arch = "wasm32"))] pub fn from_jpeg_file(path: &std::path::Path) -> Result { - crate::profile_function!(path.to_string_lossy()); + re_tracing::profile_function!(path.to_string_lossy()); let jpeg_bytes = { - crate::profile_scope!("fs::read"); + re_tracing::profile_scope!("fs::read"); std::fs::read(path)? }; Self::from_jpeg_bytes(jpeg_bytes) @@ -890,7 +890,7 @@ impl Tensor { bytes: Vec, format: image::ImageFormat, ) -> Result { - crate::profile_function!(format!("{format:?}")); + re_tracing::profile_function!(format!("{format:?}")); if format == image::ImageFormat::Jpeg { Self::from_jpeg_bytes(bytes) } else { @@ -903,7 +903,7 @@ impl Tensor { /// /// Requires the `image` feature. pub fn from_jpeg_bytes(jpeg_bytes: Vec) -> Result { - crate::profile_function!(); + re_tracing::profile_function!(); use image::ImageDecoder as _; let jpeg = image::codecs::jpeg::JpegDecoder::new(std::io::Cursor::new(&jpeg_bytes))?; if jpeg.color_type() != image::ColorType::Rgb8 { @@ -1126,7 +1126,7 @@ impl DecodedTensor { pub fn from_dynamic_image( image: image::DynamicImage, ) -> Result { - crate::profile_function!(); + re_tracing::profile_function!(); let (w, h) = (image.width(), image.height()); @@ -1181,7 +1181,7 @@ impl DecodedTensor { } pub fn try_decode(maybe_encoded_tensor: Tensor) -> Result { - crate::profile_function!(); + re_tracing::profile_function!(); match &maybe_encoded_tensor.data { TensorData::U8(_) @@ -1201,7 +1201,7 @@ impl DecodedTensor { let mut reader = ImageReader::new(std::io::Cursor::new(buf.as_slice())); reader.set_format(image::ImageFormat::Jpeg); let img = { - crate::profile_scope!("decode_jpeg"); + re_tracing::profile_scope!("decode_jpeg"); reader.decode()? }; let decoded_tensor = DecodedTensor::from_image(img)?; diff --git a/crates/re_data_store/Cargo.toml b/crates/re_data_store/Cargo.toml index 8f6bb648a980..1e87a837211b 100644 --- a/crates/re_data_store/Cargo.toml +++ b/crates/re_data_store/Cargo.toml @@ -31,6 +31,7 @@ re_log.workspace = true re_log_encoding = { workspace = true, optional = true } re_log_types.workspace = true re_smart_channel.workspace = true +re_tracing.workspace = true ahash.workspace = true document-features = "0.2" @@ -39,11 +40,6 @@ nohash-hasher = "0.2" serde = { version = "1", features = ["derive", "rc"], optional = true } thiserror = "1.0" -# Native dependencies: -[target.'cfg(not(target_arch = "wasm32"))'.dependencies] -puffin.workspace = true - - [dev-dependencies] re_components = { workspace = true, features = ["arrow_datagen"] } re_log_encoding = { workspace = true, features = ["decoder", "encoder"] } diff --git a/crates/re_data_store/src/entity_tree.rs b/crates/re_data_store/src/entity_tree.rs index d3a702ee9653..a22126a339d1 100644 --- a/crates/re_data_store/src/entity_tree.rs +++ b/crates/re_data_store/src/entity_tree.rs @@ -148,7 +148,7 @@ impl EntityTree { time_point: &TimePoint, component_path: &ComponentPath, ) -> Vec<(RowId, TimePoint)> { - crate::profile_function!(); + re_tracing::profile_function!(); let leaf = self.create_subtrees_recursively(component_path.entity_path.as_slice(), 0, time_point); @@ -182,7 +182,7 @@ impl EntityTree { time_point: &TimePoint, path_op: &PathOp, ) -> Vec { - crate::profile_function!(); + re_tracing::profile_function!(); let entity_path = path_op.entity_path(); @@ -299,22 +299,22 @@ impl EntityTree { } = self; for (timeline, histogram) in &mut prefix_times.0 { - crate::profile_scope!("prefix_times"); + re_tracing::profile_scope!("prefix_times"); if let Some(cutoff_time) = cutoff_times.get(timeline) { histogram.remove(..cutoff_time.as_i64()); } } { - crate::profile_scope!("nonrecursive_clears"); + re_tracing::profile_scope!("nonrecursive_clears"); nonrecursive_clears.retain(|row_id, _| !drop_row_ids.contains(row_id)); } { - crate::profile_scope!("recursive_clears"); + re_tracing::profile_scope!("recursive_clears"); recursive_clears.retain(|row_id, _| !drop_row_ids.contains(row_id)); } { - crate::profile_scope!("fields"); + re_tracing::profile_scope!("fields"); for columns in fields.values_mut() { columns.purge(cutoff_times); } diff --git a/crates/re_data_store/src/log_db.rs b/crates/re_data_store/src/log_db.rs index a7dedc24f281..1352773c71a0 100644 --- a/crates/re_data_store/src/log_db.rs +++ b/crates/re_data_store/src/log_db.rs @@ -61,7 +61,7 @@ impl EntityDb { } fn try_add_arrow_msg(&mut self, msg: &ArrowMsg) -> Result<(), Error> { - crate::profile_function!(); + re_tracing::profile_function!(); // TODO(#1760): Compute the size of the datacells in the batching threads on the clients. let mut table = DataTable::from_arrow_msg(msg)?; @@ -147,7 +147,7 @@ impl EntityDb { cutoff_times: &std::collections::BTreeMap, drop_row_ids: &ahash::HashSet, ) { - crate::profile_function!(); + re_tracing::profile_function!(); let Self { entity_path_from_hash: _, @@ -157,12 +157,12 @@ impl EntityDb { } = self; { - crate::profile_scope!("times_per_timeline"); + re_tracing::profile_scope!("times_per_timeline"); times_per_timeline.purge(cutoff_times); } { - crate::profile_scope!("tree"); + re_tracing::profile_scope!("tree"); tree.purge(cutoff_times, drop_row_ids); } } @@ -237,7 +237,7 @@ impl LogDb { } pub fn add(&mut self, msg: &LogMsg) -> Result<(), Error> { - crate::profile_function!(); + re_tracing::profile_function!(); match &msg { LogMsg::SetRecordingInfo(msg) => self.add_begin_recording_msg(msg), @@ -271,7 +271,7 @@ impl LogDb { /// Free up some RAM by forgetting the older parts of all timelines. pub fn purge_fraction_of_ram(&mut self, fraction_to_purge: f32) { - crate::profile_function!(); + re_tracing::profile_function!(); assert!((0.0..=1.0).contains(&fraction_to_purge)); let (drop_row_ids, stats_diff) = self.entity_db.data_store.gc( @@ -295,7 +295,7 @@ impl LogDb { } = self; { - crate::profile_scope!("entity_op_msgs"); + re_tracing::profile_scope!("entity_op_msgs"); entity_op_msgs.retain(|row_id, _| !drop_row_ids.contains(row_id)); } diff --git a/crates/re_data_store/src/util.rs b/crates/re_data_store/src/util.rs index 3d54365f4bd6..6ba7686b045a 100644 --- a/crates/re_data_store/src/util.rs +++ b/crates/re_data_store/src/util.rs @@ -21,7 +21,7 @@ pub fn query_latest_single( where for<'b> &'b C::ArrayType: IntoIterator, { - crate::profile_function!(); + re_tracing::profile_function!(); // Although it would be nice to use the `re_query` helpers for this, we would need to move // this out of re_data_store to avoid a circular dep. Since we don't need to do a join for diff --git a/crates/re_data_ui/Cargo.toml b/crates/re_data_ui/Cargo.toml index ba295ce9539a..c37f055f31ef 100644 --- a/crates/re_data_ui/Cargo.toml +++ b/crates/re_data_ui/Cargo.toml @@ -21,10 +21,11 @@ re_components.workspace = true re_data_store.workspace = true re_error.workspace = true re_format.workspace = true -re_log_types.workspace = true re_log.workspace = true +re_log_types.workspace = true re_query.workspace = true re_renderer.workspace = true +re_tracing.workspace = true re_ui.workspace = true re_viewer_context.workspace = true @@ -36,6 +37,3 @@ image.workspace = true itertools.workspace = true nohash-hasher.workspace = true rfd.workspace = true - -[target.'cfg(not(target_arch = "wasm32"))'.dependencies] -puffin.workspace = true diff --git a/crates/re_data_ui/src/component.rs b/crates/re_data_ui/src/component.rs index 23bf74687ca5..d3290e90c41a 100644 --- a/crates/re_data_ui/src/component.rs +++ b/crates/re_data_ui/src/component.rs @@ -32,7 +32,7 @@ impl DataUi for EntityComponentWithInstances { verbosity: UiVerbosity, query: &re_arrow_store::LatestAtQuery, ) { - crate::profile_function!(self.component_name().full_name()); + re_tracing::profile_function!(self.component_name().full_name()); let instance_keys: Vec<_> = self.component_data.iter_instance_keys().collect(); diff --git a/crates/re_data_ui/src/image.rs b/crates/re_data_ui/src/image.rs index 9b82fc7096ad..a086fe44b28e 100644 --- a/crates/re_data_ui/src/image.rs +++ b/crates/re_data_ui/src/image.rs @@ -24,7 +24,7 @@ impl EntityDataUi for Tensor { entity_path: &re_log_types::EntityPath, query: &re_arrow_store::LatestAtQuery, ) { - crate::profile_function!(); + re_tracing::profile_function!(); match ctx.cache.entry::().entry(self.clone()) { Ok(decoded) => { @@ -596,12 +596,12 @@ fn tensor_pixel_value_ui( } fn rgb8_histogram_ui(ui: &mut egui::Ui, rgb: &[u8]) -> egui::Response { - crate::profile_function!(); + re_tracing::profile_function!(); let mut histograms = [[0_u64; 256]; 3]; { // TODO(emilk): this is slow, so cache the results! - crate::profile_scope!("build"); + re_tracing::profile_scope!("build"); for pixel in rgb.chunks_exact(3) { for c in 0..3 { histograms[c][pixel[c] as usize] += 1; @@ -638,7 +638,7 @@ fn rgb8_histogram_ui(ui: &mut egui::Ui, rgb: &[u8]) -> egui::Response { }) .collect_vec(); - crate::profile_scope!("show"); + re_tracing::profile_scope!("show"); Plot::new("rgb_histogram") .legend(Legend::default()) .height(200.0) diff --git a/crates/re_data_ui/src/lib.rs b/crates/re_data_ui/src/lib.rs index 01dd3e67e7a5..6ff26917fe23 100644 --- a/crates/re_data_ui/src/lib.rs +++ b/crates/re_data_ui/src/lib.rs @@ -154,7 +154,7 @@ pub fn annotations( query: &re_arrow_store::LatestAtQuery, entity_path: &re_data_store::EntityPath, ) -> std::sync::Arc { - crate::profile_function!(); + re_tracing::profile_function!(); let mut annotation_map = re_viewer_context::AnnotationMap::default(); let entity_paths: nohash_hasher::IntSet<_> = std::iter::once(entity_path.clone()).collect(); let entity_props_map = re_data_store::EntityPropertyMap::default(); @@ -167,25 +167,3 @@ pub fn annotations( annotation_map.load(ctx, &scene_query); annotation_map.find(entity_path) } - -// --------------------------------------------------------------------------- - -/// Wrapper around puffin profiler on native, no-op on weasm -#[doc(hidden)] -#[macro_export] -macro_rules! profile_function { - ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_function!($($arg)*); - }; -} - -/// Wrapper around puffin profiler on native, no-op on weasm -#[doc(hidden)] -#[macro_export] -macro_rules! profile_scope { - ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_scope!($($arg)*); - }; -} diff --git a/crates/re_log_encoding/Cargo.toml b/crates/re_log_encoding/Cargo.toml index e97eb7633cd5..e7f0f9b9c1c1 100644 --- a/crates/re_log_encoding/Cargo.toml +++ b/crates/re_log_encoding/Cargo.toml @@ -34,6 +34,7 @@ re_error.workspace = true re_log_types = { workspace = true, features = ["serde"] } re_log.workspace = true re_smart_channel.workspace = true +re_tracing.workspace = true # External: ehttp = "0.2" @@ -45,10 +46,6 @@ web-time.workspace = true rmp-serde = { version = "1", optional = true } lz4_flex = { version = "0.10", optional = true } -# Native dependencies: -[target.'cfg(not(target_arch = "wasm32"))'.dependencies] -puffin.workspace = true - # Web dependencies: [target.'cfg(target_arch = "wasm32")'.dependencies] js-sys = "0.3" diff --git a/crates/re_log_encoding/src/decoder.rs b/crates/re_log_encoding/src/decoder.rs index 568ef06df25b..c9fcdb628be9 100644 --- a/crates/re_log_encoding/src/decoder.rs +++ b/crates/re_log_encoding/src/decoder.rs @@ -92,7 +92,7 @@ pub struct Decoder { impl Decoder { pub fn new(mut read: R) -> Result { - crate::profile_function!(); + re_tracing::profile_function!(); { let mut header = [0_u8; 4]; @@ -133,7 +133,7 @@ impl Iterator for Decoder { type Item = Result; fn next(&mut self) -> Option { - crate::profile_function!(); + re_tracing::profile_function!(); let mut len = [0_u8; 8]; self.decompressor.read_exact(&mut len).ok()?; @@ -142,13 +142,13 @@ impl Iterator for Decoder { self.buffer.resize(len, 0); { - crate::profile_scope!("lz4"); + re_tracing::profile_scope!("lz4"); if let Err(err) = self.decompressor.read_exact(&mut self.buffer) { return Some(Err(err)); } } - crate::profile_scope!("MsgPack deser"); + re_tracing::profile_scope!("MsgPack deser"); match rmp_serde::from_read(&mut self.buffer.as_slice()) { Ok(msg) => Some(Ok(msg)), Err(err) => Some(Err(err.into())), diff --git a/crates/re_log_encoding/src/lib.rs b/crates/re_log_encoding/src/lib.rs index c43f6f5fd638..4eae406b05e8 100644 --- a/crates/re_log_encoding/src/lib.rs +++ b/crates/re_log_encoding/src/lib.rs @@ -102,25 +102,3 @@ pub enum OptionsError { #[error("Unknown serializer: {0}")] UnknownSerializer(u8), } - -// --------------------------------------------------------------------------- - -/// Wrapper around puffin profiler on native, no-op on weasm -#[doc(hidden)] -#[macro_export] -macro_rules! profile_function { - ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_function!($($arg)*); - }; -} - -/// Wrapper around puffin profiler on native, no-op on weasm -#[doc(hidden)] -#[macro_export] -macro_rules! profile_scope { - ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_scope!($($arg)*); - }; -} diff --git a/crates/re_log_types/Cargo.toml b/crates/re_log_types/Cargo.toml index 47f462e8db63..402788957dd9 100644 --- a/crates/re_log_types/Cargo.toml +++ b/crates/re_log_types/Cargo.toml @@ -35,6 +35,7 @@ serde = [ re_format.workspace = true re_log.workspace = true re_string_interner.workspace = true +re_tracing.workspace = true re_tuid = { workspace = true, features = ["arrow2_convert"] } # External @@ -67,7 +68,6 @@ serde_bytes = { version = "0.11", optional = true } # Native dependencies: [target.'cfg(not(target_arch = "wasm32"))'.dependencies] crossbeam.workspace = true -puffin.workspace = true [dev-dependencies] diff --git a/crates/re_log_types/src/data_table.rs b/crates/re_log_types/src/data_table.rs index add245382a0e..c175d4e183cd 100644 --- a/crates/re_log_types/src/data_table.rs +++ b/crates/re_log_types/src/data_table.rs @@ -365,7 +365,7 @@ impl DataTable { /// Builds a new `DataTable` from an iterable of [`DataRow`]s. pub fn from_rows(table_id: TableId, rows: impl IntoIterator) -> Self { - crate::profile_function!(); + re_tracing::profile_function!(); let rows = rows.into_iter(); @@ -578,7 +578,7 @@ impl DataTable { /// They are optional, potentially sparse, and never deserialized on the server-side (not by /// the storage systems, at least). pub fn serialize(&self) -> DataTableResult<(Schema, Chunk>)> { - crate::profile_function!(); + re_tracing::profile_function!(); let mut schema = Schema::default(); let mut columns = Vec::new(); @@ -609,7 +609,7 @@ impl DataTable { /// Serializes all time columns into an arrow payload and schema. fn serialize_time_columns(&self) -> (Schema, Vec>) { - crate::profile_function!(); + re_tracing::profile_function!(); fn serialize_time_column( timeline: Timeline, @@ -650,7 +650,7 @@ impl DataTable { /// They are always present, always dense, and always deserialized upon reception by the /// server. fn serialize_control_columns(&self) -> DataTableResult<(Schema, Vec>)> { - crate::profile_function!(); + re_tracing::profile_function!(); let Self { table_id, @@ -692,7 +692,7 @@ impl DataTable { name: &str, values: &[C], ) -> DataTableResult<(Field, Box)> { - crate::profile_function!(); + re_tracing::profile_function!(); /// Transforms an array of unit values into a list of unit arrays. /// @@ -731,7 +731,7 @@ impl DataTable { values: &[T], datatype: Option, ) -> DataTableResult<(Field, Box)> { - crate::profile_function!(); + re_tracing::profile_function!(); let data = PrimitiveArray::from_slice(values); @@ -755,7 +755,7 @@ impl DataTable { /// They are optional, potentially sparse, and never deserialized on the server-side (not by /// the storage systems, at least). fn serialize_data_columns(&self) -> DataTableResult<(Schema, Vec>)> { - crate::profile_function!(); + re_tracing::profile_function!(); let Self { table_id: _, @@ -789,7 +789,7 @@ impl DataTable { name: &str, column: &[Option], ) -> DataTableResult<(Field, Box)> { - crate::profile_function!(); + re_tracing::profile_function!(); /// Create a list-array out of a flattened array of cell values. /// @@ -875,7 +875,7 @@ impl DataTable { schema: &Schema, chunk: &Chunk>, ) -> DataTableResult { - crate::profile_function!(); + re_tracing::profile_function!(); // --- Time --- @@ -964,7 +964,7 @@ impl DataTable { name: &str, column: &dyn Array, ) -> DataTableResult<(Timeline, TimeOptVec)> { - crate::profile_function!(); + re_tracing::profile_function!(); // See also [`Timeline::datatype`] let timeline = match column.data_type().to_logical_type() { @@ -993,7 +993,7 @@ impl DataTable { component: ComponentName, column: &dyn Array, ) -> DataTableResult { - crate::profile_function!(); + re_tracing::profile_function!(); Ok(DataCellColumn( column .as_any() diff --git a/crates/re_log_types/src/serde_field.rs b/crates/re_log_types/src/serde_field.rs index ae29ffdbedd0..7168f06ce57f 100644 --- a/crates/re_log_types/src/serde_field.rs +++ b/crates/re_log_types/src/serde_field.rs @@ -52,7 +52,7 @@ where v: &::Type, array: &mut Self::MutableArrayType, ) -> arrow2::error::Result<()> { - crate::profile_function!(); + re_tracing::profile_function!(); let mut buf = Vec::new(); rmp_serde::encode::write_named(&mut buf, v).map_err(|err| { arrow2::error::Error::ExternalFormat(format!("Could not encode as rmp: {err}")) @@ -69,7 +69,7 @@ where #[inline] fn arrow_deserialize(v: <&Self::ArrayType as IntoIterator>::Item) -> Option { - crate::profile_function!(); + re_tracing::profile_function!(); v.and_then(|v| rmp_serde::from_slice::(v).ok()) } } diff --git a/crates/re_query/Cargo.toml b/crates/re_query/Cargo.toml index 03e81425c8e4..c899f242f99d 100644 --- a/crates/re_query/Cargo.toml +++ b/crates/re_query/Cargo.toml @@ -26,11 +26,12 @@ polars = ["dep:polars-core", "re_arrow_store/polars"] [dependencies] # Rerun dependencies: re_arrow_store.workspace = true +re_components = { workspace = true, features = ["arrow_datagen"] } re_data_store.workspace = true re_format.workspace = true re_log_types.workspace = true -re_components = { workspace = true, features = ["arrow_datagen"] } re_log.workspace = true +re_tracing.workspace = true # External dependencies: arrow2.workspace = true @@ -57,10 +58,6 @@ polars-core = { workspace = true, features = [ "fmt", ] } -# Native dependencies: -[target.'cfg(not(target_arch = "wasm32"))'.dependencies] -puffin.workspace = true - [lib] bench = false diff --git a/crates/re_query/src/lib.rs b/crates/re_query/src/lib.rs index e17a237159fc..6c68acb7d7f0 100644 --- a/crates/re_query/src/lib.rs +++ b/crates/re_query/src/lib.rs @@ -53,25 +53,3 @@ pub enum QueryError { } pub type Result = std::result::Result; - -// --------------------------------------------------------------------------- - -/// Profiling macro for puffin -#[doc(hidden)] -#[macro_export] -macro_rules! profile_function { - ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_function!($($arg)*); - }; -} - -/// Profiling macro for puffin -#[doc(hidden)] -#[macro_export] -macro_rules! profile_scope { - ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_scope!($($arg)*); - }; -} diff --git a/crates/re_query/src/query.rs b/crates/re_query/src/query.rs index 97f9fca7878f..bfa62d5d4e0e 100644 --- a/crates/re_query/src/query.rs +++ b/crates/re_query/src/query.rs @@ -123,7 +123,7 @@ pub fn query_entity_with_primary( ent_path: &EntityPath, components: &[ComponentName], ) -> crate::Result> { - crate::profile_function!(); + re_tracing::profile_function!(); let (row_id, primary) = get_component_with_instances(store, query, ent_path, Primary::name()) .ok_or(QueryError::PrimaryNotFound)?; diff --git a/crates/re_query/src/range.rs b/crates/re_query/src/range.rs index f92b939bfda1..890bb2163dac 100644 --- a/crates/re_query/src/range.rs +++ b/crates/re_query/src/range.rs @@ -27,7 +27,7 @@ pub fn range_entity_with_primary<'a, Primary: Component + 'a, const N: usize>( ent_path: &'a EntityPath, components: [ComponentName; N], ) -> impl Iterator, EntityView)> + 'a { - crate::profile_function!(); + re_tracing::profile_function!(); let primary = Primary::name(); let cluster_key = store.cluster_key(); diff --git a/crates/re_query/src/visit.rs b/crates/re_query/src/visit.rs index 82b5cf17746c..6a28fac52715 100644 --- a/crates/re_query/src/visit.rs +++ b/crates/re_query/src/visit.rs @@ -69,7 +69,7 @@ macro_rules! create_visitor { for<'a> &'a $CC::ArrayType: IntoIterator, )* { - crate::profile_function!(); + re_tracing::profile_function!(); ::itertools::izip!( self.primary.iter_instance_keys(), diff --git a/crates/re_renderer/Cargo.toml b/crates/re_renderer/Cargo.toml index 7f085fb27076..008917cc5d2d 100644 --- a/crates/re_renderer/Cargo.toml +++ b/crates/re_renderer/Cargo.toml @@ -44,6 +44,7 @@ webgl = ["wgpu/webgl"] [dependencies] re_error.workspace = true re_log.workspace = true +re_tracing.workspace = true ahash.workspace = true anyhow.workspace = true @@ -77,7 +78,6 @@ tobj = { version = "4.0", optional = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] crossbeam.workspace = true notify = "6.0" -puffin.workspace = true wgpu-core.workspace = true # For examples: diff --git a/crates/re_renderer/src/allocator/cpu_write_gpu_read_belt.rs b/crates/re_renderer/src/allocator/cpu_write_gpu_read_belt.rs index 6bc86a60d112..42a62f1d0ed4 100644 --- a/crates/re_renderer/src/allocator/cpu_write_gpu_read_belt.rs +++ b/crates/re_renderer/src/allocator/cpu_write_gpu_read_belt.rs @@ -315,7 +315,7 @@ impl CpuWriteGpuReadBelt { buffer_pool: &GpuBufferPool, num_elements: usize, ) -> CpuWriteGpuReadBuffer { - crate::profile_function!(); + re_tracing::profile_function!(); debug_assert!(num_elements > 0, "Cannot allocate zero-sized buffer"); @@ -378,7 +378,7 @@ impl CpuWriteGpuReadBelt { /// further writes) until after [`CpuWriteGpuReadBelt::after_queue_submit`] is called *and* the GPU is done /// copying the data from them. pub fn before_queue_submit(&mut self) { - crate::profile_function!(); + re_tracing::profile_function!(); // This would be a great usecase for persistent memory mapping, i.e. mapping without the need to unmap // https://github.com/gfx-rs/wgpu/issues/1468 @@ -396,7 +396,7 @@ impl CpuWriteGpuReadBelt { /// copy operations are submitted. Additional calls are harmless. /// Not calling this as soon as possible may result in increased buffer memory usage. pub fn after_queue_submit(&mut self) { - crate::profile_function!(); + re_tracing::profile_function!(); self.receive_chunks(); let sender = &self.sender; diff --git a/crates/re_renderer/src/allocator/gpu_readback_belt.rs b/crates/re_renderer/src/allocator/gpu_readback_belt.rs index d20e231cb269..62aad3775d4e 100644 --- a/crates/re_renderer/src/allocator/gpu_readback_belt.rs +++ b/crates/re_renderer/src/allocator/gpu_readback_belt.rs @@ -247,7 +247,7 @@ impl GpuReadbackBelt { identifier: GpuReadbackIdentifier, user_data: GpuReadbackUserDataStorage, ) -> GpuReadbackBuffer { - crate::profile_function!(); + re_tracing::profile_function!(); debug_assert!(size_in_bytes > 0, "Cannot allocate zero-sized buffer"); @@ -302,7 +302,7 @@ impl GpuReadbackBelt { /// /// This should be called after the command encoder(s) used in [`GpuReadbackBuffer`] copy operations are submitted. pub fn after_queue_submit(&mut self) { - crate::profile_function!(); + re_tracing::profile_function!(); for chunk in self.active_chunks.drain(..) { let sender = self.sender.clone(); chunk.buffer.clone().slice(..chunk.unused_offset).map_async( @@ -366,7 +366,7 @@ impl GpuReadbackBelt { identifier: GpuReadbackIdentifier, callback: impl FnOnce(&[u8], Box), ) { - crate::profile_function!(); + re_tracing::profile_function!(); self.receive_chunks(); diff --git a/crates/re_renderer/src/context.rs b/crates/re_renderer/src/context.rs index a2c8d032b819..048dc071ec53 100644 --- a/crates/re_renderer/src/context.rs +++ b/crates/re_renderer/src/context.rs @@ -65,7 +65,7 @@ impl Renderers { resolver: &mut FileResolver, ) -> &R { self.renderers.entry().or_insert_with(|| { - crate::profile_scope!("create_renderer", std::any::type_name::()); + re_tracing::profile_scope!("create_renderer", std::any::type_name::()); R::create_renderer(shared_data, resource_pools, device, resolver) }) } @@ -111,7 +111,7 @@ impl RenderContext { queue: Arc, config: RenderContextConfig, ) -> Self { - crate::profile_function!(); + re_tracing::profile_function!(); let mut gpu_resources = WgpuResourcePools::default(); let global_bindings = GlobalBindings::new(&mut gpu_resources, &device); @@ -230,7 +230,7 @@ impl RenderContext { } fn poll_device(&mut self) { - crate::profile_function!(); + re_tracing::profile_function!(); // Browsers don't let us wait for GPU work via `poll`: // @@ -276,7 +276,7 @@ impl RenderContext { /// /// Updates internal book-keeping, frame allocators and executes delayed events like shader reloading. pub fn begin_frame(&mut self) { - crate::profile_function!(); + re_tracing::profile_function!(); // If the currently active frame still has an encoder, we need to finish it and queue it. // This should only ever happen for the first frame where we created an encoder for preparatory work. Every other frame we take the encoder at submit! @@ -366,7 +366,7 @@ impl RenderContext { /// Call this at the end of a frame but before submitting command buffers (e.g. from [`crate::view_builder::ViewBuilder`]) pub fn before_submit(&mut self) { - crate::profile_function!(); + re_tracing::profile_function!(); // Unmap all write staging buffers. self.cpu_write_gpu_read_belt.lock().before_queue_submit(); @@ -378,7 +378,7 @@ impl RenderContext { .0 .take() { - crate::profile_scope!("finish & submit frame-global encoder"); + re_tracing::profile_scope!("finish & submit frame-global encoder"); let command_buffer = command_encoder.finish(); // TODO(andreas): For better performance, we should try to bundle this with the single submit call that is currently happening in eframe. diff --git a/crates/re_renderer/src/draw_phases/outlines.rs b/crates/re_renderer/src/draw_phases/outlines.rs index 2b2c709d5225..79eed3709ac9 100644 --- a/crates/re_renderer/src/draw_phases/outlines.rs +++ b/crates/re_renderer/src/draw_phases/outlines.rs @@ -202,7 +202,7 @@ impl OutlineMaskProcessor { view_name: &DebugLabel, resolution_in_pixel: [u32; 2], ) -> Self { - crate::profile_function!(); + re_tracing::profile_function!(); let instance_label: DebugLabel = format!("{view_name} - OutlineMaskProcessor").into(); // ------------- Textures ------------- diff --git a/crates/re_renderer/src/draw_phases/picking_layer.rs b/crates/re_renderer/src/draw_phases/picking_layer.rs index d2466a1d7329..e16ee40083c0 100644 --- a/crates/re_renderer/src/draw_phases/picking_layer.rs +++ b/crates/re_renderer/src/draw_phases/picking_layer.rs @@ -312,7 +312,7 @@ impl PickingLayerProcessor { view_name: &DebugLabel, encoder: &'a mut wgpu::CommandEncoder, ) -> wgpu::RenderPass<'a> { - crate::profile_function!(); + re_tracing::profile_function!(); let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { label: DebugLabel::from(format!("{view_name} - picking_layer pass")).get(), diff --git a/crates/re_renderer/src/draw_phases/screenshot.rs b/crates/re_renderer/src/draw_phases/screenshot.rs index 79cac54c1a6a..b5759245ed9e 100644 --- a/crates/re_renderer/src/draw_phases/screenshot.rs +++ b/crates/re_renderer/src/draw_phases/screenshot.rs @@ -79,7 +79,7 @@ impl ScreenshotProcessor { view_name: &DebugLabel, encoder: &'a mut wgpu::CommandEncoder, ) -> wgpu::RenderPass<'a> { - crate::profile_function!(); + re_tracing::profile_function!(); let pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { label: DebugLabel::from(format!("{view_name} - screenshot")).get(), diff --git a/crates/re_renderer/src/file_resolver.rs b/crates/re_renderer/src/file_resolver.rs index 09220b7d73b2..5a22be91bed6 100644 --- a/crates/re_renderer/src/file_resolver.rs +++ b/crates/re_renderer/src/file_resolver.rs @@ -505,7 +505,7 @@ impl FileResolver { impl FileResolver { pub fn populate(&mut self, path: impl AsRef) -> anyhow::Result { - crate::profile_function!(); + re_tracing::profile_function!(); fn populate_rec( this: &mut FileResolver, diff --git a/crates/re_renderer/src/importer/gltf.rs b/crates/re_renderer/src/importer/gltf.rs index bcf43901dc9d..40ffcb9d382e 100644 --- a/crates/re_renderer/src/importer/gltf.rs +++ b/crates/re_renderer/src/importer/gltf.rs @@ -21,16 +21,16 @@ pub fn load_gltf_from_buffer( lifetime: ResourceLifeTime, ctx: &mut RenderContext, ) -> anyhow::Result> { - crate::profile_function!(); + re_tracing::profile_function!(); let (doc, buffers, images) = { - crate::profile_scope!("gltf::import_slice"); + re_tracing::profile_scope!("gltf::import_slice"); gltf::import_slice(buffer)? }; let mut images_as_textures = Vec::with_capacity(images.len()); for (_index, image) in images.into_iter().enumerate() { - crate::profile_scope!("image"); + re_tracing::profile_scope!("image"); let (format, data) = if let Some(format) = map_format(image.format) { (format, image.pixels) @@ -90,7 +90,7 @@ pub fn load_gltf_from_buffer( let mut meshes = HashMap::with_capacity(doc.meshes().len()); for ref mesh in doc.meshes() { - crate::profile_scope!("mesh"); + re_tracing::profile_scope!("mesh"); let re_mesh = import_mesh( mesh, @@ -145,7 +145,7 @@ fn import_mesh( gpu_image_handles: &[GpuTexture2D], texture_manager: &mut TextureManager2D, //imported_materials: HashMap, ) -> anyhow::Result { - crate::profile_function!(); + re_tracing::profile_function!(); let mut indices = Vec::new(); let mut vertex_positions = Vec::new(); diff --git a/crates/re_renderer/src/importer/obj.rs b/crates/re_renderer/src/importer/obj.rs index cf2b305da0ec..2bafa92a4fb6 100644 --- a/crates/re_renderer/src/importer/obj.rs +++ b/crates/re_renderer/src/importer/obj.rs @@ -17,7 +17,7 @@ pub fn load_obj_from_buffer( lifetime: ResourceLifeTime, ctx: &mut RenderContext, ) -> anyhow::Result> { - crate::profile_function!(); + re_tracing::profile_function!(); let (models, _materials) = tobj::load_obj_buf( &mut std::io::Cursor::new(buffer), diff --git a/crates/re_renderer/src/lib.rs b/crates/re_renderer/src/lib.rs index b4067b7ec7e8..9d02a76580eb 100644 --- a/crates/re_renderer/src/lib.rs +++ b/crates/re_renderer/src/lib.rs @@ -93,31 +93,9 @@ pub type Buffer = Vec; // --------------------------------------------------------------------------- -/// Profiling macro for puffin -#[doc(hidden)] -#[macro_export] -macro_rules! profile_function { - ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_function!($($arg)*); - }; -} - -/// Profiling macro for puffin -#[doc(hidden)] -#[macro_export] -macro_rules! profile_scope { - ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_scope!($($arg)*); - }; -} - -// --------------------------------------------------------------------------- - /// Pad `RGB` to `RGBA` with the given alpha. pub fn pad_rgb_to_rgba(rgb: &[T], alpha: T) -> Vec { - crate::profile_function!(); + re_tracing::profile_function!(); if cfg!(debug_assertions) { // fastest version in debug builds. // 5x faster in debug builds, but 2x slower in release diff --git a/crates/re_renderer/src/mesh.rs b/crates/re_renderer/src/mesh.rs index b6bbdbff1c42..2e22cf3e14dd 100644 --- a/crates/re_renderer/src/mesh.rs +++ b/crates/re_renderer/src/mesh.rs @@ -71,7 +71,7 @@ pub struct Mesh { impl Mesh { pub fn sanity_check(&self) -> Result<(), MeshError> { - crate::profile_function!(); + re_tracing::profile_function!(); let num_pos = self.vertex_positions.len(); let num_color = self.vertex_colors.len(); diff --git a/crates/re_renderer/src/point_cloud_builder.rs b/crates/re_renderer/src/point_cloud_builder.rs index e09daa649b42..39a7f4b2f7e3 100644 --- a/crates/re_renderer/src/point_cloud_builder.rs +++ b/crates/re_renderer/src/point_cloud_builder.rs @@ -170,7 +170,7 @@ impl<'a> PointCloudBatchBuilder<'a> { // or potentially make `FixedSizedIterator` work correctly. This should be possible size the // underlying arrow structures are of known-size, but carries some complexity with the amount of // chaining, joining, filtering, etc. that happens along the way. - crate::profile_function!(); + re_tracing::profile_function!(); debug_assert_eq!(self.0.vertices.len(), self.0.color_buffer.num_written()); debug_assert_eq!( @@ -192,7 +192,7 @@ impl<'a> PointCloudBatchBuilder<'a> { self.batch_mut().point_count += num_points as u32; { - crate::profile_scope!("positions"); + re_tracing::profile_scope!("positions"); let num_before = self.0.vertices.len(); self.0.vertices.extend( positions @@ -211,7 +211,7 @@ impl<'a> PointCloudBatchBuilder<'a> { ); } { - crate::profile_scope!("colors"); + re_tracing::profile_scope!("colors"); let num_written = self.0.color_buffer.extend(colors.take(num_points)); // Fill up with defaults. Doing this in a separate step is faster than chaining the iterator. self.0 @@ -219,7 +219,7 @@ impl<'a> PointCloudBatchBuilder<'a> { .extend(std::iter::repeat(Color32::TRANSPARENT).take(num_points - num_written)); } { - crate::profile_scope!("picking_instance_ids"); + re_tracing::profile_scope!("picking_instance_ids"); let num_written = self .0 .picking_instance_ids_buffer diff --git a/crates/re_renderer/src/renderer/depth_cloud.rs b/crates/re_renderer/src/renderer/depth_cloud.rs index d0884e3767f2..14887326b9ac 100644 --- a/crates/re_renderer/src/renderer/depth_cloud.rs +++ b/crates/re_renderer/src/renderer/depth_cloud.rs @@ -203,7 +203,7 @@ impl DepthCloudDrawData { ctx: &mut RenderContext, depth_clouds: &DepthClouds, ) -> Result { - crate::profile_function!(); + re_tracing::profile_function!(); let DepthClouds { clouds: depth_clouds, @@ -314,7 +314,7 @@ impl Renderer for DepthCloudRenderer { device: &wgpu::Device, resolver: &mut FileResolver, ) -> Self { - crate::profile_function!(); + re_tracing::profile_function!(); let bind_group_layout = pools.bind_group_layouts.get_or_create( device, @@ -435,7 +435,7 @@ impl Renderer for DepthCloudRenderer { pass: &mut wgpu::RenderPass<'a>, draw_data: &'a Self::RendererDrawData, ) -> anyhow::Result<()> { - crate::profile_function!(); + re_tracing::profile_function!(); if draw_data.instances.is_empty() { return Ok(()); } diff --git a/crates/re_renderer/src/renderer/generic_skybox.rs b/crates/re_renderer/src/renderer/generic_skybox.rs index e088c8b3a17d..f72620feaebe 100644 --- a/crates/re_renderer/src/renderer/generic_skybox.rs +++ b/crates/re_renderer/src/renderer/generic_skybox.rs @@ -50,7 +50,7 @@ impl Renderer for GenericSkybox { device: &wgpu::Device, resolver: &mut FileResolver, ) -> Self { - crate::profile_function!(); + re_tracing::profile_function!(); let vertex_handle = screen_triangle_vertex_shader(pools, device, resolver); let render_pipeline = pools.render_pipelines.get_or_create( @@ -101,7 +101,7 @@ impl Renderer for GenericSkybox { pass: &mut wgpu::RenderPass<'a>, _draw_data: &GenericSkyboxDrawData, ) -> anyhow::Result<()> { - crate::profile_function!(); + re_tracing::profile_function!(); let pipeline = pools.render_pipelines.get_resource(self.render_pipeline)?; diff --git a/crates/re_renderer/src/renderer/mesh_renderer.rs b/crates/re_renderer/src/renderer/mesh_renderer.rs index 9e822f4791c7..32c2852b1570 100644 --- a/crates/re_renderer/src/renderer/mesh_renderer.rs +++ b/crates/re_renderer/src/renderer/mesh_renderer.rs @@ -154,7 +154,7 @@ impl MeshDrawData { /// If you pass zero mesh instances, subsequent drawing will do nothing. /// Mesh data itself is gpu uploaded if not already present. pub fn new(ctx: &mut RenderContext, instances: &[MeshInstance]) -> anyhow::Result { - crate::profile_function!(); + re_tracing::profile_function!(); let _mesh_renderer = ctx.renderers.write().get_or_create::<_, MeshRenderer>( &ctx.shared_renderer_data, @@ -300,7 +300,7 @@ impl Renderer for MeshRenderer { device: &wgpu::Device, resolver: &mut FileResolver, ) -> Self { - crate::profile_function!(); + re_tracing::profile_function!(); let bind_group_layout = pools.bind_group_layouts.get_or_create( device, @@ -421,7 +421,7 @@ impl Renderer for MeshRenderer { pass: &mut wgpu::RenderPass<'a>, draw_data: &'a Self::RendererDrawData, ) -> anyhow::Result<()> { - crate::profile_function!(); + re_tracing::profile_function!(); let Some(instance_buffer) = &draw_data.instance_buffer else { return Ok(()); // Instance buffer was empty. diff --git a/crates/re_renderer/src/renderer/point_cloud.rs b/crates/re_renderer/src/renderer/point_cloud.rs index c47f36ce9db0..0dcad048a145 100644 --- a/crates/re_renderer/src/renderer/point_cloud.rs +++ b/crates/re_renderer/src/renderer/point_cloud.rs @@ -187,7 +187,7 @@ impl PointCloudDrawData { ctx: &mut RenderContext, mut builder: PointCloudBuilder, ) -> Result { - crate::profile_function!(); + re_tracing::profile_function!(); let mut renderers = ctx.renderers.write(); let point_renderer = renderers.get_or_create::<_, PointCloudRenderer>( @@ -295,7 +295,7 @@ impl PointCloudDrawData { ); { - crate::profile_scope!("write_pos_size_texture"); + re_tracing::profile_scope!("write_pos_size_texture"); let mut staging_buffer = ctx.cpu_write_gpu_read_belt.lock().allocate( &ctx.device, @@ -553,7 +553,7 @@ impl Renderer for PointCloudRenderer { device: &wgpu::Device, resolver: &mut FileResolver, ) -> Self { - crate::profile_function!(); + re_tracing::profile_function!(); let bind_group_layout_all_points = pools.bind_group_layouts.get_or_create( device, diff --git a/crates/re_renderer/src/renderer/rectangles.rs b/crates/re_renderer/src/renderer/rectangles.rs index 3a7960d5260b..2ce1edbd7dbc 100644 --- a/crates/re_renderer/src/renderer/rectangles.rs +++ b/crates/re_renderer/src/renderer/rectangles.rs @@ -349,7 +349,7 @@ impl RectangleDrawData { ctx: &mut RenderContext, rectangles: &[TexturedRect], ) -> Result { - crate::profile_function!(); + re_tracing::profile_function!(); let mut renderers = ctx.renderers.write(); let rectangle_renderer = renderers.get_or_create::<_, RectangleRenderer>( @@ -485,7 +485,7 @@ impl Renderer for RectangleRenderer { device: &wgpu::Device, resolver: &mut FileResolver, ) -> Self { - crate::profile_function!(); + re_tracing::profile_function!(); let bind_group_layout = pools.bind_group_layouts.get_or_create( device, @@ -654,7 +654,7 @@ impl Renderer for RectangleRenderer { pass: &mut wgpu::RenderPass<'a>, draw_data: &'a Self::RendererDrawData, ) -> anyhow::Result<()> { - crate::profile_function!(); + re_tracing::profile_function!(); if draw_data.instances.is_empty() { return Ok(()); } diff --git a/crates/re_renderer/src/resource_managers/texture_manager.rs b/crates/re_renderer/src/resource_managers/texture_manager.rs index f754529db937..5a9469d7170b 100644 --- a/crates/re_renderer/src/resource_managers/texture_manager.rs +++ b/crates/re_renderer/src/resource_managers/texture_manager.rs @@ -159,7 +159,7 @@ impl TextureManager2D { queue: Arc, texture_pool: &mut GpuTexturePool, ) -> Self { - crate::profile_function!(); + re_tracing::profile_function!(); let white_texture_unorm = Self::create_and_upload_texture( &device, @@ -314,7 +314,7 @@ impl TextureManager2D { texture_pool: &mut GpuTexturePool, creation_desc: &Texture2DCreationDesc<'_>, ) -> Result { - crate::profile_function!(); + re_tracing::profile_function!(); if creation_desc.width == 0 || creation_desc.height == 0 { return Err(TextureCreationError::ZeroSize(creation_desc.label.clone())); @@ -354,7 +354,7 @@ impl TextureManager2D { // TODO(andreas): temp allocator for staging data? // We don't do any further validation of the buffer here as wgpu does so extensively. - crate::profile_scope!("write_texture"); + re_tracing::profile_scope!("write_texture"); queue.write_texture( wgpu::ImageCopyTexture { texture: &texture.texture, diff --git a/crates/re_renderer/src/texture_info.rs b/crates/re_renderer/src/texture_info.rs index e18d447e62f8..7982c61d90c2 100644 --- a/crates/re_renderer/src/texture_info.rs +++ b/crates/re_renderer/src/texture_info.rs @@ -55,7 +55,7 @@ impl Texture2DBufferInfo { /// Note that if you're passing in gpu data, there no alignment guarantees on the returned slice, /// do NOT convert it using [`bytemuck`]. Use [`Texture2DBufferInfo::remove_padding_and_convert`] instead. pub fn remove_padding<'a>(&self, buffer: &'a [u8]) -> Cow<'a, [u8]> { - crate::profile_function!(); + re_tracing::profile_function!(); assert_eq!(buffer.len() as wgpu::BufferAddress, self.buffer_size_padded); @@ -82,7 +82,7 @@ impl Texture2DBufferInfo { /// The unpadded row size is expected to be a multiple of the size of the target type. /// (Which means that, while uncommon, it technically doesn't need to be as big as a block in the pixel - this can be useful for e.g. packing wide bitfields) pub fn remove_padding_and_convert(&self, buffer: &[u8]) -> Vec { - crate::profile_function!(); + re_tracing::profile_function!(); assert_eq!(buffer.len() as wgpu::BufferAddress, self.buffer_size_padded); assert!(self.bytes_per_row_unpadded % std::mem::size_of::() as u32 == 0); diff --git a/crates/re_renderer/src/view_builder.rs b/crates/re_renderer/src/view_builder.rs index fc987ece35f7..a59a62adee91 100644 --- a/crates/re_renderer/src/view_builder.rs +++ b/crates/re_renderer/src/view_builder.rs @@ -276,7 +276,7 @@ impl ViewBuilder { }); pub fn new(ctx: &mut RenderContext, config: TargetConfiguration) -> Self { - crate::profile_function!(); + re_tracing::profile_function!(); // Can't handle 0 size resolution since this would imply creating zero sized textures. assert_ne!(config.resolution_in_pixel[0], 0); @@ -514,7 +514,7 @@ impl ViewBuilder { phase: DrawPhase, pass: &mut wgpu::RenderPass<'a>, ) { - crate::profile_function!(); + re_tracing::profile_function!(); for queued_draw in &self.queued_draws { if queued_draw.participated_phases.contains(&phase) { @@ -532,7 +532,7 @@ impl ViewBuilder { &mut self, draw_data: &D, ) -> &mut Self { - crate::profile_function!(); + re_tracing::profile_function!(); self.queued_draws.push(queued_draw(draw_data)); self @@ -544,7 +544,7 @@ impl ViewBuilder { ctx: &RenderContext, clear_color: Rgba, ) -> Result { - crate::profile_function!(); + re_tracing::profile_function!(); let setup = &self.setup; @@ -555,7 +555,7 @@ impl ViewBuilder { }); { - crate::profile_scope!("main target pass"); + re_tracing::profile_scope!("main target pass"); let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { label: DebugLabel::from(format!("{} - main pass", setup.name)).get(), @@ -619,9 +619,9 @@ impl ViewBuilder { } if let Some(outline_mask_processor) = self.outline_mask_processor.take() { - crate::profile_scope!("outlines"); + re_tracing::profile_scope!("outlines"); { - crate::profile_scope!("outline mask pass"); + re_tracing::profile_scope!("outline mask pass"); let mut pass = outline_mask_processor.start_mask_render_pass(&mut encoder); pass.set_bind_group(0, &setup.bind_group_0, &[]); self.draw_phase(ctx, DrawPhase::OutlineMask, &mut pass); @@ -768,7 +768,7 @@ impl ViewBuilder { pass: &mut wgpu::RenderPass<'a>, screen_position: glam::Vec2, ) { - crate::profile_function!(); + re_tracing::profile_function!(); pass.set_viewport( screen_position.x, diff --git a/crates/re_renderer/src/wgpu_resources/buffer_pool.rs b/crates/re_renderer/src/wgpu_resources/buffer_pool.rs index 5f20566cbc4e..4ef2fb8810d0 100644 --- a/crates/re_renderer/src/wgpu_resources/buffer_pool.rs +++ b/crates/re_renderer/src/wgpu_resources/buffer_pool.rs @@ -60,9 +60,9 @@ impl GpuBufferPool { /// For more efficient allocation (faster, less fragmentation) you should sub-allocate buffers whenever possible /// either manually or using a higher level allocator. pub fn alloc(&self, device: &wgpu::Device, desc: &BufferDesc) -> GpuBuffer { - crate::profile_function!(); + re_tracing::profile_function!(); self.pool.alloc(desc, |desc| { - crate::profile_scope!("create_buffer"); + re_tracing::profile_scope!("create_buffer"); device.create_buffer(&wgpu::BufferDescriptor { label: desc.label.get(), size: desc.size, diff --git a/crates/re_renderer/src/wgpu_resources/dynamic_resource_pool.rs b/crates/re_renderer/src/wgpu_resources/dynamic_resource_pool.rs index 679bf0c6edb7..dcc66ac957ff 100644 --- a/crates/re_renderer/src/wgpu_resources/dynamic_resource_pool.rs +++ b/crates/re_renderer/src/wgpu_resources/dynamic_resource_pool.rs @@ -89,7 +89,7 @@ where desc: &Desc, creation_func: F, ) -> Arc> { - crate::profile_function!(); + re_tracing::profile_function!(); let mut state = self.state.write(); // First check if we can reclaim a resource we have around from a previous frame. @@ -109,7 +109,7 @@ where // Otherwise create a new resource re_log::trace!(?desc, "Allocated new resource"); let inner_resource = { - crate::profile_scope!("creation_func"); + re_tracing::profile_scope!("creation_func"); creation_func(desc) }; self.total_resource_size_in_bytes.fetch_add( @@ -147,7 +147,7 @@ where } pub fn begin_frame(&mut self, frame_index: u64, mut on_destroy_resource: impl FnMut(&Res)) { - crate::profile_function!(); + re_tracing::profile_function!(); self.current_frame_index = frame_index; let state = self.state.get_mut(); diff --git a/crates/re_renderer/src/wgpu_resources/render_pipeline_pool.rs b/crates/re_renderer/src/wgpu_resources/render_pipeline_pool.rs index 13ad98812f29..27acdef47b9b 100644 --- a/crates/re_renderer/src/wgpu_resources/render_pipeline_pool.rs +++ b/crates/re_renderer/src/wgpu_resources/render_pipeline_pool.rs @@ -179,7 +179,7 @@ impl GpuRenderPipelinePool { shader_modules: &mut GpuShaderModulePool, pipeline_layouts: &mut GpuPipelineLayoutPool, ) { - crate::profile_function!(); + re_tracing::profile_function!(); self.pool.current_frame_index = frame_index; // Recompile render pipelines referencing shader modules that have been recompiled this frame. diff --git a/crates/re_renderer/src/wgpu_resources/static_resource_pool.rs b/crates/re_renderer/src/wgpu_resources/static_resource_pool.rs index bdcba8c39cad..66e7f4976748 100644 --- a/crates/re_renderer/src/wgpu_resources/static_resource_pool.rs +++ b/crates/re_renderer/src/wgpu_resources/static_resource_pool.rs @@ -51,7 +51,10 @@ where creation_func: F, ) -> Handle { *self.lookup.entry(desc.clone()).or_insert_with(|| { - crate::profile_scope!("Creating new static resource", std::any::type_name::()); + re_tracing::profile_scope!( + "Creating new static resource", + std::any::type_name::() + ); re_log::trace!(?desc, "Created new resource"); let resource = creation_func(desc); self.resources.insert(StoredResource { @@ -65,7 +68,7 @@ where } pub fn recreate_resources Option>(&mut self, mut recreation_func: F) { - crate::profile_function!(); + re_tracing::profile_function!(); for (desc, handle) in &self.lookup { if let Some(new_resource) = recreation_func(desc) { diff --git a/crates/re_renderer/src/wgpu_resources/texture_pool.rs b/crates/re_renderer/src/wgpu_resources/texture_pool.rs index d194b387f773..b6a86936c513 100644 --- a/crates/re_renderer/src/wgpu_resources/texture_pool.rs +++ b/crates/re_renderer/src/wgpu_resources/texture_pool.rs @@ -111,7 +111,7 @@ impl GpuTexturePool { /// Returns a reference-counted handle to a currently unused texture. /// Once ownership to the handle is given up, the texture may be reclaimed in future frames. pub fn alloc(&self, device: &wgpu::Device, desc: &TextureDesc) -> GpuTexture { - crate::profile_function!(); + re_tracing::profile_function!(); self.pool.alloc(desc, |desc| { let texture = device.create_texture(&wgpu::TextureDescriptor { label: desc.label.get(), diff --git a/crates/re_time_panel/Cargo.toml b/crates/re_time_panel/Cargo.toml index 587f3a24d7e9..6edfeccab5b7 100644 --- a/crates/re_time_panel/Cargo.toml +++ b/crates/re_time_panel/Cargo.toml @@ -21,6 +21,7 @@ re_data_store.workspace = true re_data_ui.workspace = true re_format.workspace = true re_log_types.workspace = true +re_tracing.workspace = true re_ui.workspace = true re_viewer_context.workspace = true @@ -28,6 +29,3 @@ egui.workspace = true itertools.workspace = true serde = "1.0" vec1 = "1.8" - -[target.'cfg(not(target_arch = "wasm32"))'.dependencies] -puffin.workspace = true diff --git a/crates/re_time_panel/src/data_density_graph.rs b/crates/re_time_panel/src/data_density_graph.rs index 353fa4516fda..20f8cc54e7a6 100644 --- a/crates/re_time_panel/src/data_density_graph.rs +++ b/crates/re_time_panel/src/data_density_graph.rs @@ -193,7 +193,7 @@ impl DensityGraph { full_color: Color32, hovered_x_range: RangeInclusive, ) { - crate::profile_function!(); + re_tracing::profile_function!(); let (min_y, max_y) = (*y_range.start(), *y_range.end()); let center_y = (min_y + max_y) / 2.0; @@ -281,7 +281,7 @@ impl DensityGraph { { // I also tried writing this as `flat_map + collect`, but it got much slower in debug builds. - crate::profile_scope!("triangles"); + re_tracing::profile_scope!("triangles"); mesh.indices.reserve(6 * 3 * (self.buckets.len() - 1)); for i in 1..self.buckets.len() { let i = i as u32; @@ -323,7 +323,7 @@ impl DensityGraph { /// Blur the input slightly. fn smooth(density: &[f32]) -> Vec { - crate::profile_function!(); + re_tracing::profile_function!(); fn kernel(x: f32) -> f32 { (0.25 * std::f32::consts::TAU * x).cos() @@ -372,7 +372,7 @@ pub fn data_density_graph_ui( time_ranges_ui: &TimeRangesUi, item: Item, ) { - crate::profile_function!(); + re_tracing::profile_function!(); let pointer_pos = ui.input(|i| i.pointer.hover_pos()); let interact_radius_sq = ui.style().interaction.resize_grab_radius_side.powi(2); @@ -437,7 +437,7 @@ pub fn data_density_graph_ui( let time_chunk_size = (chunk_size_in_ui_points / time_ranges_ui.points_per_time).round() as _; let ranges: Vec<_> = { - crate::profile_scope!("time_histogram.range"); + re_tracing::profile_scope!("time_histogram.range"); time_histogram .range( visible_time_range.min.as_i64()..=visible_time_range.max.as_i64(), @@ -446,7 +446,7 @@ pub fn data_density_graph_ui( .collect() }; - crate::profile_scope!("add_data_point"); + re_tracing::profile_scope!("add_data_point"); for (time_range, num_messages_at_time) in ranges { add_data_point( TimeRange::new(time_range.min.into(), time_range.max.into()), diff --git a/crates/re_time_panel/src/lib.rs b/crates/re_time_panel/src/lib.rs index 765f8e6d57a0..45019bcfc8b7 100644 --- a/crates/re_time_panel/src/lib.rs +++ b/crates/re_time_panel/src/lib.rs @@ -188,7 +188,7 @@ impl TimePanel { } fn expanded_ui(&mut self, ctx: &mut ViewerContext<'_>, ui: &mut egui::Ui) { - crate::profile_function!(); + re_tracing::profile_function!(); self.data_dentity_graph_painter.begin_frame(ui.ctx()); @@ -345,7 +345,7 @@ impl TimePanel { time_area_painter: &egui::Painter, ui: &mut egui::Ui, ) { - crate::profile_function!(); + re_tracing::profile_function!(); egui::ScrollArea::vertical() .auto_shrink([false; 2]) @@ -724,7 +724,7 @@ fn initialize_time_ranges_ui( time_x_range: RangeInclusive, mut time_view: Option, ) -> TimeRangesUi { - crate::profile_function!(); + re_tracing::profile_function!(); // If there's any timeless data, add the "beginning range" that contains timeless data. let mut time_range = if ctx.log_db.num_timeless_messages() > 0 { @@ -791,7 +791,7 @@ fn paint_time_ranges_gaps( painter: &egui::Painter, y_range: RangeInclusive, ) { - crate::profile_function!(); + re_tracing::profile_function!(); // For each gap we are painting this: // @@ -1076,25 +1076,3 @@ fn time_marker_ui( } } } - -// --------------------------------------------------------------------------- - -/// Wrapper around puffin profiler on native, no-op on weasm -#[doc(hidden)] -#[macro_export] -macro_rules! profile_function { - ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_function!($($arg)*); - }; -} - -/// Wrapper around puffin profiler on native, no-op on weasm -#[doc(hidden)] -#[macro_export] -macro_rules! profile_scope { - ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_scope!($($arg)*); - }; -} diff --git a/crates/re_time_panel/src/paint_ticks.rs b/crates/re_time_panel/src/paint_ticks.rs index 3bf5076702ce..5620636bf686 100644 --- a/crates/re_time_panel/src/paint_ticks.rs +++ b/crates/re_time_panel/src/paint_ticks.rs @@ -100,7 +100,7 @@ fn paint_ticks( next_time_step: fn(i64) -> i64, format_tick: fn(i64) -> String, ) -> Vec { - crate::profile_function!(); + re_tracing::profile_function!(); let color_from_alpha = |alpha: f32| -> Color32 { if dark_mode { diff --git a/crates/re_time_panel/src/time_axis.rs b/crates/re_time_panel/src/time_axis.rs index cdb6e8192e44..941731209812 100644 --- a/crates/re_time_panel/src/time_axis.rs +++ b/crates/re_time_panel/src/time_axis.rs @@ -14,7 +14,7 @@ pub(crate) struct TimelineAxis { impl TimelineAxis { pub fn new(time_type: TimeType, times: &TimeHistogram) -> Self { - crate::profile_function!(); + re_tracing::profile_function!(); assert!(!times.is_empty()); let gap_threshold = gap_size_heuristic(time_type, times); Self { @@ -49,7 +49,7 @@ impl TimelineAxis { /// We also don't want to produce a timeline of only gaps. /// Finding a perfect heuristic is impossible, but we do our best! fn gap_size_heuristic(time_type: TimeType, times: &TimeHistogram) -> u64 { - crate::profile_function!(); + re_tracing::profile_function!(); assert!(!times.is_empty()); @@ -104,7 +104,7 @@ fn collect_candidate_gaps( min_gap_size: u64, max_collapses: usize, ) -> Vec { - crate::profile_function!(); + re_tracing::profile_function!(); // We want this to be fast, even when we have _a lot_ of times. // `TimeHistogram::range` has a granularity argument: // - if it make it too small, we get too many gaps and run very slow @@ -128,7 +128,7 @@ fn collect_gaps_with_granularity( granularity: u64, min_gap_size: u64, ) -> Vec { - crate::profile_function!(); + re_tracing::profile_function!(); times .range(.., granularity) .tuple_windows() @@ -139,7 +139,7 @@ fn collect_gaps_with_granularity( /// Collapse any gaps larger or equals to the given threshold. fn create_ranges(times: &TimeHistogram, gap_threshold: u64) -> vec1::Vec1 { - crate::profile_function!(); + re_tracing::profile_function!(); let mut it = times.range(.., gap_threshold); let first_range = it.next().unwrap().0; let mut ranges = vec1::vec1![TimeRange::new( diff --git a/crates/re_time_panel/src/time_ranges_ui.rs b/crates/re_time_panel/src/time_ranges_ui.rs index 93482286526b..fad781c244cb 100644 --- a/crates/re_time_panel/src/time_ranges_ui.rs +++ b/crates/re_time_panel/src/time_ranges_ui.rs @@ -98,7 +98,7 @@ impl TimeRangesUi { time_view: TimeView, time_ranges: &[TimeRange], ) -> Self { - crate::profile_function!(); + re_tracing::profile_function!(); debug_assert!(x_range.start() < x_range.end()); diff --git a/crates/re_viewer/Cargo.toml b/crates/re_viewer/Cargo.toml index 018391cadaaa..edec0cd51bde 100644 --- a/crates/re_viewer/Cargo.toml +++ b/crates/re_viewer/Cargo.toml @@ -52,6 +52,7 @@ re_memory.workspace = true re_renderer = { workspace = true, default-features = false } re_smart_channel.workspace = true re_time_panel.workspace = true +re_tracing.workspace = true re_ui = { workspace = true, features = ["eframe"] } re_viewer_context.workspace = true re_viewport.workspace = true diff --git a/crates/re_viewer/src/app.rs b/crates/re_viewer/src/app.rs index 746ea0cb7114..bcb5f7002958 100644 --- a/crates/re_viewer/src/app.rs +++ b/crates/re_viewer/src/app.rs @@ -756,7 +756,7 @@ fn wait_screen_ui(ui: &mut egui::Ui, rx: &Receiver) { impl App { /// Show recent text log messages to the user as toast notifications. fn show_text_logs_as_notifications(&mut self) { - crate::profile_function!(); + re_tracing::profile_function!(); while let Ok(re_log::LogMsg { level, target, msg }) = self.text_log_rx.try_recv() { let is_rerun_crate = target.starts_with("rerun") || target.starts_with("re_"); @@ -782,7 +782,7 @@ impl App { } fn receive_messages(&mut self, egui_ctx: &egui::Context) { - crate::profile_function!(); + re_tracing::profile_function!(); let start = web_time::Instant::now(); @@ -849,7 +849,7 @@ impl App { } fn cleanup(&mut self) { - crate::profile_function!(); + re_tracing::profile_function!(); self.log_dbs.retain(|_, log_db| !log_db.is_empty()); @@ -872,7 +872,7 @@ impl App { } fn purge_memory_if_needed(&mut self) { - crate::profile_function!(); + re_tracing::profile_function!(); fn format_limit(limit: Option) -> String { if let Some(bytes) = limit { @@ -900,7 +900,7 @@ impl App { } { - crate::profile_scope!("pruning"); + re_tracing::profile_scope!("pruning"); if let Some(counted) = mem_use_before.counted { re_log::debug!( "Attempting to purge {:.1}% of used RAM ({})…", @@ -1082,7 +1082,7 @@ impl AppState { component_ui_registry: &ComponentUiRegistry, rx: &Receiver, ) { - crate::profile_function!(); + re_tracing::profile_function!(); let Self { app_options: options, @@ -1188,7 +1188,7 @@ fn top_panel( app: &mut App, gpu_resource_stats: &WgpuResourcePoolStatistics, ) { - crate::profile_function!(); + re_tracing::profile_function!(); let native_pixels_per_point = frame.info().native_pixels_per_point; let fullscreen = { @@ -1991,7 +1991,7 @@ fn save_database_to_file( ) -> anyhow::Result anyhow::Result> { use re_arrow_store::TimeRange; - crate::profile_scope!("dump_messages"); + re_tracing::profile_scope!("dump_messages"); let begin_rec_msg = log_db .recording_msg() @@ -2028,7 +2028,7 @@ fn save_database_to_file( .chain(data_msgs); Ok(move || { - crate::profile_scope!("save_to_file"); + re_tracing::profile_scope!("save_to_file"); use anyhow::Context as _; let file = std::fs::File::create(path.as_path()) @@ -2043,7 +2043,7 @@ fn save_database_to_file( #[allow(unused_mut)] fn load_rrd_to_log_db(mut read: impl std::io::Read) -> anyhow::Result { - crate::profile_function!(); + re_tracing::profile_function!(); let mut decoder = re_log_encoding::decoder::Decoder::new(read)?; @@ -2062,7 +2062,7 @@ fn load_rrd_to_log_db(mut read: impl std::io::Read) -> anyhow::Result { #[must_use] fn load_file_path(path: &std::path::Path) -> Option { fn load_file_path_impl(path: &std::path::Path) -> anyhow::Result { - crate::profile_function!(); + re_tracing::profile_function!(); use anyhow::Context as _; let file = std::fs::File::open(path).context("Failed to open file")?; load_rrd_to_log_db(file) diff --git a/crates/re_viewer/src/lib.rs b/crates/re_viewer/src/lib.rs index 8e291361f369..d723c9eccfb0 100644 --- a/crates/re_viewer/src/lib.rs +++ b/crates/re_viewer/src/lib.rs @@ -46,28 +46,6 @@ mod web; // --------------------------------------------------------------------------- -/// Wrapper around puffin profiler on native, no-op on weasm -#[doc(hidden)] -#[macro_export] -macro_rules! profile_function { - ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_function!($($arg)*); - }; -} - -/// Wrapper around puffin profiler on native, no-op on weasm -#[doc(hidden)] -#[macro_export] -macro_rules! profile_scope { - ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_scope!($($arg)*); - }; -} - -// --------------------------------------------------------------------------- - /// Information about this version of the crate. pub fn build_info() -> re_build_info::BuildInfo { re_build_info::build_info!() diff --git a/crates/re_viewer/src/ui/blueprint.rs b/crates/re_viewer/src/ui/blueprint.rs index e1d4cf706db3..c165b80590e0 100644 --- a/crates/re_viewer/src/ui/blueprint.rs +++ b/crates/re_viewer/src/ui/blueprint.rs @@ -32,7 +32,7 @@ impl Blueprint { ctx: &mut ViewerContext<'_>, ui: &mut egui::Ui, ) { - crate::profile_function!(); + re_tracing::profile_function!(); let spaces_info = SpaceInfoCollection::new(&ctx.log_db.entity_db); diff --git a/crates/re_viewer/src/ui/memory_panel.rs b/crates/re_viewer/src/ui/memory_panel.rs index 17af75073f7b..9d8a42f12fbc 100644 --- a/crates/re_viewer/src/ui/memory_panel.rs +++ b/crates/re_viewer/src/ui/memory_panel.rs @@ -21,7 +21,7 @@ impl MemoryPanel { store_stats: &DataStoreStats, blueprint_stats: &DataStoreStats, ) { - crate::profile_function!(); + re_tracing::profile_function!(); self.history.capture( Some( (gpu_resource_stats.total_buffer_size_in_bytes @@ -48,7 +48,7 @@ impl MemoryPanel { store_stats: &DataStoreStats, blueprint_stats: &DataStoreStats, ) { - crate::profile_function!(); + re_tracing::profile_function!(); // We show realtime stats, so keep showing the latest! ui.ctx().request_repaint(); @@ -366,7 +366,7 @@ impl MemoryPanel { } fn plot(&self, ui: &mut egui::Ui, limit: &MemoryLimit) { - crate::profile_function!(); + re_tracing::profile_function!(); use itertools::Itertools as _; diff --git a/crates/re_viewer/src/ui/selection_panel.rs b/crates/re_viewer/src/ui/selection_panel.rs index f5a6318ff529..e9d00d08864d 100644 --- a/crates/re_viewer/src/ui/selection_panel.rs +++ b/crates/re_viewer/src/ui/selection_panel.rs @@ -85,7 +85,7 @@ impl SelectionPanel { ctx: &mut ViewerContext<'_>, blueprint: &mut Blueprint, ) { - crate::profile_function!(); + re_tracing::profile_function!(); let query = ctx.current_query(); @@ -478,7 +478,7 @@ fn depth_props_ui( entity_path: &EntityPath, entity_props: &mut EntityProperties, ) -> Option<()> { - crate::profile_function!(); + re_tracing::profile_function!(); let query = ctx.current_query(); let store = &ctx.log_db.entity_db.data_store; diff --git a/crates/re_viewer_context/Cargo.toml b/crates/re_viewer_context/Cargo.toml index 3a17ed040471..194ebbb8b8c9 100644 --- a/crates/re_viewer_context/Cargo.toml +++ b/crates/re_viewer_context/Cargo.toml @@ -23,6 +23,7 @@ re_log_types.workspace = true re_log.workspace = true re_query.workspace = true re_renderer.workspace = true +re_tracing.workspace = true re_ui.workspace = true ahash.workspace = true @@ -48,4 +49,3 @@ wgpu.workspace = true arboard = { version = "3.2", default-features = false, features = [ "image-data", ] } -puffin.workspace = true diff --git a/crates/re_viewer_context/src/annotations.rs b/crates/re_viewer_context/src/annotations.rs index b83f17f2a3c5..fb730df476a9 100644 --- a/crates/re_viewer_context/src/annotations.rs +++ b/crates/re_viewer_context/src/annotations.rs @@ -126,7 +126,7 @@ impl AnnotationMap { /// /// An entity is considered its own (nearest) ancestor. pub fn load(&mut self, ctx: &mut ViewerContext<'_>, scene_query: &SceneQuery<'_>) { - crate::profile_function!(); + re_tracing::profile_function!(); let mut visited = IntSet::::default(); diff --git a/crates/re_viewer_context/src/component_ui_registry.rs b/crates/re_viewer_context/src/component_ui_registry.rs index 61e500d194ba..32d91df781c8 100644 --- a/crates/re_viewer_context/src/component_ui_registry.rs +++ b/crates/re_viewer_context/src/component_ui_registry.rs @@ -66,7 +66,7 @@ impl ComponentUiRegistry { component: &ComponentWithInstances, instance_key: &InstanceKey, ) { - crate::profile_function!(component.name().full_name()); + re_tracing::profile_function!(component.name().full_name()); if component.name() == InstanceKey::name() { // The user wants to show a ui for the `InstanceKey` component - well, that's easy: diff --git a/crates/re_viewer_context/src/gpu_bridge/mod.rs b/crates/re_viewer_context/src/gpu_bridge/mod.rs index 4cc9f587fdb8..ed4cc4f745a6 100644 --- a/crates/re_viewer_context/src/gpu_bridge/mod.rs +++ b/crates/re_viewer_context/src/gpu_bridge/mod.rs @@ -88,7 +88,7 @@ pub fn renderer_paint_callback( clip_rect: egui::Rect, pixels_from_point: f32, ) -> egui::PaintCallback { - crate::profile_function!(); + re_tracing::profile_function!(); slotmap::new_key_type! { pub struct ViewBuilderHandle; } @@ -119,7 +119,7 @@ pub fn renderer_paint_callback( }, ) .paint(move |_info, render_pass, paint_callback_resources| { - crate::profile_scope!("paint"); + re_tracing::profile_scope!("paint"); // TODO(andreas): This should work as well but doesn't work in the 3d view. // Looks like a bug in egui, but unclear what's going on. //let clip_rect = info.clip_rect_in_pixels(); @@ -144,7 +144,7 @@ pub fn render_image( texture_options: egui::TextureOptions, debug_name: &str, ) -> anyhow::Result<()> { - crate::profile_function!(); + re_tracing::profile_function!(); use re_renderer::renderer::{TextureFilterMag, TextureFilterMin}; diff --git a/crates/re_viewer_context/src/gpu_bridge/tensor_to_gpu.rs b/crates/re_viewer_context/src/gpu_bridge/tensor_to_gpu.rs index f7c4b97fbb23..68765af83fff 100644 --- a/crates/re_viewer_context/src/gpu_bridge/tensor_to_gpu.rs +++ b/crates/re_viewer_context/src/gpu_bridge/tensor_to_gpu.rs @@ -35,7 +35,7 @@ pub fn tensor_to_gpu( tensor_stats: &TensorStats, annotations: &Annotations, ) -> anyhow::Result { - crate::profile_function!(format!( + re_tracing::profile_function!(format!( "meaning: {:?}, dtype: {}, shape: {:?}", tensor.meaning, tensor.dtype(), @@ -398,7 +398,7 @@ fn cast_slice_to_cow(slice: &[From]) -> Cow<'_, [u8]> { // wgpu doesn't support u64 textures, so we need to narrow to f32: fn narrow_u64_to_f32s(slice: &[u64]) -> Cow<'static, [u8]> { - crate::profile_function!(); + re_tracing::profile_function!(); let bytes: Vec = slice .iter() .flat_map(|&f| (f as f32).to_le_bytes()) @@ -408,7 +408,7 @@ fn narrow_u64_to_f32s(slice: &[u64]) -> Cow<'static, [u8]> { // wgpu doesn't support i64 textures, so we need to narrow to f32: fn narrow_i64_to_f32s(slice: &[i64]) -> Cow<'static, [u8]> { - crate::profile_function!(); + re_tracing::profile_function!(); let bytes: Vec = slice .iter() .flat_map(|&f| (f as f32).to_le_bytes()) @@ -418,7 +418,7 @@ fn narrow_i64_to_f32s(slice: &[i64]) -> Cow<'static, [u8]> { // wgpu doesn't support f64 textures, so we need to narrow to f32: fn narrow_f64_to_f32s(slice: &[f64]) -> Cow<'static, [u8]> { - crate::profile_function!(); + re_tracing::profile_function!(); let bytes: Vec = slice .iter() .flat_map(|&f| (f as f32).to_le_bytes()) @@ -427,7 +427,7 @@ fn narrow_f64_to_f32s(slice: &[f64]) -> Cow<'static, [u8]> { } fn pad_and_cast(data: &[T], pad: T) -> Cow<'static, [u8]> { - crate::profile_function!(); + re_tracing::profile_function!(); let padded: Vec = pad_rgb_to_rgba(data, pad); let bytes: Vec = pod_collect_to_vec(&padded); bytes.into() @@ -438,7 +438,7 @@ fn pad_and_narrow_and_cast( pad: f32, narrow: impl Fn(T) -> f32, ) -> Cow<'static, [u8]> { - crate::profile_function!(); + re_tracing::profile_function!(); let floats: Vec = data .chunks_exact(3) diff --git a/crates/re_viewer_context/src/lib.rs b/crates/re_viewer_context/src/lib.rs index 3ed78a38bca5..ac1eb11359c1 100644 --- a/crates/re_viewer_context/src/lib.rs +++ b/crates/re_viewer_context/src/lib.rs @@ -105,25 +105,3 @@ pub enum NeedsRepaint { Yes, No, } - -// --------------------------------------------------------------------------- - -/// Wrapper around puffin profiler on native, no-op on weasm -#[doc(hidden)] -#[macro_export] -macro_rules! profile_function { - ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_function!($($arg)*); - }; -} - -/// Wrapper around puffin profiler on native, no-op on weasm -#[doc(hidden)] -#[macro_export] -macro_rules! profile_scope { - ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_scope!($($arg)*); - }; -} diff --git a/crates/re_viewer_context/src/selection_history.rs b/crates/re_viewer_context/src/selection_history.rs index b2e1a5fc762f..717dde6308e7 100644 --- a/crates/re_viewer_context/src/selection_history.rs +++ b/crates/re_viewer_context/src/selection_history.rs @@ -30,7 +30,7 @@ pub struct SelectionHistory { impl SelectionHistory { /// Retains all elements that fulfil a certain condition. pub fn retain(&mut self, f: &impl Fn(&Item) -> bool) { - crate::profile_function!(); + re_tracing::profile_function!(); let mut i = 0; self.stack.retain_mut(|selection| { diff --git a/crates/re_viewer_context/src/selection_state.rs b/crates/re_viewer_context/src/selection_state.rs index 2365996863fe..0c87ba792613 100644 --- a/crates/re_viewer_context/src/selection_state.rs +++ b/crates/re_viewer_context/src/selection_state.rs @@ -112,7 +112,7 @@ pub struct SelectionState { impl SelectionState { /// Called at the start of each frame pub fn on_frame_start(&mut self, item_retain_condition: impl Fn(&Item) -> bool) { - crate::profile_function!(); + re_tracing::profile_function!(); self.history.retain(&item_retain_condition); @@ -173,7 +173,7 @@ impl SelectionState { /// Select currently hovered objects unless already selected in which case they get unselected. pub fn toggle_selection(&mut self, toggle_items: Vec) { - crate::profile_function!(); + re_tracing::profile_function!(); // Make sure we preserve the order - old items kept in same order, new items added to the end. diff --git a/crates/re_viewer_context/src/tensor/tensor_decode_cache.rs b/crates/re_viewer_context/src/tensor/tensor_decode_cache.rs index e1b68f0fa889..f08ef945811b 100644 --- a/crates/re_viewer_context/src/tensor/tensor_decode_cache.rs +++ b/crates/re_viewer_context/src/tensor/tensor_decode_cache.rs @@ -32,7 +32,7 @@ impl TensorDecodeCache { &mut self, maybe_encoded_tensor: Tensor, ) -> Result { - crate::profile_function!(); + re_tracing::profile_function!(); match DecodedTensor::try_from(maybe_encoded_tensor) { Ok(decoded_tensor) => Ok(decoded_tensor), @@ -78,7 +78,7 @@ impl Cache for TensorDecodeCache { } fn purge_memory(&mut self) { - crate::profile_function!(); + re_tracing::profile_function!(); // Very aggressively flush everything not used in this frame diff --git a/crates/re_viewer_context/src/tensor/tensor_stats.rs b/crates/re_viewer_context/src/tensor/tensor_stats.rs index 1d8f36e6d751..db62be633dce 100644 --- a/crates/re_viewer_context/src/tensor/tensor_stats.rs +++ b/crates/re_viewer_context/src/tensor/tensor_stats.rs @@ -13,7 +13,7 @@ impl TensorStats { macro_rules! declare_tensor_range_int { ($name: ident, $typ: ty) => { fn $name(tensor: ndarray::ArrayViewD<'_, $typ>) -> (f64, f64) { - crate::profile_function!(); + re_tracing::profile_function!(); let (min, max) = tensor .fold((<$typ>::MAX, <$typ>::MIN), |(min, max), &value| { (min.min(value), max.max(value)) @@ -26,7 +26,7 @@ impl TensorStats { macro_rules! declare_tensor_range_float { ($name: ident, $typ: ty) => { fn $name(tensor: ndarray::ArrayViewD<'_, $typ>) -> (f64, f64) { - crate::profile_function!(); + re_tracing::profile_function!(); let (min, max) = tensor.fold( (<$typ>::INFINITY, <$typ>::NEG_INFINITY), |(min, max), &value| (min.min(value), max.max(value)), @@ -53,7 +53,7 @@ impl TensorStats { #[allow(clippy::needless_pass_by_value)] fn tensor_range_f16(tensor: ndarray::ArrayViewD<'_, f16>) -> (f64, f64) { - crate::profile_function!(); + re_tracing::profile_function!(); let (min, max) = tensor .fold((f16::INFINITY, f16::NEG_INFINITY), |(min, max), &value| { (min.min(value), max.max(value)) diff --git a/crates/re_viewport/Cargo.toml b/crates/re_viewport/Cargo.toml index 04af465245b5..f8bf1a83c86d 100644 --- a/crates/re_viewport/Cargo.toml +++ b/crates/re_viewport/Cargo.toml @@ -32,6 +32,7 @@ re_renderer = { workspace = true, default-features = false, features = [ "serde", ] } re_tensor_ops.workspace = true +re_tracing.workspace = true re_ui.workspace = true re_viewer_context.workspace = true @@ -63,6 +64,3 @@ slotmap.workspace = true smallvec = { workspace = true, features = ["serde"] } thiserror.workspace = true wgpu.workspace = true - -[target.'cfg(not(target_arch = "wasm32"))'.dependencies] -puffin.workspace = true diff --git a/crates/re_viewport/src/auto_layout.rs b/crates/re_viewport/src/auto_layout.rs index 1c503b811226..373f4edeb20d 100644 --- a/crates/re_viewport/src/auto_layout.rs +++ b/crates/re_viewport/src/auto_layout.rs @@ -286,7 +286,7 @@ fn group_by_path_prefix(space_infos: &[SpaceMakeInfo]) -> Vec if space_infos.len() < 2 { return vec![space_infos.to_vec()]; } - crate::profile_function!(); + re_tracing::profile_function!(); let paths = space_infos .iter() diff --git a/crates/re_viewport/src/data_blueprint.rs b/crates/re_viewport/src/data_blueprint.rs index ff586231f1f3..76b518628b5d 100644 --- a/crates/re_viewport/src/data_blueprint.rs +++ b/crates/re_viewport/src/data_blueprint.rs @@ -181,7 +181,7 @@ impl DataBlueprintTree { /// /// Propagates any data blueprint changes along the tree. pub fn on_frame_start(&mut self) { - crate::profile_function!(); + re_tracing::profile_function!(); // NOTE: We could do this projection only when the entity properties changes // and/or when new entity paths are added, but such memoization would add complexity. @@ -227,7 +227,7 @@ impl DataBlueprintTree { paths: impl Iterator, base_path: &EntityPath, ) { - crate::profile_function!(); + re_tracing::profile_function!(); let mut new_leaf_groups = Vec::new(); @@ -367,7 +367,7 @@ impl DataBlueprintTree { /// Removes a group and all its entities and subgroups from the blueprint tree pub fn remove_group(&mut self, group_handle: DataBlueprintGroupHandle) { - crate::profile_function!(); + re_tracing::profile_function!(); let Some(group) = self.groups.get(group_handle) else { return; diff --git a/crates/re_viewport/src/lib.rs b/crates/re_viewport/src/lib.rs index a6daf8f9e8df..8ae41270d425 100644 --- a/crates/re_viewport/src/lib.rs +++ b/crates/re_viewport/src/lib.rs @@ -71,25 +71,3 @@ pub mod item_ui { item_ui::cursor_interact_with_selectable(ctx.selection_state_mut(), response, item) } } - -// --------------------------------------------------------------------------- - -/// Wrapper around puffin profiler on native, no-op on weasm -#[doc(hidden)] -#[macro_export] -macro_rules! profile_function { - ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_function!($($arg)*); - }; -} - -/// Wrapper around puffin profiler on native, no-op on weasm -#[doc(hidden)] -#[macro_export] -macro_rules! profile_scope { - ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_scope!($($arg)*); - }; -} diff --git a/crates/re_viewport/src/mesh_cache.rs b/crates/re_viewport/src/mesh_cache.rs index 196ea01626a0..6a1124fe921b 100644 --- a/crates/re_viewport/src/mesh_cache.rs +++ b/crates/re_viewport/src/mesh_cache.rs @@ -18,7 +18,7 @@ impl MeshCache { mesh: &Mesh3D, render_ctx: &mut RenderContext, ) -> Option> { - crate::profile_function!(); + re_tracing::profile_function!(); let mesh_id = mesh.mesh_id(); diff --git a/crates/re_viewport/src/mesh_loader.rs b/crates/re_viewport/src/mesh_loader.rs index f78697b0fe16..20789c5431dc 100644 --- a/crates/re_viewport/src/mesh_loader.rs +++ b/crates/re_viewport/src/mesh_loader.rs @@ -34,7 +34,7 @@ impl LoadedMesh { bytes: &[u8], render_ctx: &mut RenderContext, ) -> anyhow::Result { - crate::profile_function!(); + re_tracing::profile_function!(); let mesh_instances = match format { MeshFormat::Glb | MeshFormat::Gltf => { @@ -62,7 +62,7 @@ impl LoadedMesh { encoded_mesh: &EncodedMesh3D, render_ctx: &mut RenderContext, ) -> anyhow::Result { - crate::profile_function!(); + re_tracing::profile_function!(); let EncodedMesh3D { mesh_id: _, format, @@ -90,7 +90,7 @@ impl LoadedMesh { raw_mesh: &RawMesh3D, render_ctx: &mut RenderContext, ) -> anyhow::Result { - crate::profile_function!(); + re_tracing::profile_function!(); // TODO(cmc): Having to do all of these data conversions, copies and allocations doesn't // really make sense when you consider that both the component and the renderer are native diff --git a/crates/re_viewport/src/space_info.rs b/crates/re_viewport/src/space_info.rs index ed7aa0053e45..51ac3ca28d08 100644 --- a/crates/re_viewport/src/space_info.rs +++ b/crates/re_viewport/src/space_info.rs @@ -113,7 +113,7 @@ impl SpaceInfoCollection { /// Do a graph analysis of the transform hierarchy, and create cuts /// wherever we find a non-identity transform. pub fn new(entity_db: &EntityDb) -> Self { - crate::profile_function!(); + re_tracing::profile_function!(); fn add_children( entity_db: &EntityDb, @@ -231,7 +231,7 @@ impl SpaceInfoCollection { from: &EntityPath, to_reference: &EntityPath, ) -> Result<(), UnreachableTransform> { - crate::profile_function!(); + re_tracing::profile_function!(); // Get closest space infos for the given entity paths. let mut from_space = self.get_first_parent_with_info(from); diff --git a/crates/re_viewport/src/space_view.rs b/crates/re_viewport/src/space_view.rs index 03df907adac9..6a809a612cc4 100644 --- a/crates/re_viewport/src/space_view.rs +++ b/crates/re_viewport/src/space_view.rs @@ -188,7 +188,7 @@ impl SpaceViewBlueprint { latest_at: TimeInt, highlights: &SpaceViewHighlights, ) { - crate::profile_function!(); + re_tracing::profile_function!(); let is_zero_sized_viewport = ui.available_size().min_elem() <= 0.0; if is_zero_sized_viewport { @@ -262,7 +262,7 @@ impl SpaceViewBlueprint { /// /// Ignores all entities that aren't part of the blueprint. pub fn remove_entity_subtree(&mut self, tree: &EntityTree) { - crate::profile_function!(); + re_tracing::profile_function!(); tree.visit_children_recursively(&mut |path: &EntityPath| { self.data_blueprint.remove_entity(path); @@ -279,7 +279,7 @@ impl SpaceViewBlueprint { spaces_info: &SpaceInfoCollection, log_db: &re_data_store::LogDb, ) { - crate::profile_function!(); + re_tracing::profile_function!(); let mut entities = Vec::new(); tree.visit_children_recursively(&mut |entity_path: &EntityPath| { diff --git a/crates/re_viewport/src/space_view_heuristics.rs b/crates/re_viewport/src/space_view_heuristics.rs index f4fe8d8c90a0..64d9cc4352bd 100644 --- a/crates/re_viewport/src/space_view_heuristics.rs +++ b/crates/re_viewport/src/space_view_heuristics.rs @@ -20,7 +20,7 @@ pub fn all_possible_space_views( ctx: &ViewerContext<'_>, spaces_info: &SpaceInfoCollection, ) -> Vec { - crate::profile_function!(); + re_tracing::profile_function!(); // Everything with a SpaceInfo is a candidate (that is root + whenever there is a transform), // as well as all direct descendants of the root. @@ -123,7 +123,7 @@ fn default_created_space_views_from_candidates( store: &re_arrow_store::DataStore, candidates: Vec, ) -> Vec { - crate::profile_function!(); + re_tracing::profile_function!(); // All queries are "right most" on the log timeline. let query = LatestAtQuery::latest(Timeline::log_time()); @@ -287,7 +287,7 @@ pub fn default_queried_entities( spaces_info: &SpaceInfoCollection, category: ViewCategory, ) -> Vec { - crate::profile_function!(); + re_tracing::profile_function!(); let timeline = Timeline::log_time(); let log_db = &ctx.log_db; @@ -318,7 +318,7 @@ fn default_queried_entities_by_category( space_path: &EntityPath, space_info_collection: &SpaceInfoCollection, ) -> BTreeMap> { - crate::profile_function!(); + re_tracing::profile_function!(); let timeline = Timeline::log_time(); let log_db = &ctx.log_db; diff --git a/crates/re_viewport/src/space_view_highlights.rs b/crates/re_viewport/src/space_view_highlights.rs index 9f4fb2e6e77b..bf03a52a49eb 100644 --- a/crates/re_viewport/src/space_view_highlights.rs +++ b/crates/re_viewport/src/space_view_highlights.rs @@ -92,7 +92,7 @@ pub fn highlights_for_space_view( space_view_id: SpaceViewId, space_views: &HashMap, ) -> SpaceViewHighlights { - crate::profile_function!(); + re_tracing::profile_function!(); let mut highlighted_entity_paths = IntMap::::default(); diff --git a/crates/re_viewport/src/transform_cache.rs b/crates/re_viewport/src/transform_cache.rs index 2e0b9592088a..88f78740e5a1 100644 --- a/crates/re_viewport/src/transform_cache.rs +++ b/crates/re_viewport/src/transform_cache.rs @@ -83,7 +83,7 @@ impl TransformCache { space_path: &EntityPath, entity_prop_map: &EntityPropertyMap, ) -> Self { - crate::profile_function!(); + re_tracing::profile_function!(); let mut transforms = TransformCache { reference_path: space_path.clone(), diff --git a/crates/re_viewport/src/view_bar_chart/scene.rs b/crates/re_viewport/src/view_bar_chart/scene.rs index eb9a9b77d1a9..7cf485fc9838 100644 --- a/crates/re_viewport/src/view_bar_chart/scene.rs +++ b/crates/re_viewport/src/view_bar_chart/scene.rs @@ -13,13 +13,13 @@ pub struct SceneBarChart { impl SceneBarChart { pub(crate) fn load(&mut self, ctx: &mut ViewerContext<'_>, query: &SceneQuery<'_>) { - crate::profile_function!(); + re_tracing::profile_function!(); self.load_tensors(ctx, query); } fn load_tensors(&mut self, ctx: &mut ViewerContext<'_>, query: &SceneQuery<'_>) { - crate::profile_function!(); + re_tracing::profile_function!(); let store = &ctx.log_db.entity_db.data_store; diff --git a/crates/re_viewport/src/view_category.rs b/crates/re_viewport/src/view_category.rs index 86acae3dd9c7..9256da24558c 100644 --- a/crates/re_viewport/src/view_category.rs +++ b/crates/re_viewport/src/view_category.rs @@ -67,7 +67,7 @@ pub fn categorize_entity_path( log_db: &LogDb, entity_path: &EntityPath, ) -> ViewCategorySet { - crate::profile_function!(); + re_tracing::profile_function!(); let mut set = ViewCategorySet::default(); diff --git a/crates/re_viewport/src/view_spatial/scene/mod.rs b/crates/re_viewport/src/view_spatial/scene/mod.rs index 5a4c696fd9c5..b0c43ecf9bec 100644 --- a/crates/re_viewport/src/view_spatial/scene/mod.rs +++ b/crates/re_viewport/src/view_spatial/scene/mod.rs @@ -133,7 +133,7 @@ impl SceneSpatial { ctx: &mut ViewerContext<'_>, query: &SceneQuery<'_>, ) -> EntityDepthOffsets { - crate::profile_function!(); + re_tracing::profile_function!(); #[derive(PartialEq, PartialOrd, Eq, Ord)] enum DrawOrderTarget { @@ -233,7 +233,7 @@ impl SceneSpatial { transforms: &TransformCache, highlights: &SpaceViewHighlights, ) { - crate::profile_function!(); + re_tracing::profile_function!(); self.annotation_map.load(ctx, query); diff --git a/crates/re_viewport/src/view_spatial/scene/picking.rs b/crates/re_viewport/src/view_spatial/scene/picking.rs index 932287bec74d..b60b6385c588 100644 --- a/crates/re_viewport/src/view_spatial/scene/picking.rs +++ b/crates/re_viewport/src/view_spatial/scene/picking.rs @@ -112,7 +112,7 @@ impl PickingContext { primitives: &SceneSpatialPrimitives, ui_data: &SceneSpatialUiData, ) -> PickingResult { - crate::profile_function!(); + re_tracing::profile_function!(); // Gather picking results from different sources. let gpu_pick = picking_gpu( @@ -167,7 +167,7 @@ fn picking_gpu( context: &PickingContext, previous_picking_result: &Option, ) -> Option { - crate::profile_function!(); + re_tracing::profile_function!(); // Only look at newest available result, discard everything else. let mut gpu_picking_result = None; @@ -243,7 +243,7 @@ fn picking_gpu( } fn picking_textured_rects(context: &PickingContext, images: &[Image]) -> Vec { - crate::profile_function!(); + re_tracing::profile_function!(); let mut hits = Vec::new(); @@ -291,7 +291,7 @@ fn picking_ui_rects( context: &PickingContext, ui_data: &SceneSpatialUiData, ) -> Option { - crate::profile_function!(); + re_tracing::profile_function!(); let egui_pos = egui::pos2(context.pointer_in_space2d.x, context.pointer_in_space2d.y); for (bbox, instance_hash) in &ui_data.pickable_ui_rects { diff --git a/crates/re_viewport/src/view_spatial/scene/primitives.rs b/crates/re_viewport/src/view_spatial/scene/primitives.rs index c66a7e7073e3..afbd4c79f99e 100644 --- a/crates/re_viewport/src/view_spatial/scene/primitives.rs +++ b/crates/re_viewport/src/view_spatial/scene/primitives.rs @@ -79,7 +79,7 @@ impl SceneSpatialPrimitives { } pub fn recalculate_bounding_box(&mut self) { - crate::profile_function!(); + re_tracing::profile_function!(); let Self { bounding_box, @@ -125,7 +125,7 @@ impl SceneSpatialPrimitives { } pub fn mesh_instances(&self) -> Vec { - crate::profile_function!(); + re_tracing::profile_function!(); self.meshes .iter() .flat_map(|mesh| { diff --git a/crates/re_viewport/src/view_spatial/scene/scene_part/arrows3d.rs b/crates/re_viewport/src/view_spatial/scene/scene_part/arrows3d.rs index 7fea3cd81aad..0a8548d43f03 100644 --- a/crates/re_viewport/src/view_spatial/scene/scene_part/arrows3d.rs +++ b/crates/re_viewport/src/view_spatial/scene/scene_part/arrows3d.rs @@ -94,7 +94,7 @@ impl ScenePart for Arrows3DPart { highlights: &SpaceViewHighlights, _depth_offsets: &EntityDepthOffsets, ) { - crate::profile_scope!("Points2DPart"); + re_tracing::profile_scope!("Points2DPart"); for (ent_path, props) in query.iter_entities() { let Some(world_from_obj) = transforms.reference_from_entity(ent_path) else { diff --git a/crates/re_viewport/src/view_spatial/scene/scene_part/boxes2d.rs b/crates/re_viewport/src/view_spatial/scene/scene_part/boxes2d.rs index fa8291e3dd51..a9f542b741aa 100644 --- a/crates/re_viewport/src/view_spatial/scene/scene_part/boxes2d.rs +++ b/crates/re_viewport/src/view_spatial/scene/scene_part/boxes2d.rs @@ -109,7 +109,7 @@ impl ScenePart for Boxes2DPart { highlights: &SpaceViewHighlights, depth_offsets: &EntityDepthOffsets, ) { - crate::profile_scope!("Boxes2DPart"); + re_tracing::profile_scope!("Boxes2DPart"); for (ent_path, props) in query.iter_entities() { let Some(world_from_obj) = transforms.reference_from_entity(ent_path) else { diff --git a/crates/re_viewport/src/view_spatial/scene/scene_part/boxes3d.rs b/crates/re_viewport/src/view_spatial/scene/scene_part/boxes3d.rs index 7cb906423bc3..11a4f8e26d51 100644 --- a/crates/re_viewport/src/view_spatial/scene/scene_part/boxes3d.rs +++ b/crates/re_viewport/src/view_spatial/scene/scene_part/boxes3d.rs @@ -99,7 +99,7 @@ impl ScenePart for Boxes3DPart { highlights: &SpaceViewHighlights, _depth_offsets: &EntityDepthOffsets, ) { - crate::profile_scope!("Boxes3DPart"); + re_tracing::profile_scope!("Boxes3DPart"); for (ent_path, props) in query.iter_entities() { let Some(world_from_obj) = transforms.reference_from_entity(ent_path) else { diff --git a/crates/re_viewport/src/view_spatial/scene/scene_part/cameras.rs b/crates/re_viewport/src/view_spatial/scene/scene_part/cameras.rs index a1afec0294f7..0b7359a03572 100644 --- a/crates/re_viewport/src/view_spatial/scene/scene_part/cameras.rs +++ b/crates/re_viewport/src/view_spatial/scene/scene_part/cameras.rs @@ -188,7 +188,7 @@ impl ScenePart for CamerasPart { highlights: &SpaceViewHighlights, _depth_offsets: &EntityDepthOffsets, ) { - crate::profile_scope!("CamerasPart"); + re_tracing::profile_scope!("CamerasPart"); let store = &ctx.log_db.entity_db.data_store; for (ent_path, props) in query.iter_entities() { diff --git a/crates/re_viewport/src/view_spatial/scene/scene_part/images.rs b/crates/re_viewport/src/view_spatial/scene/scene_part/images.rs index 9bce36ab4de0..252ef188320b 100644 --- a/crates/re_viewport/src/view_spatial/scene/scene_part/images.rs +++ b/crates/re_viewport/src/view_spatial/scene/scene_part/images.rs @@ -38,7 +38,7 @@ fn to_textured_rect( outline_mask: OutlineMaskPreference, depth_offset: re_renderer::DepthOffset, ) -> Option { - crate::profile_function!(); + re_tracing::profile_function!(); let Some([height, width, _]) = tensor.image_height_width_channels() else { return None; }; @@ -98,7 +98,7 @@ struct ImageGrouping { } fn handle_image_layering(scene: &mut SceneSpatial) { - crate::profile_function!(); + re_tracing::profile_function!(); // Rebuild the image list, grouped by "shared plane", identified with camera & draw order. let mut image_groups: BTreeMap> = BTreeMap::new(); @@ -162,7 +162,7 @@ impl ImagesPart { highlights: &SpaceViewHighlights, depth_offset: re_renderer::DepthOffset, ) -> Result<(), QueryError> { - crate::profile_function!(); + re_tracing::profile_function!(); // Instance ids of tensors refer to entries inside the tensor. for (tensor, color, draw_order) in itertools::izip!( @@ -170,7 +170,7 @@ impl ImagesPart { entity_view.iter_component::()?, entity_view.iter_component::()? ) { - crate::profile_scope!("loop_iter"); + re_tracing::profile_scope!("loop_iter"); let Some(tensor) = tensor else { continue; }; if !tensor.is_shaped_like_an_image() { @@ -259,7 +259,7 @@ impl ImagesPart { pinhole_ent_path: &EntityPath, entity_highlight: &SpaceViewOutlineMasks, ) -> Result<(), String> { - crate::profile_function!(); + re_tracing::profile_function!(); let store = &ctx.log_db.entity_db.data_store; let Some(intrinsics) = store.query_latest_component::( @@ -384,7 +384,7 @@ impl ScenePart for ImagesPart { highlights: &SpaceViewHighlights, depth_offsets: &EntityDepthOffsets, ) { - crate::profile_scope!("ImagesPart"); + re_tracing::profile_scope!("ImagesPart"); for (ent_path, props) in query.iter_entities() { let Some(world_from_obj) = transforms.reference_from_entity(ent_path) else { diff --git a/crates/re_viewport/src/view_spatial/scene/scene_part/lines2d.rs b/crates/re_viewport/src/view_spatial/scene/scene_part/lines2d.rs index a44999a4894c..04636210b8ca 100644 --- a/crates/re_viewport/src/view_spatial/scene/scene_part/lines2d.rs +++ b/crates/re_viewport/src/view_spatial/scene/scene_part/lines2d.rs @@ -78,7 +78,7 @@ impl ScenePart for Lines2DPart { highlights: &SpaceViewHighlights, depth_offsets: &EntityDepthOffsets, ) { - crate::profile_scope!("Lines2DPart"); + re_tracing::profile_scope!("Lines2DPart"); for (ent_path, props) in query.iter_entities() { let Some(world_from_obj) = transforms.reference_from_entity(ent_path) else { diff --git a/crates/re_viewport/src/view_spatial/scene/scene_part/lines3d.rs b/crates/re_viewport/src/view_spatial/scene/scene_part/lines3d.rs index 348d3fe04517..d747cd57818d 100644 --- a/crates/re_viewport/src/view_spatial/scene/scene_part/lines3d.rs +++ b/crates/re_viewport/src/view_spatial/scene/scene_part/lines3d.rs @@ -77,7 +77,7 @@ impl ScenePart for Lines3DPart { highlights: &SpaceViewHighlights, _depth_offsets: &EntityDepthOffsets, ) { - crate::profile_scope!("Lines3DPart"); + re_tracing::profile_scope!("Lines3DPart"); for (ent_path, props) in query.iter_entities() { let Some(world_from_obj) = transforms.reference_from_entity(ent_path) else { diff --git a/crates/re_viewport/src/view_spatial/scene/scene_part/meshes.rs b/crates/re_viewport/src/view_spatial/scene/scene_part/meshes.rs index ccccd3e849e6..ec329f11edf3 100644 --- a/crates/re_viewport/src/view_spatial/scene/scene_part/meshes.rs +++ b/crates/re_viewport/src/view_spatial/scene/scene_part/meshes.rs @@ -70,7 +70,7 @@ impl ScenePart for MeshPart { highlights: &SpaceViewHighlights, _depth_offsets: &EntityDepthOffsets, ) { - crate::profile_scope!("MeshPart"); + re_tracing::profile_scope!("MeshPart"); for (ent_path, props) in query.iter_entities() { let Some(world_from_obj) = transforms.reference_from_entity(ent_path) else { diff --git a/crates/re_viewport/src/view_spatial/scene/scene_part/mod.rs b/crates/re_viewport/src/view_spatial/scene/scene_part/mod.rs index d6879b4ea90b..c743fc0611ef 100644 --- a/crates/re_viewport/src/view_spatial/scene/scene_part/mod.rs +++ b/crates/re_viewport/src/view_spatial/scene/scene_part/mod.rs @@ -109,7 +109,7 @@ where Primary: re_log_types::SerializableComponent + re_log_types::DeserializableComponent, for<'b> &'b Primary::ArrayType: IntoIterator, { - crate::profile_function!(); + re_tracing::profile_function!(); let default_color = DefaultColor::EntityPath(ent_path); Ok(itertools::izip!( @@ -130,7 +130,7 @@ where Primary: re_log_types::SerializableComponent + re_log_types::DeserializableComponent, for<'b> &'b Primary::ArrayType: IntoIterator, { - crate::profile_function!(); + re_tracing::profile_function!(); let ent_path = ent_path.clone(); Ok(entity_view.iter_component::()?.map(move |radius| { radius.map_or(re_renderer::Size::AUTO, |r| { @@ -161,7 +161,7 @@ where for<'b> &'b Primary::ArrayType: IntoIterator, glam::Vec3: std::convert::From, { - crate::profile_function!(); + re_tracing::profile_function!(); let mut keypoints: Keypoints = HashMap::default(); diff --git a/crates/re_viewport/src/view_spatial/scene/scene_part/points2d.rs b/crates/re_viewport/src/view_spatial/scene/scene_part/points2d.rs index e21589ba39ad..ea1b4c1fa231 100644 --- a/crates/re_viewport/src/view_spatial/scene/scene_part/points2d.rs +++ b/crates/re_viewport/src/view_spatial/scene/scene_part/points2d.rs @@ -63,7 +63,7 @@ impl Points2DPart { entity_highlight: &SpaceViewOutlineMasks, depth_offset: re_renderer::DepthOffset, ) -> Result<(), QueryError> { - crate::profile_function!(); + re_tracing::profile_function!(); scene.num_logged_2d_objects += 1; @@ -81,7 +81,7 @@ impl Points2DPart { process_colors(entity_view, ent_path, &annotation_infos)?.collect::>(); let instance_path_hashes_for_picking = { - crate::profile_scope!("instance_hashes"); + re_tracing::profile_scope!("instance_hashes"); entity_view .iter_instance_keys() .map(|instance_key| { @@ -118,7 +118,7 @@ impl Points2DPart { .picking_object_id(re_renderer::PickingLayerObjectId(ent_path.hash64())); let point_positions = { - crate::profile_scope!("collect_points"); + re_tracing::profile_scope!("collect_points"); entity_view .iter_primary()? .filter_map(|pt| pt.map(glam::Vec2::from)) @@ -142,7 +142,7 @@ impl Points2DPart { // Determine if there's any sub-ranges that need extra highlighting. { - crate::profile_scope!("marking additional highlight points"); + re_tracing::profile_scope!("marking additional highlight points"); for (highlighted_key, instance_mask_ids) in &entity_highlight.instances { // TODO(andreas/jeremy): We can do this much more efficiently let highlighted_point_index = entity_view @@ -175,7 +175,7 @@ impl ScenePart for Points2DPart { highlights: &SpaceViewHighlights, depth_offsets: &EntityDepthOffsets, ) { - crate::profile_scope!("Points2DPart"); + re_tracing::profile_scope!("Points2DPart"); for (ent_path, props) in query.iter_entities() { let Some(world_from_obj) = transforms.reference_from_entity(ent_path) else { diff --git a/crates/re_viewport/src/view_spatial/scene/scene_part/points3d.rs b/crates/re_viewport/src/view_spatial/scene/scene_part/points3d.rs index cf23d442f318..d5863c0061a0 100644 --- a/crates/re_viewport/src/view_spatial/scene/scene_part/points3d.rs +++ b/crates/re_viewport/src/view_spatial/scene/scene_part/points3d.rs @@ -71,7 +71,7 @@ impl Points3DPart { world_from_obj: glam::Affine3A, entity_highlight: &SpaceViewOutlineMasks, ) -> Result<(), QueryError> { - crate::profile_function!(); + re_tracing::profile_function!(); scene.num_logged_3d_objects += 1; @@ -89,7 +89,7 @@ impl Points3DPart { process_colors(entity_view, ent_path, &annotation_infos)?.collect::>(); let instance_path_hashes_for_picking = { - crate::profile_scope!("instance_hashes"); + re_tracing::profile_scope!("instance_hashes"); entity_view .iter_instance_keys() .map(|instance_key| { @@ -122,7 +122,7 @@ impl Points3DPart { .picking_object_id(re_renderer::PickingLayerObjectId(ent_path.hash64())); let point_positions = { - crate::profile_scope!("collect_points"); + re_tracing::profile_scope!("collect_points"); entity_view .iter_primary()? .filter_map(|pt| pt.map(glam::Vec3::from)) @@ -145,7 +145,7 @@ impl Points3DPart { // Determine if there's any sub-ranges that need extra highlighting. { - crate::profile_scope!("marking additional highlight points"); + re_tracing::profile_scope!("marking additional highlight points"); for (highlighted_key, instance_mask_ids) in &entity_highlight.instances { // TODO(andreas/jeremy): We can do this much more efficiently let highlighted_point_index = entity_view @@ -178,7 +178,7 @@ impl ScenePart for Points3DPart { highlights: &SpaceViewHighlights, _depth_offsets: &EntityDepthOffsets, ) { - crate::profile_scope!("Points3DPart"); + re_tracing::profile_scope!("Points3DPart"); for (ent_path, props) in query.iter_entities() { let Some(world_from_obj) = transforms.reference_from_entity(ent_path) else { diff --git a/crates/re_viewport/src/view_spatial/ui.rs b/crates/re_viewport/src/view_spatial/ui.rs index 7e1206c1dcf1..546c7da00f99 100644 --- a/crates/re_viewport/src/view_spatial/ui.rs +++ b/crates/re_viewport/src/view_spatial/ui.rs @@ -143,7 +143,7 @@ impl ViewSpatialState { ctx: &mut ViewerContext<'_>, data_blueprint: &mut DataBlueprintTree, ) { - crate::profile_function!(); + re_tracing::profile_function!(); let query = ctx.current_query(); @@ -527,7 +527,7 @@ pub fn create_labels( highlights: &SpaceViewHighlights, nav_mode: SpatialNavigationMode, ) -> Vec { - crate::profile_function!(); + re_tracing::profile_function!(); let mut label_shapes = Vec::with_capacity(scene_ui.labels.len() * 2); @@ -677,7 +677,7 @@ pub fn picking( space: &EntityPath, entity_properties: &EntityPropertyMap, ) -> egui::Response { - crate::profile_function!(); + re_tracing::profile_function!(); let Some(pointer_pos_ui) = response.hover_pos() else { state.previous_picking_result = None; diff --git a/crates/re_viewport/src/view_spatial/ui_2d.rs b/crates/re_viewport/src/view_spatial/ui_2d.rs index 64b38d589fba..fb3f1c4d9597 100644 --- a/crates/re_viewport/src/view_spatial/ui_2d.rs +++ b/crates/re_viewport/src/view_spatial/ui_2d.rs @@ -233,7 +233,7 @@ pub fn view_2d( highlights: &SpaceViewHighlights, entity_properties: &EntityPropertyMap, ) -> egui::Response { - crate::profile_function!(); + re_tracing::profile_function!(); // Save off the available_size since this is used for some of the layout updates later let available_size = ui.available_size(); diff --git a/crates/re_viewport/src/view_spatial/ui_3d.rs b/crates/re_viewport/src/view_spatial/ui_3d.rs index dc0f6ade6da5..0fcc095e633f 100644 --- a/crates/re_viewport/src/view_spatial/ui_3d.rs +++ b/crates/re_viewport/src/view_spatial/ui_3d.rs @@ -291,7 +291,7 @@ pub fn view_3d( highlights: &SpaceViewHighlights, entity_properties: &EntityPropertyMap, ) { - crate::profile_function!(); + re_tracing::profile_function!(); let (rect, mut response) = ui.allocate_at_least(ui.available_size(), egui::Sense::click_and_drag()); diff --git a/crates/re_viewport/src/view_spatial/ui_renderer_bridge.rs b/crates/re_viewport/src/view_spatial/ui_renderer_bridge.rs index e02885290f73..8b624a8ef662 100644 --- a/crates/re_viewport/src/view_spatial/ui_renderer_bridge.rs +++ b/crates/re_viewport/src/view_spatial/ui_renderer_bridge.rs @@ -17,7 +17,7 @@ pub fn fill_view_builder( primitives: SceneSpatialPrimitives, background: &ScreenBackground, ) -> anyhow::Result { - crate::profile_function!(); + re_tracing::profile_function!(); view_builder .queue_draw(&DepthCloudDrawData::new( diff --git a/crates/re_viewport/src/view_tensor/scene.rs b/crates/re_viewport/src/view_tensor/scene.rs index e5839bba30a4..7b2cd303800b 100644 --- a/crates/re_viewport/src/view_tensor/scene.rs +++ b/crates/re_viewport/src/view_tensor/scene.rs @@ -12,7 +12,7 @@ pub struct SceneTensor { impl SceneTensor { /// Loads all tensors into the scene according to the given query. pub(crate) fn load(&mut self, ctx: &mut ViewerContext<'_>, query: &SceneQuery<'_>) { - crate::profile_function!(); + re_tracing::profile_function!(); let store = &ctx.log_db.entity_db.data_store; for (ent_path, props) in query.iter_entities() { diff --git a/crates/re_viewport/src/view_tensor/tensor_slice_to_gpu.rs b/crates/re_viewport/src/view_tensor/tensor_slice_to_gpu.rs index ab3b0c5f063b..c7ee12d54813 100644 --- a/crates/re_viewport/src/view_tensor/tensor_slice_to_gpu.rs +++ b/crates/re_viewport/src/view_tensor/tensor_slice_to_gpu.rs @@ -31,7 +31,7 @@ pub fn colormapped_texture( tensor_stats: &TensorStats, state: &ViewTensorState, ) -> Result> { - crate::profile_function!(); + re_tracing::profile_function!(); let range = range(tensor_stats).map_err(|err| TextureManager2DError::DataCreation(err.into()))?; @@ -67,7 +67,7 @@ fn texture_desc_from_tensor( slice_selection: &SliceSelection, ) -> Result, TensorUploadError> { use wgpu::TextureFormat; - crate::profile_function!(); + re_tracing::profile_function!(); let tensor = tensor.inner(); @@ -143,7 +143,7 @@ fn to_texture_desc( format: wgpu::TextureFormat, caster: impl Fn(From) -> To, ) -> Result, TensorUploadError> { - crate::profile_function!(); + re_tracing::profile_function!(); use ndarray::Dimension as _; @@ -158,7 +158,7 @@ fn to_texture_desc( .expect("Mismatched length."); { - crate::profile_scope!("copy_from_slice"); + re_tracing::profile_scope!("copy_from_slice"); ndarray::Zip::from(pixels_view) .and(slice) .for_each(|pixel: &mut To, value: &From| { @@ -166,7 +166,7 @@ fn to_texture_desc( }); } - crate::profile_scope!("pod_collect_to_vec"); + re_tracing::profile_scope!("pod_collect_to_vec"); Ok(Texture2DCreationDesc { label: "tensor_slice".into(), data: bytemuck::pod_collect_to_vec(&pixels).into(), diff --git a/crates/re_viewport/src/view_tensor/ui.rs b/crates/re_viewport/src/view_tensor/ui.rs index 09856f0b1dc1..f9c9696922ac 100644 --- a/crates/re_viewport/src/view_tensor/ui.rs +++ b/crates/re_viewport/src/view_tensor/ui.rs @@ -104,7 +104,7 @@ pub(crate) fn view_tensor( state: &mut ViewTensorState, tensor: &DecodedTensor, ) { - crate::profile_function!(); + re_tracing::profile_function!(); state.tensor = Some(tensor.clone()); @@ -176,7 +176,7 @@ fn paint_tensor_slice( state: &mut ViewTensorState, tensor: &DecodedTensor, ) -> anyhow::Result<(egui::Response, egui::Painter, egui::Rect)> { - crate::profile_function!(); + re_tracing::profile_function!(); let tensor_stats = ctx.cache.entry::().entry(tensor); let colormapped_texture = super::tensor_slice_to_gpu::colormapped_texture( @@ -278,7 +278,7 @@ fn colormap_preview_ui( ui: &mut egui::Ui, colormap: Colormap, ) -> egui::Response { - crate::profile_function!(); + re_tracing::profile_function!(); let desired_size = egui::vec2(128.0, 16.0); let (rect, response) = ui.allocate_exact_size(desired_size, egui::Sense::hover()); diff --git a/crates/re_viewport/src/view_text/scene.rs b/crates/re_viewport/src/view_text/scene.rs index b25397cd89b3..6f8e4c41eebb 100644 --- a/crates/re_viewport/src/view_text/scene.rs +++ b/crates/re_viewport/src/view_text/scene.rs @@ -39,7 +39,7 @@ impl SceneText { query: &SceneQuery<'_>, filters: &ViewTextFilters, ) { - crate::profile_function!(); + re_tracing::profile_function!(); let store = &ctx.log_db.entity_db.data_store; diff --git a/crates/re_viewport/src/view_text/ui.rs b/crates/re_viewport/src/view_text/ui.rs index 8e1acd2009dc..2bc6e225cc67 100644 --- a/crates/re_viewport/src/view_text/ui.rs +++ b/crates/re_viewport/src/view_text/ui.rs @@ -27,7 +27,7 @@ pub struct ViewTextState { impl ViewTextState { pub fn selection_ui(&mut self, re_ui: &re_ui::ReUi, ui: &mut egui::Ui) { - crate::profile_function!(); + re_tracing::profile_function!(); let ViewTextFilters { col_timelines, @@ -80,7 +80,7 @@ pub(crate) fn view_text( state: &mut ViewTextState, scene: &SceneText, ) -> egui::Response { - crate::profile_function!(); + re_tracing::profile_function!(); // Update filters if necessary. state.filters.update(ctx, &scene.text_entries); @@ -96,7 +96,7 @@ pub(crate) fn view_text( // - Otherwise, let the user scroll around freely! let time_cursor_moved = state.latest_time != time; let scroll_to_row = time_cursor_moved.then(|| { - crate::profile_scope!("TextEntryState - search scroll time"); + re_tracing::profile_scope!("TextEntryState - search scroll time"); scene .text_entries .partition_point(|te| te.time.unwrap_or(i64::MIN) < time) @@ -106,7 +106,7 @@ pub(crate) fn view_text( ui.with_layout(egui::Layout::top_down(egui::Align::Center), |ui| { egui::ScrollArea::horizontal().show(ui, |ui| { - crate::profile_scope!("render table"); + re_tracing::profile_scope!("render table"); table_ui(ctx, ui, state, &scene.text_entries, scroll_to_row); }) }) @@ -157,7 +157,7 @@ impl ViewTextFilters { // Checks whether new values are available for any of the filters, and updates everything // accordingly. fn update(&mut self, ctx: &mut ViewerContext<'_>, text_entries: &[TextEntry]) { - crate::profile_function!(); + re_tracing::profile_function!(); let Self { col_timelines, diff --git a/crates/re_viewport/src/view_text_box/scene.rs b/crates/re_viewport/src/view_text_box/scene.rs index 6b57dc6967ef..a72438d93a3d 100644 --- a/crates/re_viewport/src/view_text_box/scene.rs +++ b/crates/re_viewport/src/view_text_box/scene.rs @@ -19,7 +19,7 @@ pub struct SceneTextBox { impl SceneTextBox { /// Loads all text components into the scene according to the given query. pub(crate) fn load(&mut self, ctx: &ViewerContext<'_>, query: &SceneQuery<'_>) { - crate::profile_function!(); + re_tracing::profile_function!(); let store = &ctx.log_db.entity_db.data_store; diff --git a/crates/re_viewport/src/view_text_box/ui.rs b/crates/re_viewport/src/view_text_box/ui.rs index f63067a92fd1..6a248008b937 100644 --- a/crates/re_viewport/src/view_text_box/ui.rs +++ b/crates/re_viewport/src/view_text_box/ui.rs @@ -22,7 +22,7 @@ impl Default for ViewTextBoxState { impl ViewTextBoxState { pub fn selection_ui(&mut self, re_ui: &re_ui::ReUi, ui: &mut egui::Ui) { - crate::profile_function!(); + re_tracing::profile_function!(); re_ui.selection_grid(ui, "text_config").show(ui, |ui| { re_ui.grid_left_hand_label(ui, "Text style"); @@ -42,7 +42,7 @@ pub(crate) fn view_text_box( state: &mut ViewTextBoxState, scene: &SceneTextBox, ) -> egui::Response { - crate::profile_function!(); + re_tracing::profile_function!(); ui.with_layout(egui::Layout::top_down(egui::Align::LEFT), |ui| { egui::ScrollArea::both() diff --git a/crates/re_viewport/src/view_time_series/scene.rs b/crates/re_viewport/src/view_time_series/scene.rs index 8e99a3d32716..d26f51841b81 100644 --- a/crates/re_viewport/src/view_time_series/scene.rs +++ b/crates/re_viewport/src/view_time_series/scene.rs @@ -62,7 +62,7 @@ pub struct SceneTimeSeries { impl SceneTimeSeries { /// Loads all plots into the scene according to the given query. pub(crate) fn load(&mut self, ctx: &mut ViewerContext<'_>, query: &SceneQuery<'_>) { - crate::profile_function!(); + re_tracing::profile_function!(); self.annotation_map.load(ctx, query); @@ -71,7 +71,7 @@ impl SceneTimeSeries { #[inline(never)] // Better callstacks on crashes fn load_scalars(&mut self, ctx: &mut ViewerContext<'_>, query: &SceneQuery<'_>) { - crate::profile_function!(); + re_tracing::profile_function!(); let store = &ctx.log_db.entity_db.data_store; @@ -162,7 +162,7 @@ impl SceneTimeSeries { // we notice a change in attributes, we need a new line segment. #[inline(never)] // Better callstacks on crashes fn add_line_segments(&mut self, line_label: &str, points: Vec) { - crate::profile_function!(); + re_tracing::profile_function!(); let num_points = points.len(); let mut attrs = points[0].attrs.clone(); diff --git a/crates/re_viewport/src/view_time_series/ui.rs b/crates/re_viewport/src/view_time_series/ui.rs index e7576e344861..6fe89e98273e 100644 --- a/crates/re_viewport/src/view_time_series/ui.rs +++ b/crates/re_viewport/src/view_time_series/ui.rs @@ -52,7 +52,7 @@ pub(crate) fn view_time_series( _state: &mut ViewTimeSeriesState, scene: &SceneTimeSeries, ) -> egui::Response { - crate::profile_function!(); + re_tracing::profile_function!(); let time_ctrl = &ctx.rec_cfg.time_ctrl; let current_time = time_ctrl.time_i64(); diff --git a/crates/re_viewport/src/viewport.rs b/crates/re_viewport/src/viewport.rs index b4d353059aea..665891aba1a2 100644 --- a/crates/re_viewport/src/viewport.rs +++ b/crates/re_viewport/src/viewport.rs @@ -54,7 +54,7 @@ pub struct Viewport { impl Viewport { /// Create a default suggested blueprint using some heuristics. pub fn new(ctx: &mut ViewerContext<'_>, spaces_info: &SpaceInfoCollection) -> Self { - crate::profile_function!(); + re_tracing::profile_function!(); let mut viewport = Self::default(); for space_view in default_created_space_views(ctx, spaces_info) { @@ -102,7 +102,7 @@ impl Viewport { /// Show the blueprint panel tree view. pub fn tree_ui(&mut self, ctx: &mut ViewerContext<'_>, ui: &mut egui::Ui) { - crate::profile_function!(); + re_tracing::profile_function!(); egui::ScrollArea::both() .auto_shrink([true, false]) @@ -364,7 +364,7 @@ impl Viewport { ctx: &mut ViewerContext<'_>, spaces_info: &SpaceInfoCollection, ) { - crate::profile_function!(); + re_tracing::profile_function!(); for space_view in self.space_views.values_mut() { space_view.on_frame_start(ctx, spaces_info); @@ -645,7 +645,7 @@ impl<'a, 'b> egui_tiles::Behavior for TabViewer<'a, 'b> { _tile_id: egui_tiles::TileId, space_view_id: &mut SpaceViewId, ) -> egui_tiles::UiResponse { - crate::profile_function!(); + re_tracing::profile_function!(); let highlights = highlights_for_space_view(self.ctx.selection_state(), *space_view_id, self.space_views); From d2ea251ee368cbe5775ede35988ab1c96b06bafd Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Wed, 31 May 2023 09:09:29 +0200 Subject: [PATCH 3/4] web fix --- crates/re_tracing/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/re_tracing/src/lib.rs b/crates/re_tracing/src/lib.rs index dfa0d7237ef8..4b91eb478e64 100644 --- a/crates/re_tracing/src/lib.rs +++ b/crates/re_tracing/src/lib.rs @@ -1,6 +1,7 @@ //! Helpers for tracing/spans/flamegraphs and such. pub mod reexports { + #[cfg(not(target_arch = "wasm32"))] pub use puffin; } From eea583ac5c7af1b15dd2558df7bb006e456bbf87 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Wed, 31 May 2023 09:09:55 +0200 Subject: [PATCH 4/4] update publish script --- scripts/publish_crates.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/publish_crates.sh b/scripts/publish_crates.sh index e52575f94c0c..7e37e73569a7 100755 --- a/scripts/publish_crates.sh +++ b/scripts/publish_crates.sh @@ -93,6 +93,7 @@ echo "Publishing crates…" cargo publish $FLAGS -p re_build_info cargo publish $FLAGS -p re_build_build_info cargo publish $FLAGS -p re_log +cargo publish $FLAGS -p re_tracing cargo publish $FLAGS -p re_int_histogram cargo publish $FLAGS -p re_error cargo publish $FLAGS -p re_tuid