Modern Apps git

← Modern-Apps.git

maps: parallelise the graph sorts and bound the pass reorder buffer

Commit
e0cac3b3cb4ba540c06986d694225baaab9feb15
Author
vayun-mathur <[email protected]>
When
2026-08-26 04:35 UTC (3 months ago)
Parents
2ad0841

Diff

scripts/maps/osm_ingest/Cargo.lock
diff --git a/scripts/maps/osm_ingest/Cargo.lock b/scripts/maps/osm_ingest/Cargo.lockindex f596afcd72..cbbe116df1 100644--- a/scripts/maps/osm_ingest/Cargo.lock+++ b/scripts/maps/osm_ingest/Cargo.lock@@ -8,6 +8,37 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" +[[package]]+name = "crossbeam-deque"+version = "0.8.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5181e0de7b61eb03a81e347d6dd8797bae9da5146707b51077e2d71a54ec0ceb"+dependencies = [+ "crossbeam-epoch",+ "crossbeam-utils",+]++[[package]]+name = "crossbeam-epoch"+version = "0.9.20"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2d6914041f254d6e9176c01941b21115dcfb7089e55135a35411081bd106ef3f"+dependencies = [+ "crossbeam-utils",+]++[[package]]+name = "crossbeam-utils"+version = "0.8.22"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "61803da095bee82a81bb1a452ecc25d3b2f1416d1897eb86430c6159ef717c17"++[[package]]+name = "either"+version = "1.17.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9e5e8f6c15a24b9a3ee5efec809ccd006d3b30e8b3bb63c39af737c7f87daa1d"+ [[package]] name = "miniz_oxide" version = "0.8.9"@@ -22,4 +53,25 @@ name = "osm_ingest" version = "0.1.0" dependencies = [  "miniz_oxide",+ "rayon",+]++[[package]]+name = "rayon"+version = "1.12.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d"+dependencies = [+ "either",+ "rayon-core",+]++[[package]]+name = "rayon-core"+version = "1.13.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91"+dependencies = [+ "crossbeam-deque",+ "crossbeam-utils", ]
scripts/maps/osm_ingest/Cargo.toml
diff --git a/scripts/maps/osm_ingest/Cargo.toml b/scripts/maps/osm_ingest/Cargo.tomlindex 7f2a252603..814d2a9b6c 100644--- a/scripts/maps/osm_ingest/Cargo.toml+++ b/scripts/maps/osm_ingest/Cargo.toml@@ -8,10 +8,22 @@ # # Deliberately DETACHED from the Android Rust workspace (the empty [workspace] # table below), exactly like `scripts/maps/gtfs_ingest`: it is a host binary, so-# `cargo build` here never pulls the aarch64-android toolchain or the app-# crates' lints. Its single dependency, `miniz_oxide`, is a pure-Rust-# DECODE-ONLY inflate implementation already in the local registry cache (the-# app's maps crate pulls it via flate2), so builds still resolve offline.+# `cargo build` here never pulls the aarch64-android toolchain or the app crates'+# lints.+#+# Both dependencies are pure Rust and no C toolchain is involved:+#+#   miniz_oxide  DECODE-ONLY inflate. We only ever decompress the zlib blobs+#                inside a .osm.pbf, so the deflate side is not needed here (unlike+#                tile_build, which writes gzip).+#   rayon        the work-stealing pool behind the spatial sort and the graph+#                writer. Sized by `par::threads()`, so `--threads` and+#                `MAPS_THREADS` govern it rather than the whole box.+#+# `cargo build --offline` resolves both from the local registry cache, along with+# rayon's own tree (rayon-core, crossbeam-deque, crossbeam-utils, crossbeam-epoch,+# either). That is a statement about THIS box's cache, not a guarantee: a clean+# machine needs one online `cargo fetch` before it can build offline. [package] name = "osm_ingest" version = "0.1.0"@@ -40,6 +52,7 @@ path = "src/bin/osm_extract.rs" # Pure-Rust inflate. We only ever DECOMPRESS the zlib blobs inside a .osm.pbf, # so a decode-only crate is enough and keeps the C toolchain out of the build. miniz_oxide = "0.8"+rayon = "1"  [profile.release] opt-level = 3
scripts/maps/osm_ingest/src/chains.rs
diff --git a/scripts/maps/osm_ingest/src/chains.rs b/scripts/maps/osm_ingest/src/chains.rsindex 8f80a09714..6a47486e15 100644--- a/scripts/maps/osm_ingest/src/chains.rs+++ b/scripts/maps/osm_ingest/src/chains.rs@@ -42,7 +42,7 @@ //! Both of those were bugs that had to be fixed once already.  use std::fs::File;-use std::io::{BufReader, BufWriter, Read, Seek, SeekFrom, Write};+use std::io::{BufReader, BufWriter, Read, Write}; use std::path::{Path, PathBuf};  use crate::compact::Chain;@@ -778,22 +778,52 @@ pub(crate) struct PointReader {  impl PointReader {     /// Replace `out` with the `len` points starting at point index `start`.+    ///+    /// One positional read rather than a seek followed by a read. This is the only+    /// random read in the graph writer — once per edge that stores a polyline — and+    /// `osm_ingest/README.md` records that pass as 47 minutes at 21% CPU with 17.8 M+    /// voluntary context switches, so halving its syscall count is worth the platform+    /// split.+    ///+    /// Still `&mut self`, because `buf` is reused: the writer is sequential, and an+    /// allocation per edge would cost more than the seek this removes. Making the read+    /// positional is nonetheless what a parallel writer would need first, since the+    /// handle's cursor is no longer part of the result.     pub fn read(&mut self, start: u64, len: u32, out: &mut Vec<geom::Pt>) -> Result<()> {         out.clear();         if len == 0 {             return Ok(());         }-        self.file-            .seek(SeekFrom::Start(start * CHAIN_PT_BYTES))-            .map_err(io_err)?;         self.buf.clear();         self.buf.resize(len as usize * CHAIN_PT_BYTES as usize, 0);-        self.file.read_exact(&mut self.buf).map_err(io_err)?;+        read_exact_at(&self.file, &mut self.buf, start * CHAIN_PT_BYTES).map_err(io_err)?;         out.extend(self.buf.chunks_exact(CHAIN_PT_BYTES as usize).map(decode_pt));         Ok(())     } } +/// Fill `buf` from `offset` in one call, without moving the file's cursor.+///+/// Neither platform's positional read is guaranteed to return everything at once,+/// hence the loop; in practice it goes round once.+fn read_exact_at(file: &File, mut buf: &mut [u8], mut offset: u64) -> std::io::Result<()> {+    while !buf.is_empty() {+        #[cfg(windows)]+        let n = std::os::windows::fs::FileExt::seek_read(file, buf, offset)?;+        #[cfg(unix)]+        let n = std::os::unix::fs::FileExt::read_at(file, buf, offset)?;+        if n == 0 {+            return Err(std::io::Error::new(+                std::io::ErrorKind::UnexpectedEof,+                "chains.pts ended mid-chain",+            ));+        }+        buf = &mut buf[n..];+        offset += n as u64;+    }+    Ok(())+}+ fn io_err(e: std::io::Error) -> Error {     Error(e.to_string()) }
scripts/maps/osm_ingest/src/graph_build.rs
diff --git a/scripts/maps/osm_ingest/src/graph_build.rs b/scripts/maps/osm_ingest/src/graph_build.rsindex 6f1c06f2d9..2be5d7fff5 100644--- a/scripts/maps/osm_ingest/src/graph_build.rs+++ b/scripts/maps/osm_ingest/src/graph_build.rs@@ -67,6 +67,7 @@ use crate::par; use crate::pbf::{self, KIND_NODES, KIND_WAYS}; use crate::proto::{Error, Result}; use crate::spatial::{accurate_dist_mm, spatial_from_e7};+use rayon::prelude::*; use crate::tags;  /// Node ids at or above this are skipped, exactly as in the C++. The bitset that@@ -677,7 +678,14 @@ pub fn build_with(input: &Path, out_dir: &Path, opts: Options) -> Result<Stats>         }     }     debug_assert_eq!(keys.len(), kept_count as usize);-    keys.sort_by_key(|(spatial, _)| *spatial);+    // The key is `(spatial, dense)`, and the loop above pushed `dense` ascending, so+    // this is exactly the order the previous STABLE `sort_by_key(spatial)` produced:+    // ties there fell back to insertion order, which was ascending `dense`. Spelling+    // the tie-break into the key makes the order total, and a total order is what lets+    // an UNSTABLE parallel sort be substituted without changing a single final id --+    // and final ids are what `nodes.bin`, `edges.bin` and every offset in the pack are+    // numbered by, so this is the one comparison in the build that must not move.+    par::install(|| keys.par_sort_unstable());      let mut final_of_kept = vec![0u32; kept_count as usize];     let mut node_coords: Vec<geom::Pt> = Vec::with_capacity(kept_count as usize);@@ -1039,10 +1047,36 @@ fn build_csr(spill: &chains::Spill, kept_count: u32, ids: &FinalIds) -> Result<C     // Per group, so `twin_is_unique` can binary-search it. Sorting the whole array     // would be one comparison sort over a billion elements; this is millions of     // sorts over a handful each.-    for v in 0..kept_count as usize {-        let (a, b) = (edge_ptr[v] as usize, edge_ptr[v + 1] as usize);-        targets[a..b].sort_unstable();+    //+    // Parallelised by carving `targets` into one disjoint slice per WORKER, each+    // covering a contiguous span of nodes, rather than one slice per group: a+    // `&mut [u32]` is 16 bytes, and a planet graph has around a billion groups, so+    // collecting them all would cost more memory than the graph. Sorting `u32`s has+    // one answer, so nothing here depends on the order the work happens in.+    let n = kept_count as usize;+    let workers = par::threads().min(n).max(1);+    let mut pieces: Vec<(usize, usize, &mut [u32])> = Vec::with_capacity(workers);+    let mut rest: &mut [u32] = &mut targets;+    let mut consumed = 0usize;+    for w in 0..workers {+        let lo = n * w / workers;+        let hi = n * (w + 1) / workers;+        let end = edge_ptr[hi] as usize;+        let (mine, tail) = rest.split_at_mut(end - consumed);+        pieces.push((lo, hi, mine));+        rest = tail;+        consumed = end;     }+    let ptr = &edge_ptr;+    par::install(|| {+        pieces.par_iter_mut().for_each(|(lo, hi, buf)| {+            let base = ptr[*lo] as usize;+            for v in *lo..*hi {+                let (a, b) = (ptr[v] as usize - base, ptr[v + 1] as usize - base);+                buf[a..b].sort_unstable();+            }+        });+    });     println!("{total} directed edge(s) from chains");     Ok(Csr { edge_ptr, targets }) }@@ -3121,6 +3155,79 @@ mod tests {         }     } +    /// The gate for threading the graph build: all six outputs must be byte-identical+    /// at every thread count.+    ///+    /// `nodes.bin` is the one that would move first. Final node ids come from the+    /// spatial sort, and every offset in `edges.bin`, `lanes.bin` and+    /// `intermediate.bin` is expressed in terms of them — so a sort whose order is not+    /// total would not corrupt one file, it would silently renumber the whole pack.+    /// Multiple rounds are covered too, because `write_graph` partitions by source and+    /// each round writes its own slice of `intermediate.bin`.+    #[test]+    fn the_thread_count_changes_no_graph_bytes() {+        for rounds in [1u32, 3] {+            let (pbf_path, base_dir) = testpbf::write_sample(&format!("graph_threads_{rounds}_1"));+            let run = |n: usize, dir: &Path| {+                crate::par::set_threads(n);+                build_with(+                    &pbf_path,+                    dir,+                    Options {+                        rounds,+                        ..Default::default()+                    },+                )+                .unwrap();+                read_outputs(dir)+            };+            let base = run(1, &base_dir);+            for n in [2, 3, 32] {+                let (_, dir) = testpbf::write_sample(&format!("graph_threads_{rounds}_{n}"));+                let got = run(n, &dir);+                assert_eq!(got.meta, base.meta, "{rounds} round(s), {n} threads: metadata.bin");+                assert_eq!(got.nodes, base.nodes, "{rounds} round(s), {n} threads: nodes.bin");+                assert_eq!(got.edges, base.edges, "{rounds} round(s), {n} threads: edges.bin");+                assert_eq!(got.lanes, base.lanes, "{rounds} round(s), {n} threads: lanes.bin");+                assert_eq!(got.names, base.names, "{rounds} round(s), {n} threads: road_names.bin");+                assert_eq!(got.inter, base.inter, "{rounds} round(s), {n} threads: intermediate.bin");+            }+        }+        crate::par::clear_threads();+    }++    /// The substitution the spatial sort relies on: because the key is total, an+    /// unstable sort produces exactly what the old stable `sort_by_key(spatial)` did.+    ///+    /// Ties on `spatial` are the only case where the two could differ, so the fixture+    /// is mostly ties, with `dense` ascending as the real builder pushes them.+    #[test]+    fn the_spatial_key_is_total_so_an_unstable_sort_matches_the_stable_one() {+        let keys: Vec<(u64, u32)> = vec![+            (5, 0),+            (3, 1),+            (5, 2),+            (1, 3),+            (3, 4),+            (5, 5),+            (1, 6),+            (9, 7),+            (3, 8),+        ];+        // What the code used to do: stable, keyed on `spatial` alone, so ties kept+        // their insertion order -- which was ascending `dense`.+        let mut stable = keys.clone();+        stable.sort_by_key(|(spatial, _)| *spatial);+        // What it does now.+        let mut unstable = keys;+        unstable.par_sort_unstable();+        assert_eq!(unstable, stable);+        // And the property that makes it true: no two entries share a full key.+        let mut seen = unstable.clone();+        seen.dedup();+        assert_eq!(seen.len(), unstable.len(), "the key must be unique per node");+    }+     // ---- the within-way chain path ---------------------------------------      fn within_opts() -> Options {
scripts/maps/osm_ingest/src/par.rs
diff --git a/scripts/maps/osm_ingest/src/par.rs b/scripts/maps/osm_ingest/src/par.rsindex 3c06a99a18..d8cd7b8491 100644--- a/scripts/maps/osm_ingest/src/par.rs+++ b/scripts/maps/osm_ingest/src/par.rs@@ -11,7 +11,7 @@ //! uncapped pool oversubscribes the box once they do.  use std::sync::atomic::{AtomicUsize, Ordering};-use std::sync::Mutex;+use std::sync::{Arc, Mutex};  /// 0 means "not set"; any other value is an explicit cap from `--threads`. static OVERRIDE: AtomicUsize = AtomicUsize::new(0);@@ -87,6 +87,46 @@ pub fn parse_threads(value: &str) -> std::result::Result<usize, String> {         .ok_or_else(|| format!("--threads wants a positive count, not {value}")) } +/// Our own rayon pool rather than the global one, so the cap above governs it.+///+/// Cached, and rebuilt only when the requested count changes. In production that+/// happens once, because `--threads` is read before any work starts; the reason it+/// is not a `OnceLock` is that the byte-identity tests build the same graph at+/// several thread counts in one process, and a pool fixed on first use would make+/// those tests assert nothing.+///+/// `map_chunks` above does not use this — it owns its own scoped threads and its+/// own ordered merge. This is for the phases that are a plain sort or map, where+/// rayon's work stealing is worth more than a hand-rolled split.+fn pool() -> Arc<rayon::ThreadPool> {+    static POOL: Mutex<Option<(usize, Arc<rayon::ThreadPool>)>> = Mutex::new(None);+    let want = threads();+    let mut cached = POOL.lock().expect("thread pool mutex");+    if let Some((have, p)) = cached.as_ref() {+        if *have == want {+            return Arc::clone(p);+        }+    }+    let built = Arc::new(build_pool(want).unwrap_or_else(|e| {+        eprintln!("WARNING: cannot start a {want}-thread pool ({e}); continuing on one thread");+        build_pool(1).expect("a one-thread pool")+    }));+    *cached = Some((want, Arc::clone(&built)));+    built+}++fn build_pool(n: usize) -> std::result::Result<rayon::ThreadPool, rayon::ThreadPoolBuildError> {+    rayon::ThreadPoolBuilder::new()+        .num_threads(n)+        .thread_name(|i| format!("osm_ingest-{i}"))+        .build()+}++/// Run `f` on the pool, so it sees our thread cap rather than rayon's global one.+pub fn install<R: Send>(f: impl FnOnce() -> R + Send) -> R {+    pool().install(f)+}+ /// Apply `f(chunk_start, chunk)` to every chunk of `chunk_len` items, returning /// the results in chunk order. pub fn map_chunks<T, R, F>(items: &[T], chunk_len: usize, f: F) -> Vec<R>
scripts/maps/osm_ingest/src/pbf.rs
diff --git a/scripts/maps/osm_ingest/src/pbf.rs b/scripts/maps/osm_ingest/src/pbf.rsindex 1d0967e122..a344c90c36 100644--- a/scripts/maps/osm_ingest/src/pbf.rs+++ b/scripts/maps/osm_ingest/src/pbf.rs@@ -18,7 +18,7 @@ use std::fs::File; use std::io::{BufReader, Read, Seek, SeekFrom, Write}; use std::path::Path; use std::sync::atomic::{AtomicU8, AtomicUsize, Ordering};-use std::sync::Mutex;+use std::sync::{Condvar, Mutex};  use crate::proto::{self, Error, Reader, Result, WIRE_BYTES}; @@ -298,6 +298,16 @@ where     let last_pct = AtomicUsize::new(usize::MAX);     let n_threads = crate::par::threads().min(n_chunks);     let mut first_err: Option<Error> = None;+    // How far ahead of the sink the workers may run.+    //+    // Without this the reorder buffer is unbounded: a worker deposits and immediately+    // claims another chunk, so one slow chunk 0 can park every other chunk's+    // accumulator in `slots` at once. On a planet pass those accumulators are the+    // largest things in the build, and raising the thread count widens the window,+    // which is exactly the failure this plan is shaped to avoid. Two chunks per thread+    // leaves slack for an uneven chunk without letting the buffer grow with the file.+    let window = n_threads.saturating_mul(2).max(2);+    let progressed = Condvar::new();      std::thread::scope(|scope| {         let mut handles = Vec::with_capacity(n_threads);@@ -312,6 +322,15 @@ where                     if chunk >= n_chunks {                         return Ok(());                     }+                    // Hold off until this chunk is inside the window. The worker that+                    // owns the lowest outstanding chunk always passes this test, so it+                    // always makes progress and the wait cannot deadlock.+                    {+                        let mut d = drain.lock().expect("chunk slot mutex");+                        while chunk >= d.next + window {+                            d = progressed.wait(d).expect("chunk slot mutex");+                        }+                    }                     let start = chunk * CHUNK_BLOBS;                     let end = ((chunk + 1) * CHUNK_BLOBS).min(blobs.len());                     let mut state = make();@@ -330,6 +349,7 @@ where                         report(label, &done_blobs, &last_pct, blobs.len());                     }                     drain.lock().expect("chunk slot mutex").deposit(chunk, state);+                    progressed.notify_all();                 }             }));         }@@ -450,6 +470,98 @@ mod tests {     use super::*;     use crate::testpbf; +    /// A file with enough `OSMData` blobs to span several chunks, so the reorder+    /// buffer and its window are actually reached.+    fn multi_chunk_pbf(chunks: usize) -> (std::path::PathBuf, std::path::PathBuf) {+        let block = testpbf::primitive_block();+        let blobs = chunks * CHUNK_BLOBS;+        let refs: Vec<&[u8]> = (0..blobs).map(|_| block.as_slice()).collect();+        let bytes = testpbf::pbf_from_blocks(refs);+        let dir = std::env::temp_dir().join(format!(+            "osm_ingest_window_{}_{chunks}_{:?}",+            std::process::id(),+            std::thread::current().id()+        ));+        let _ = std::fs::remove_dir_all(&dir);+        std::fs::create_dir_all(&dir).unwrap();+        let path = dir.join("many.osm.pbf");+        std::fs::write(&path, &bytes).unwrap();+        (path, dir)+    }++    /// The reorder buffer must not grow with the file.+    ///+    /// A worker deposits a finished chunk and immediately claims another, so without a+    /// window one slow chunk 0 parks every later chunk's accumulator at once — and on a+    /// planet pass those accumulators are the largest things in the build. Chunk 0 is+    /// made slow here on purpose; the counter is what proves the bound, because the+    /// pass would produce correct output either way.+    #[test]+    fn the_reorder_buffer_stays_bounded_when_the_first_chunk_lags() {+        let (path, _dir) = multi_chunk_pbf(40);+        crate::par::set_threads(4);+        let blobs = scan_blobs(&path).unwrap();+        let n_chunks = blobs.len().div_ceil(CHUNK_BLOBS);+        assert!(n_chunks >= 40, "{n_chunks} chunk(s) is not enough to bound anything");++        // Accumulators alive right now, and the worst it ever got.+        let live = std::sync::Arc::new(AtomicUsize::new(0));+        let peak = std::sync::Arc::new(AtomicUsize::new(0));++        struct Acc {+            live: std::sync::Arc<AtomicUsize>,+        }+        impl Drop for Acc {+            fn drop(&mut self) {+                self.live.fetch_sub(1, Ordering::SeqCst);+            }+        }++        let first_seen = AtomicUsize::new(0);+        let (mk_live, mk_peak) = (live.clone(), peak.clone());+        let drained = std::sync::Mutex::new(Vec::new());+        run_pass_sink(+            &path,+            &blobs,+            None,+            KIND_NODES,+            "window",+            || {+                let n = mk_live.fetch_add(1, Ordering::SeqCst) + 1;+                mk_peak.fetch_max(n, Ordering::SeqCst);+                Acc { live: mk_live.clone() }+            },+            |_acc, _block| {+                // Only the very first chunk to start is slowed, which is enough to make+                // every other worker run ahead of the sink.+                if first_seen.fetch_add(1, Ordering::SeqCst) == 0 {+                    std::thread::sleep(std::time::Duration::from_millis(300));+                }+                Ok(KIND_NODES)+            },+            |acc: Acc| {+                drained.lock().unwrap().push(());+                drop(acc);+                Ok(())+            },+        )+        .unwrap();++        assert_eq!(drained.into_inner().unwrap().len(), n_chunks, "every chunk drains");+        assert_eq!(live.load(Ordering::SeqCst), 0, "an accumulator leaked");+        // 4 threads => a window of 8, plus the one each worker is filling. Well under+        // the ~40 that would pile up if the workers were free to run to the end of the+        // file, which is what makes this assertion mean something.+        let bound = 8 + 4;+        let got = peak.load(Ordering::SeqCst);+        assert!(+            got <= bound,+            "{got} accumulators were live at once over {n_chunks} chunks; \+             the window should have held it to {bound}"+        );+        crate::par::clear_threads();+    }+     #[test]     fn round_trips_a_synthetic_file() {         let (path, _dir) = testpbf::write_sample("pbf_pass");
scripts/maps/osm_ingest/src/testpbf.rs
diff --git a/scripts/maps/osm_ingest/src/testpbf.rs b/scripts/maps/osm_ingest/src/testpbf.rsindex 8572608f72..bac9e375c3 100644--- a/scripts/maps/osm_ingest/src/testpbf.rs+++ b/scripts/maps/osm_ingest/src/testpbf.rs@@ -323,6 +323,15 @@ pub fn sample_pbf() -> Vec<u8> { }  fn pbf_from_block(block: &[u8]) -> Vec<u8> {+    pbf_from_blocks(std::iter::once(block))+}++/// A complete `.osm.pbf` with one `OSMData` blob per block.+///+/// Exists so a test can produce more than the one chunk `CHUNK_BLOBS` groups blobs+/// into. Everything about `run_pass_sink` that is interesting under concurrency — the+/// reorder buffer, its window, the ordered drain — is inert on a single-chunk file.+pub fn pbf_from_blocks<'a>(blocks: impl IntoIterator<Item = &'a [u8]>) -> Vec<u8> {     let mut header_block = Vec::new();     bytes_field(4, b"OsmSchema-V0.6", &mut header_block);     bytes_field(4, b"DenseNodes", &mut header_block);@@ -333,7 +342,9 @@ fn pbf_from_block(block: &[u8]) -> Vec<u8> {      let mut out = Vec::new();     framed("OSMHeader", &header_blob, &mut out);-    framed("OSMData", &data_blob(block), &mut out);+    for block in blocks {+        framed("OSMData", &data_blob(block), &mut out);+    }     out }