Modern Apps git

← Modern-Apps.git

maps: lazy per-block graph inflate + faster A* search loop

Commit
1ee04071b7fbbef94281db98465db0e27fb94e99
Author
vayun-mathur <[email protected]>
When
2026-10-25 00:08 UTC (1 month ago)
Parents
8bed65e

Diff

Cargo.lock
diff --git a/Cargo.lock b/Cargo.lockindex 1fd417e1dc..aea576fdeb 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -3747,6 +3747,7 @@ dependencies = [  "flate2",  "jni",  "libc",+ "ruzstd",  "tilecodec", ] 
maps/src/main/rust/Cargo.toml
diff --git a/maps/src/main/rust/Cargo.toml b/maps/src/main/rust/Cargo.tomlindex 98b7c22a0a..104b9bc090 100644--- a/maps/src/main/rust/Cargo.toml+++ b/maps/src/main/rust/Cargo.toml@@ -24,6 +24,8 @@ flate2.workspace = true # crate's own rule. Path dep, not workspace: tilecodec is detached (see its # Cargo.toml), the same way library/map's Rust consumes it. tilecodec = { path = "../../../../library/tilecodec/src/main/rust" }+# Per-block inflate of v7 graph sections (the same pure-Rust decoder tilecodec uses).+ruzstd.workspace = true  # Test-only writer access: device tests synthesize v7 blocked payloads with # `write_blocked`. Same package id, so cargo unifies features for the test
maps/src/main/rust/examples/route_diff.rs
diff --git a/maps/src/main/rust/examples/route_diff.rs b/maps/src/main/rust/examples/route_diff.rsindex 7372a5ec79..9d94453559 100644--- a/maps/src/main/rust/examples/route_diff.rs+++ b/maps/src/main/rust/examples/route_diff.rs@@ -32,7 +32,7 @@ use std::fmt::Write as _; use std::io::Write as _;  use offlinerouter::geometry::{accurate_dist_mm, TrafficSpeeds};-use offlinerouter::graph::{get_pt_at, Graph, LatLon, BICYCLE, DRIVING, NO_NAME, WALK};+use offlinerouter::graph::{archive_path, get_pt_at, Graph, LatLon, BICYCLE, DRIVING, NO_NAME, WALK}; use offlinerouter::routing::{perform_search_loop, prepare_routing, reconstruct_path}; use offlinerouter::state::{RadixHeap, RoutingScratchpad}; @@ -88,7 +88,7 @@ fn need(args: &[String], name: &str) -> Result<String, String> { }  fn load(dir: &str) -> Result<Graph, String> {-    Graph::load(dir).ok_or_else(|| {+    Graph::load(dir).or_else(|| Graph::load_archive(&archive_path(dir))).ok_or_else(|| {         format!("cannot load a graph from {dir} (missing/short files, or a bad metadata.bin header)")     }) }@@ -206,7 +206,7 @@ fn report(args: &[String]) -> Result<bool, String> {      let g = load(&dir)?;     let pairs = read_pairs(&pairs_path)?;-    let speeds: TrafficSpeeds = HashMap::new();+    let speeds = TrafficSpeeds::default();     let mut scratch = RoutingScratchpad::new();     let mut heap = RadixHeap::new(); @@ -585,7 +585,7 @@ fn bench(args: &[String]) -> Result<bool, String> {     let load_ms = load_started.elapsed().as_secs_f64() * 1e3;      let pairs = read_pairs(&pairs_path)?;-    let speeds: TrafficSpeeds = HashMap::new();+    let speeds = TrafficSpeeds::default();     let mut scratch = RoutingScratchpad::new();     let mut heap = RadixHeap::new(); 
maps/src/main/rust/src/geometry.rs
diff --git a/maps/src/main/rust/src/geometry.rs b/maps/src/main/rust/src/geometry.rsindex ee58d78894..a00df731f2 100644--- a/maps/src/main/rust/src/geometry.rs+++ b/maps/src/main/rust/src/geometry.rs@@ -5,6 +5,7 @@ //! casts are reproduced exactly to keep routing output bit-identical.  use std::collections::HashMap;+use std::hash::{BuildHasherDefault, Hasher};  use crate::graph::{     Graph, DEG_TO_RAD, DRIVING, INVALID_EDGE, LIVING_STREET, MAX_DRIVING_KMH, MOTORWAY,@@ -12,7 +13,33 @@ use crate::graph::{ };  /// Live traffic snapshot: global edge id -> speed (km/h). 0 means "unknown".-pub type TrafficSpeeds = HashMap<u64, u8>;+/// Probed once per relaxed edge while driving, so SipHash is replaced by a+/// single multiply.+pub type TrafficSpeeds = HashMap<u64, u8, BuildHasherDefault<EdgeIdHasher>>;++/// Fibonacci hash for `u64` edge ids. The multiply spreads entropy into the high+/// bits, which hashbrown uses for its control bytes.+#[derive(Default)]+pub struct EdgeIdHasher(u64);++impl Hasher for EdgeIdHasher {+    #[inline]+    fn write(&mut self, bytes: &[u8]) {+        for &b in bytes {+            self.0 = (self.0.rotate_left(8) ^ u64::from(b)).wrapping_mul(0x9E37_79B9_7F4A_7C15);+        }+    }++    #[inline]+    fn write_u64(&mut self, n: u64) {+        self.0 = (self.0 ^ n).wrapping_mul(0x9E37_79B9_7F4A_7C15);+    }++    #[inline]+    fn finish(&self) -> u64 {+        self.0+    }+}  /// Bits of an `Edge::type_` byte that carry the OSM road class. The high bits /// are flags — [`REVERSE_GEOMETRY_FLAG`] today — so every consumer that treats
maps/src/main/rust/src/graph_part1.rs
diff --git a/maps/src/main/rust/src/graph_part1.rs b/maps/src/main/rust/src/graph_part1.rsindex 38e9adfe54..9044652edd 100644--- a/maps/src/main/rust/src/graph_part1.rs+++ b/maps/src/main/rust/src/graph_part1.rs@@ -70,23 +70,17 @@ pub struct Graph {     elevation: *const u8,      /// v7 blocked views, parsed (not inflated) at load. `None` on the v6 path,-    /// where the raw pointers above serve directly. The unpacked bytes live in-    /// the [`Graph::unpacked`] caches below on first use.+    /// where the raw pointers above serve directly.+    ///+    /// Each view inflates and keeps a block (4096 records) the first time a+    /// record in it is read. A route only touches the blocks along its search+    /// frontier, whereas inflating whole sections up front meant ~10 GiB of heap+    /// for the world pack on the first route: a multi-minute stall, then an OOM+    /// kill on an 8 GB phone.     nodes_view: Option<BlockedView>,     edges_view: Option<BlockedView>,     elevation_view: Option<BlockedView>, -    /// Lazily inflated v7 sections, one per blocked file. Empty (and the raw-    /// pointers above null) on the v6 path.-    ///-    /// Full-section inflate on first use rather than a per-block cache: routing-    /// touches the whole graph anyway, so steady-state memory equals the v6-    /// resident set and the hot accessors keep their pointer arithmetic. The-    /// cost is a one-time inflate per section on first route, not per lookup.-    unpacked_nodes: std::sync::OnceLock<Vec<u8>>,-    unpacked_edges: std::sync::OnceLock<Vec<u8>>,-    unpacked_elevation: std::sync::OnceLock<Vec<u8>>,-     // Derived cost tables (computed in `load`, matching the C++ `init`).     pub lon_to_mm_scale: [u32; 4096],     pub time_scale_fixed: [u64; 4],@@ -102,11 +96,16 @@ pub struct Graph { pub(crate) struct BlockedView {     record_len: usize,     records_per_block: u64,+    /// `log2(records_per_block)` when it is a power of two (always, for packs+    /// the writer produces), so the hot lookup shifts instead of dividing.+    block_shift: Option<u32>,     unpacked_len: u64,     /// Absolute file offsets of each block start, plus the file end.     offsets: Vec<u64>,     frames: *const u8,-    frames_len: u64,+    /// Inflated blocks, filled on first read. A block that fails to decode is+    /// stored empty, so its records read as absent rather than retrying.+    blocks: Box<[std::sync::OnceLock<Box<[u8]>>]>, }  // Raw pointers into a mapping the graph owns: Send exactly like the tables.@@ -155,27 +154,45 @@ impl BlockedView {         Some(BlockedView {             record_len,             records_per_block,+            block_shift: records_per_block+                .is_power_of_two()+                .then(|| records_per_block.trailing_zeros()),             unpacked_len,             offsets,             frames: bytes.as_ptr(),-            frames_len: bytes.len() as u64,+            blocks: (0..block_count).map(|_| std::sync::OnceLock::new()).collect(),         })     } -    /// Inflate every block and concatenate, verifying the unpacked length.-    /// Called once per section via the graph's `OnceLock`s.-    pub(crate) fn unpack(&self) -> Option<Vec<u8>> {-        let bytes = unsafe { std::slice::from_raw_parts(self.frames, self.frames_len as usize) };-        let parsed = tilecodec::blocked::Blocked::parse(bytes).ok()?;-        let mut cache = tilecodec::blocked::BlockCache::new(0);-        let mut out = Vec::with_capacity(self.unpacked_len as usize);-        for b in 0..parsed.block_count() {-            out.extend_from_slice(cache.get(&parsed, b).ok()?);-        }-        if out.len() as u64 != self.unpacked_len {-            return None;+    /// The `record_len` bytes of record `id`, or `None` when it is out of range+    /// or its block does not decode.+    #[inline]+    pub(crate) fn record(&self, id: u64) -> Option<&[u8]> {+        let (b, i) = match self.block_shift {+            Some(s) => (id >> s, id & (self.records_per_block - 1)),+            None => (id / self.records_per_block, id % self.records_per_block),+        };+        let block = self.blocks.get(b as usize)?.get_or_init(|| self.inflate(b as usize));+        let at = i as usize * self.record_len;+        block.get(at..at + self.record_len)+    }++    /// Decode block `b`'s zstd frame, checking it against the size the header+    /// implies. Empty on any failure.+    #[cold]+    fn inflate(&self, b: usize) -> Box<[u8]> {+        let block_bytes = self.records_per_block * self.record_len as u64;+        let want = block_bytes.min(self.unpacked_len.saturating_sub(b as u64 * block_bytes)) as usize;+        let (start, end) = (self.offsets[b] as usize, self.offsets[b + 1] as usize);+        let frame = unsafe { std::slice::from_raw_parts(self.frames.add(start), end - start) };+        let mut out = Vec::with_capacity(want);+        let decoded = ruzstd::decoding::StreamingDecoder::new(frame)+            .ok()+            .and_then(|mut d| std::io::Read::read_to_end(&mut d, &mut out).ok());+        if decoded.is_none() || out.len() != want {+            return Box::default();         }-        Some(out)+        out.into_boxed_slice()     } } 
maps/src/main/rust/src/graph_part2.rs
diff --git a/maps/src/main/rust/src/graph_part2.rs b/maps/src/main/rust/src/graph_part2.rsindex 8a6b3c1050..0ab5bb85ec 100644--- a/maps/src/main/rust/src/graph_part2.rs+++ b/maps/src/main/rust/src/graph_part2.rs@@ -391,9 +391,6 @@ impl Graph {             nodes_view,             edges_view,             elevation_view,-            unpacked_nodes: std::sync::OnceLock::new(),-            unpacked_edges: std::sync::OnceLock::new(),-            unpacked_elevation: std::sync::OnceLock::new(),             lon_to_mm_scale,             time_scale_fixed,             edge_time_multipliers,
maps/src/main/rust/src/graph_part2b.rs
diff --git a/maps/src/main/rust/src/graph_part2b.rs b/maps/src/main/rust/src/graph_part2b.rsindex a1c3c77a96..51f49c96df 100644--- a/maps/src/main/rust/src/graph_part2b.rs+++ b/maps/src/main/rust/src/graph_part2b.rs@@ -21,28 +21,21 @@ impl Graph {         }     } -    /// A node record out of a v7 blocked section: inflate once (whole section,-    /// cached), then plain indexing. Steady-state memory equals the v6-    /// resident set; the cost is a one-time inflate per section on first-    /// route, not per lookup — which is what keeps the A* hot loop free of-    /// locks and branches past this one.-    #[cold]+    /// A node record out of a v7 blocked section; inflates its block on first+    /// read. Not `#[cold]`: the shipped archive is v7, so this is the A* hot path.+    #[inline]     fn blocked_node(&self, view: &BlockedView, id: u32) -> NodeMaster {-        let bytes = self.unpacked_nodes.get_or_init(|| view.unpack().unwrap_or_default());-        let at = id as usize * 12;-        if at + 12 > bytes.len() {+        let Some(r) = view.record(u64::from(id)).filter(|r| r.len() >= 12) else {             return NodeMaster {                 lat_e7: 0,                 lon_e7: 0,                 edge_ptr: 0,             };-        }+        };         NodeMaster {-            lat_e7: i32::from_le_bytes(bytes[at..at + 4].try_into().expect("4 bytes")),-            lon_e7: i32::from_le_bytes(bytes[at + 4..at + 8].try_into().expect("4 bytes")),-            edge_ptr: u64::from(u32::from_le_bytes(-                bytes[at + 8..at + 12].try_into().expect("4 bytes"),-            )),+            lat_e7: i32::from_le_bytes([r[0], r[1], r[2], r[3]]),+            lon_e7: i32::from_le_bytes([r[4], r[5], r[6], r[7]]),+            edge_ptr: u64::from(u32::from_le_bytes([r[8], r[9], r[10], r[11]])),         }     } @@ -85,18 +78,14 @@ impl Graph {         unsafe { read_at::<i16>(self.elevation, id as usize) }     } -    /// An elevation sample out of a v7 blocked section. Same lazy-inflate-    /// discipline as [`Graph::blocked_node`].+    /// An elevation sample out of a v7 blocked section; inflates its block on+    /// first read.     #[cold]     fn blocked_elevation(&self, view: &BlockedView, id: u32) -> i16 {-        let bytes = self-            .unpacked_elevation-            .get_or_init(|| view.unpack().unwrap_or_default());-        let at = id as usize * 2;-        if at + 2 > bytes.len() {-            return 0;+        match view.record(u64::from(id)) {+            Some(&[a, b, ..]) => i16::from_le_bytes([a, b]),+            _ => 0,         }-        i16::from_le_bytes(bytes[at..at + 2].try_into().expect("2 bytes"))     }      /// `[start, end)` of node `id`'s outgoing edges in `edges.bin`. `id` must be a@@ -164,8 +153,7 @@ impl Graph {     }      /// One edge record, by value. v6 reads the mapped record directly; v7-    /// indexes the lazily inflated section. Same lazy-inflate discipline as-    /// [`Graph::blocked_node`].+    /// reads it out of its lazily inflated block.     #[inline]     fn edge_rec(&self, _source: u32, idx: u64) -> EdgeRec {         if let Some(view) = &self.edges_view {@@ -174,26 +162,23 @@ impl Graph {         unsafe { read_at::<EdgeRec>(self.edges, idx as usize) }     } -    /// An edge record out of a v7 blocked section.-    #[cold]+    /// An edge record out of a v7 blocked section. Hot path, like+    /// [`Graph::blocked_node`].+    #[inline]     fn blocked_edge(&self, view: &BlockedView, idx: u64) -> EdgeRec {-        let bytes = self-            .unpacked_edges-            .get_or_init(|| view.unpack().unwrap_or_default());-        let at = idx as usize * 7;-        if at + 7 > bytes.len() {-            return EdgeRec {+        match view.record(idx) {+            Some(&[d0, d1, x0, x1, x2, type_, speed_limit, ..]) => EdgeRec {+                target_delta: i16::from_le_bytes([d0, d1]),+                dist: [x0, x1, x2],+                type_,+                speed_limit,+            },+            _ => EdgeRec {                 target_delta: 0,                 dist: [0, 0, 0],                 type_: 0,                 speed_limit: 0,-            };-        }-        EdgeRec {-            target_delta: i16::from_le_bytes([bytes[at], bytes[at + 1]]),-            dist: [bytes[at + 2], bytes[at + 3], bytes[at + 4]],-            type_: bytes[at + 5],-            speed_limit: bytes[at + 6],+            },         }     } 
maps/src/main/rust/src/graph_part4.rs
diff --git a/maps/src/main/rust/src/graph_part4.rs b/maps/src/main/rust/src/graph_part4.rsindex 70832f8657..17ff32eb8e 100644--- a/maps/src/main/rust/src/graph_part4.rs+++ b/maps/src/main/rust/src/graph_part4.rs@@ -462,9 +462,6 @@ impl Graph {             nodes_view,             edges_view,             elevation_view,-            unpacked_nodes: std::sync::OnceLock::new(),-            unpacked_edges: std::sync::OnceLock::new(),-            unpacked_elevation: std::sync::OnceLock::new(),             lon_to_mm_scale,             time_scale_fixed,             edge_time_multipliers,
maps/src/main/rust/src/graph_part5.rs
diff --git a/maps/src/main/rust/src/graph_part5.rs b/maps/src/main/rust/src/graph_part5.rsindex 57e619d0cf..c05e371e5e 100644--- a/maps/src/main/rust/src/graph_part5.rs+++ b/maps/src/main/rust/src/graph_part5.rs@@ -344,4 +344,24 @@ mod archive_tests {         assert_eq!(g.edge_count, 0, "the meta's E survives the container");         std::fs::remove_file(&path).ok();     }++    /// Blocks inflate independently, so every record must land in the right+    /// block at the right offset, including across boundaries, in the short last+    /// block, and with a non-power-of-two blocking that takes the divide path.+    #[test]+    fn a_blocked_view_reads_every_record_across_block_boundaries() {+        let recs: Vec<u8> = (0..23u8).flat_map(|i| [i, i.wrapping_mul(7), !i]).collect();+        for per_block in [4u32, 5] {+            let bytes = tilecodec::blocked::write_blocked_with(&recs, 3, per_block);+            let view = BlockedView::parse(&bytes).expect("blocked section parses");+            for i in (0..23u8).rev() {+                assert_eq!(+                    view.record(u64::from(i)),+                    Some(&[i, i.wrapping_mul(7), !i][..]),+                    "record {i} with {per_block} per block"+                );+            }+            assert_eq!(view.record(23), None, "past the end with {per_block} per block");+        }+    } }
maps/src/main/rust/src/jni/routes.rs
diff --git a/maps/src/main/rust/src/jni/routes.rs b/maps/src/main/rust/src/jni/routes.rsindex 1dfb6eb835..ceafa216a1 100644--- a/maps/src/main/rust/src/jni/routes.rs+++ b/maps/src/main/rust/src/jni/routes.rs@@ -3,7 +3,7 @@ //! traffic-prefetch reverse callback, and the walk-leg road snapper the //! transit planner borrows. Pure move out of `lib.rs`; no logic changes. -use std::collections::HashMap;+use std::collections::HashSet; use std::sync::{Arc, Mutex, OnceLock, RwLock};  use jni::objects::{JObject, JString, JValue};@@ -32,7 +32,7 @@ pub(crate) fn graph() -> Option<Arc<Graph>> { /// written by `updateTrafficNative`. pub(crate) fn traffic_speeds() -> &'static RwLock<TrafficSpeeds> {     static S: OnceLock<RwLock<TrafficSpeeds>> = OnceLock::new();-    S.get_or_init(|| RwLock::new(HashMap::new()))+    S.get_or_init(|| RwLock::new(TrafficSpeeds::default())) }  /// Reusable A* working sets, serialized so only one route runs at a time.@@ -55,6 +55,15 @@ fn route_state() -> &'static Mutex<RouteState> { // Traffic prefetch reverse-callback // --------------------------------------------------------------------------- +/// The 1° traffic square containing `(lat_e7, lon_e7)`, packed as Kotlin's+/// `packedSquare`.+fn traffic_square(lat_e7: i32, lon_e7: i32) -> (i32, i32, u32) {+    let lat_idx = (lat_e7 as f64 * 1e-7).floor() as i32;+    let lon_idx = (lon_e7 as f64 * 1e-7).floor() as i32;+    let packed = (((lat_idx + 360) as u32) << 16) | (lon_idx + 720) as u32;+    (lat_idx, lon_idx, packed)+}+ /// Request the traffic square containing `(lat_e7, lon_e7)` from Kotlin if it /// hasn't been requested yet. Mirrors the C++ `ensure_traffic_loaded`. pub(crate) fn ensure_traffic_loaded(@@ -64,9 +73,7 @@ pub(crate) fn ensure_traffic_loaded(     lon_e7: i32,     force_async: bool, ) {-    let lat_idx = (lat_e7 as f64 * 1e-7).floor() as i32;-    let lon_idx = (lon_e7 as f64 * 1e-7).floor() as i32;-    let packed = (((lat_idx + 360) as u32) << 16) | (lon_idx + 720) as u32;+    let (lat_idx, lon_idx, packed) = traffic_square(lat_e7, lon_e7);      {         let mut meta = traffic_meta().lock().unwrap();@@ -157,9 +164,20 @@ pub extern "system" fn Java_com_vayunmathur_maps_util_OfflineRouter_findRouteNat         let RouteState { scratch, heap } = &mut *state;          // prepare + search need the JNI env for the driving traffic prefetch.+        // The search asks on every expansion, but a square once requested stays+        // requested, so only the first ask per square needs the global lock.         let ctx = {+            let mut last_square = u32::MAX;+            let mut seen_squares: HashSet<u32> = HashSet::new();             let mut ensure = |lat_e7: i32, lon_e7: i32| {-                ensure_traffic_loaded(&mut *env, &thiz, lat_e7, lon_e7, false);+                let (_, _, square) = traffic_square(lat_e7, lon_e7);+                if square == last_square {+                    return;+                }+                last_square = square;+                if seen_squares.insert(square) {+                    ensure_traffic_loaded(&mut *env, &thiz, lat_e7, lon_e7, false);+                }             };              let mut ctx = match prepare_routing(
maps/src/main/rust/src/routing/search.rs
diff --git a/maps/src/main/rust/src/routing/search.rs b/maps/src/main/rust/src/routing/search.rsindex 522bed6766..0a8a6bcf75 100644--- a/maps/src/main/rust/src/routing/search.rs+++ b/maps/src/main/rust/src/routing/search.rs@@ -218,7 +218,6 @@ pub fn prepare_routing(         {             let entry = scratch.get_entry(node);             entry.g_fwd = t_actual;-            entry.g_bwd = t_actual;         }         let n_data = g.get_node(node);         let h = heuristic_time_10ms(g, n_data.lat_e7, n_data.lon_e7, end.proj_lat, end.proj_lon, mode);@@ -417,20 +416,27 @@ pub fn perform_search_loop(     let mut best_total = u32::MAX;     while !heap.empty() && ctx.iterations < 25_000_000 {         ctx.iterations += 1;-        let u = heap.pop();+        let (score, u) = heap.pop();          let u_cost = scratch.get_entry(u).g_fwd;         if u >= g.node_count {             continue;         }         let n_u = g.node(u);+        let h_u = heuristic_time_10ms(+            g, n_u.lat_e7, n_u.lon_e7, ctx.end.proj_lat, ctx.end.proj_lon, mode,+        );+        // A node is re-pushed every time its cost improves, so older entries for it+        // linger in the heap. The fresh entry pops first and already expanded the+        // node at this same cost, so expanding a stale one again finds nothing new.+        if score != u_cost.wrapping_add(h_u) {+            continue;+        }          // `f` is a lower bound on any route through `u`, and the heap pops in         // non-decreasing `f` order, so once it cannot beat a completed route         // nothing left can.-        let f_u = u_cost.saturating_add(heuristic_time_10ms(-            g, n_u.lat_e7, n_u.lon_e7, ctx.end.proj_lat, ctx.end.proj_lon, mode,-        ));+        let f_u = u_cost.saturating_add(h_u);         if f_u >= best_total {             break;         }@@ -471,7 +477,6 @@ pub fn perform_search_loop(                 let entry_v = scratch.get_entry(v);                 if new_g < entry_v.g_fwd {                     entry_v.g_fwd = new_g;-                    entry_v.g_bwd = new_g;                     entry_v.p_fwd = u;                     true                 } else {
maps/src/main/rust/src/state.rs
diff --git a/maps/src/main/rust/src/state.rs b/maps/src/main/rust/src/state.rsindex 3dcbc0e88e..b9957019c3 100644--- a/maps/src/main/rust/src/state.rs+++ b/maps/src/main/rust/src/state.rs@@ -51,8 +51,9 @@ impl RadixHeap {         self.count += 1;     } +    /// Pops the minimum entry as `(score, node_id)`.     #[inline]-    pub fn pop(&mut self) -> u32 {+    pub fn pop(&mut self) -> (u32, u32) {         if self.buckets[0].is_empty() {             // Lowest non-empty bucket above 0 holds the current minimum; drain it             // down against the new last_pop_value (standard radix-heap advance).@@ -71,7 +72,7 @@ impl RadixHeap {          let node = self.buckets[0].pop().expect("bucket 0 non-empty after refill");         self.count -= 1;-        node.id+        (node.score, node.id)     }      pub fn clear(&mut self) {@@ -90,25 +91,17 @@ impl RadixHeap {  // --- Routing scratchpad --- +/// Kept to 8 bytes so a long search touches as few cache lines as possible. #[derive(Clone, Copy)] pub struct Entry {-    pub node_id: u32,     pub g_fwd: u32,-    pub g_bwd: u32,     pub p_fwd: u32,-    #[allow(dead_code)]-    pub p_bwd: u32, }  impl Entry {-    /// Freshly-allocated pages are memset to 0xFF, matching the C++ page-    /// initializer.     const FRESH: Entry = Entry {-        node_id: 0xFFFF_FFFF,         g_fwd: 0xFFFF_FFFF,-        g_bwd: 0xFFFF_FFFF,         p_fwd: 0xFFFF_FFFF,-        p_bwd: 0xFFFF_FFFF,     }; } @@ -152,10 +145,6 @@ impl RoutingScratchpad {         }          let page = self.directory[dir_idx].as_mut().unwrap();-        let e = &mut page[page_offset];-        if e.node_id == 0xFFFF_FFFF {-            e.node_id = node_id;-        }-        e+        &mut page[page_offset]     } }