Modern Apps git

← Modern-Apps.git

library:map: instrument tile pipeline timing for issue 815

Commit
568342097502a90fd4ff32a10669235ede7c2338
Author
vayun-mathur <[email protected]>
When
2026-10-14 02:17 UTC (1 month ago)
Parents
ad597bb

Diff

library/map/src/main/rust/src/bridge/mod.rs
diff --git a/library/map/src/main/rust/src/bridge/mod.rs b/library/map/src/main/rust/src/bridge/mod.rsindex 802ff84924..62d4eaac28 100644--- a/library/map/src/main/rust/src/bridge/mod.rs+++ b/library/map/src/main/rust/src/bridge/mod.rs@@ -20,7 +20,9 @@ mod frame; mod handle; mod layers; mod lifecycle;-mod log;+// `pub(crate)` so the tile fetch path (`tile::source::fetch`, issue-815 timing)+// can log through the same `MapRenderer` tag without a second log shim.+pub(crate) mod log; mod markers; mod moon; mod pick;
library/map/src/main/rust/src/bridge/workers.rs
diff --git a/library/map/src/main/rust/src/bridge/workers.rs b/library/map/src/main/rust/src/bridge/workers.rsindex a7e3569318..eb3a664fed 100644--- a/library/map/src/main/rust/src/bridge/workers.rs+++ b/library/map/src/main/rust/src/bridge/workers.rs@@ -2,7 +2,7 @@ //! //! Pure move out of `bridge.rs`; no logic changes. use super::handle::{OnlineFlag, TileResult, ZoomRange};-use super::log::log;+use super::log::{log, log_info}; use crate::style::{self, SharedToggles}; use crate::tile::cache::{RangeCache, DEFAULT_MAX_BYTES}; use crate::tile::geometry;@@ -207,23 +207,46 @@ fn serve<R: RangeReader>(         };         let Ok(tile) = next else { return };         let key = tile.key();+        let dequeue_at = std::time::Instant::now();          // Read per tile, not once per worker: a toggle change has to reach the         // very next tile built, and all three parts come from one snapshot so the         // stamp can never describe different flags than the mesh was built with.         let (enabled, kinds, generation) = toggles.get();-        let result = match archive.tile(tile.z, tile.x, tile.y) {-            Ok(Some(body)) => TileResult::Ready(geometry::build_toggled(-                &body,-                layers,-                tile.z,-                tile.x,-                tile.y,-                rings_validated,-                enabled,-                &kinds,-                generation,-            )),+        let fetch_start = std::time::Instant::now();+        let fetched = archive.tile(tile.z, tile.x, tile.y);+        let fetch_ms = fetch_start.elapsed().as_millis();+        let result = match fetched {+            Ok(Some(body)) => {+                let tess_start = std::time::Instant::now();+                let mesh = geometry::build_toggled(+                    &body,+                    layers,+                    tile.z,+                    tile.x,+                    tile.y,+                    rings_validated,+                    enabled,+                    &kinds,+                    generation,+                );+                let tess_ms = tess_start.elapsed().as_millis();+                // Per-tile pipeline timing for issue 815: queue wait vs fetch/decode+                // vs tessellation, at info level beside the per-frame report.+                // `queue_ms` includes time spent serving earlier queued tiles; a+                // large value on the first tiles of a cold load means the queue+                // is the bottleneck, not the network.+                log_info(&format!(+                    "tile {}/{}/{} queue={}ms fetch={}ms tess={}ms",+                    tile.z,+                    tile.x,+                    tile.y,+                    dequeue_at.elapsed().as_millis().saturating_sub(fetch_ms + tess_ms),+                    fetch_ms,+                    tess_ms,+                ));+                TileResult::Ready(mesh)+            }             Ok(None) => TileResult::Absent,             Err(e) => {                 log(&format!(
library/map/src/main/rust/src/tile/source/fetch.rs
diff --git a/library/map/src/main/rust/src/tile/source/fetch.rs b/library/map/src/main/rust/src/tile/source/fetch.rsindex 4c73290564..29dc18290e 100644--- a/library/map/src/main/rust/src/tile/source/fetch.rs+++ b/library/map/src/main/rust/src/tile/source/fetch.rs@@ -21,6 +21,25 @@ pub struct JniRangeFetcher; #[cfg(target_os = "android")] impl RangeFetcher for JniRangeFetcher {     fn fetch(&self, url: &str, range: &str) -> Result<RangeResponse> {+        // Issue-815 timing: how long one range request spends across the JNI+        // bridge. A slow first request with fast followers means connection+        // reuse works; uniformly slow requests implicate per-request TLS+        // handshakes (a `:library:network` follow-up, diagnose-only here).+        let start = std::time::Instant::now();+        let outcome = self.fetch_inner(url, range);+        let ms = start.elapsed().as_millis();+        let status = match &outcome {+            Ok(r) => r.status.to_string(),+            Err(_) => "err".to_string(),+        };+        crate::bridge::log::log_info(&format!("range {range} -> {status} in {ms}ms"));+        outcome+    }+}++#[cfg(target_os = "android")]+impl JniRangeFetcher {+    fn fetch_inner(&self, url: &str, range: &str) -> Result<RangeResponse> {         // `Header` is an owned `(String, String)` pair, and `body` is `Option`, not a         // slice: a GET has none.         let headers = [("Range".to_string(), range.to_string())];