From c49205423f7cb4cabe1c2d3ff035bb8d7c77c387 Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Fri, 6 Nov 2026 14:19:05 +0100 Subject: [PATCH] STRA-338 size: model-format: wrap long comments and format strings to 120 columns (width 69->0) --- .../src/bulk_read/for_each_chunk.rs | 6 ++-- .../src/bulk_read/impl_strategy.rs | 6 ++-- .../src/gguf/parse_artifact_digest.rs | 3 +- ...ead_metadata_snapshot_with_architecture.rs | 3 +- .../src/gguf/stream_buffer_bytes.rs | 3 +- .../admits_flash_metadata_and_rejects.rs | 5 ++- ...uffered_cursor_preserves_offsets_parsin.rs | 3 +- ...empty_owned_tensor_validation_preserves.rs | 6 +++- .../original_first_source_fence_retains.rs | 3 +- .../gguf_resident/impl_verifiedgguffile.rs | 6 ++-- .../gguf_resident/impl_verifiedgguffile_2.rs | 3 +- .../src/gguf_resident/next_source_id.rs | 3 +- crates/model-format/src/huge_pages.rs | 33 +++++++++++++------ crates/model-format/src/kar.rs | 33 ++++++++++++------- .../src/kar/impl_karpleprofile.rs | 3 +- .../src/kar/impl_std_fmt_display.rs | 3 +- .../src/kar/impl_verifiedkarpleartifact.rs | 12 ++++--- .../kar/impl_verifiedkarpleartifact/verify.rs | 5 ++- .../src/kar/independent_handles.rs | 12 ++++--- crates/model-format/src/kar/read_region.rs | 3 +- crates/model-format/src/kar_extents.rs | 9 +++-- .../src/kar_extents/impl_extent.rs | 3 +- .../kar_kernel_model/decode_params_valid.rs | 3 +- .../kar_kernel_model/impl_fmt_display_for.rs | 3 +- .../src/kar_levels/impl_fmt_display_for.rs | 3 +- .../src/kar_levels/impl_selection.rs | 3 +- crates/model-format/src/native_dense_plan.rs | 6 ++-- .../src/pinned_arena_plan/fnv1a64_fn.rs | 3 +- .../src/pinned_arena_plan/load_experts_fn.rs | 3 +- .../ple_reader/impl_pagesource_for_file.rs | 3 +- .../model-format/src/ple_reader/impl_state.rs | 6 ++-- crates/model-format/src/ple_reader/tests.rs | 9 +++-- .../max_inflight_bounds_concurrent_reads.rs | 4 ++- .../tests/prefetched_keys_are_matched.rs | 24 ++++++++++---- .../tests/rows_match_the_oracle_including.rs | 4 ++- .../src/qwen4exp/expected_inventory.rs | 3 +- .../src/qwen4exp/impl_fmt_display_for.rs | 3 +- .../qwen4exp/validate_owner_index_split.rs | 3 +- .../impl_qwen4expartifact.rs | 6 ++-- .../impl_qwen4expartifact.rs | 3 +- .../impl_qwen4expartifact_2.rs | 3 +- .../retention_metadata_bytes.rs | 3 +- crates/model-format/src/readahead.rs | 12 ++++--- 43 files changed, 189 insertions(+), 87 deletions(-) diff --git a/crates/model-format/src/bulk_read/for_each_chunk.rs b/crates/model-format/src/bulk_read/for_each_chunk.rs index 15baa981..817311b3 100644 --- a/crates/model-format/src/bulk_read/for_each_chunk.rs +++ b/crates/model-format/src/bulk_read/for_each_chunk.rs @@ -3,7 +3,8 @@ #[allow(unused_imports)] use super::*; -/// Read `file[start .. start + len]` in blocks on several threads and hand each block to `sink(absolute_offset, bytes)`. +/// Read `file[start .. start + len]` in blocks on several threads and hand each block to `sink(absolute_offset, +/// bytes)`. /// Blocks arrive in no particular order, from different threads; each covers a distinct range of at most `plan.chunk` /// bytes. The first error stops the others and is returned. pub fn for_each_chunk(file: &File, start: u64, len: u64, plan: Plan, sink: F) -> io::Result @@ -17,7 +18,8 @@ where if len == 0 { return Ok(Report { strategy, bytes: 0, elapsed: began.elapsed() }); } - // The block that reaches the file's last bytes may be shorter than its aligned length: `read_full` stops at the end. + // The block that reaches the file's last bytes may be shorter than its aligned length: `read_full` stops at the + // end. let threads = plan.threads.clamp(1, len.div_ceil(chunk) as usize); let mut buffers = aligned_buffers(threads, chunk as usize + 2 * ALIGN)?; let mut shared = Shared::new(file, (strategy, direct), (start, len, file_len, chunk), plan.ahead, &sink); diff --git a/crates/model-format/src/bulk_read/impl_strategy.rs b/crates/model-format/src/bulk_read/impl_strategy.rs index f0f7a472..66010aad 100644 --- a/crates/model-format/src/bulk_read/impl_strategy.rs +++ b/crates/model-format/src/bulk_read/impl_strategy.rs @@ -1,4 +1,5 @@ -//! Moved out of the parent module by STRA-338: impl Strategy, impl Plan, impl Default_for_Plan, impl Report, impl Aligned, fn open_direct .... +//! Moved out of the parent module by STRA-338: impl Strategy, impl Plan, impl Default_for_Plan, impl Report, impl +//! Aligned, fn open_direct .... #[allow(unused_imports)] use super::*; @@ -15,7 +16,8 @@ impl Strategy { impl Plan { /// The defaults, then the environment (`LELEKA_LOAD_READ=direct|advise|plain`, `LELEKA_LOAD_THREADS=N`, - /// `LELEKA_LOAD_CHUNK_MIB=N`, `LELEKA_LOAD_AHEAD_MIB=N`): the switches that let one binary be measured in each form. + /// `LELEKA_LOAD_CHUNK_MIB=N`, `LELEKA_LOAD_AHEAD_MIB=N`): the switches that let one binary be measured in each + /// form. pub fn from_env() -> Plan { Plan::with_overrides(Plan::default(), |name| std::env::var(name).ok()) } diff --git a/crates/model-format/src/gguf/parse_artifact_digest.rs b/crates/model-format/src/gguf/parse_artifact_digest.rs index 3d77bd38..1d89241a 100644 --- a/crates/model-format/src/gguf/parse_artifact_digest.rs +++ b/crates/model-format/src/gguf/parse_artifact_digest.rs @@ -1,4 +1,5 @@ -//! Moved out of the parent module by STRA-338: fn parse_artifact_digest, fn sha256_pipelined, fn stream_file_span, fn read_file_span_owned, fn read_file_span_into, fn check_flash_next_profile .... +//! Moved out of the parent module by STRA-338: fn parse_artifact_digest, fn sha256_pipelined, fn stream_file_span, fn +//! read_file_span_owned, fn read_file_span_into, fn check_flash_next_profile .... #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/gguf/read_metadata_snapshot_with_architecture.rs b/crates/model-format/src/gguf/read_metadata_snapshot_with_architecture.rs index 5d199b8f..9ec30506 100644 --- a/crates/model-format/src/gguf/read_metadata_snapshot_with_architecture.rs +++ b/crates/model-format/src/gguf/read_metadata_snapshot_with_architecture.rs @@ -1,4 +1,5 @@ -//! Moved out of the parent module by STRA-338: fn read_metadata_snapshot_with_architecture, fn validate_tokenizer_metadata, fn inspect, fn tensor_index, fn tensor_sha256, fn read_index. +//! Moved out of the parent module by STRA-338: fn read_metadata_snapshot_with_architecture, fn +//! validate_tokenizer_metadata, fn inspect, fn tensor_index, fn tensor_sha256, fn read_index. #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/gguf/stream_buffer_bytes.rs b/crates/model-format/src/gguf/stream_buffer_bytes.rs index a9aab2e9..6d51dd91 100644 --- a/crates/model-format/src/gguf/stream_buffer_bytes.rs +++ b/crates/model-format/src/gguf/stream_buffer_bytes.rs @@ -1,4 +1,5 @@ -//! Moved out of the parent module by STRA-338: fn stream_buffer_bytes, fn stream_buffer_bytes, fn with_test_stream_buffer. +//! Moved out of the parent module by STRA-338: fn stream_buffer_bytes, fn stream_buffer_bytes, fn +//! with_test_stream_buffer. #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/gguf/tests/admits_flash_metadata_and_rejects.rs b/crates/model-format/src/gguf/tests/admits_flash_metadata_and_rejects.rs index 80fbe356..b9b8c4c4 100644 --- a/crates/model-format/src/gguf/tests/admits_flash_metadata_and_rejects.rs +++ b/crates/model-format/src/gguf/tests/admits_flash_metadata_and_rejects.rs @@ -1,4 +1,7 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): admits_flash_metadata_and_rejects_incompatible_profiles, inspects_header_and_rejects_truncated_payload, indexes_exact_mixed_tensor_spans_and_rejects_bad_layouts, owned_handle_verifies_artifact_and_streams_exact_tensor_bytes_with_bounded_chunks .... +//! Tests of tests by topic (moved out of the test file by STRA-338): +//! admits_flash_metadata_and_rejects_incompatible_profiles, inspects_header_and_rejects_truncated_payload, +//! indexes_exact_mixed_tensor_spans_and_rejects_bad_layouts, +//! owned_handle_verifies_artifact_and_streams_exact_tensor_bytes_with_bounded_chunks .... #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/gguf/tests/buffered_cursor_preserves_offsets_parsin.rs b/crates/model-format/src/gguf/tests/buffered_cursor_preserves_offsets_parsin.rs index 65201e42..ef78c933 100644 --- a/crates/model-format/src/gguf/tests/buffered_cursor_preserves_offsets_parsin.rs +++ b/crates/model-format/src/gguf/tests/buffered_cursor_preserves_offsets_parsin.rs @@ -1,4 +1,5 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): buffered_cursor_preserves_offsets_parsing_and_refusals_with_bounded_reads. +//! Tests of tests by topic (moved out of the test file by STRA-338): +//! buffered_cursor_preserves_offsets_parsing_and_refusals_with_bounded_reads. #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/gguf/tests/empty_owned_tensor_validation_preserves.rs b/crates/model-format/src/gguf/tests/empty_owned_tensor_validation_preserves.rs index 5b487d91..127466c1 100644 --- a/crates/model-format/src/gguf/tests/empty_owned_tensor_validation_preserves.rs +++ b/crates/model-format/src/gguf/tests/empty_owned_tensor_validation_preserves.rs @@ -1,4 +1,8 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): empty_owned_tensor_validation_preserves_cursor_bounds_and_size_checks, owned_tensor_bounds_are_checked_before_any_callback_and_stream_can_recover, pathname_replacement_keeps_original_verified_file_and_index, opened_file_size_changes_are_refused_and_same_size_mutation_is_not_immutability. +//! Tests of tests by topic (moved out of the test file by STRA-338): +//! empty_owned_tensor_validation_preserves_cursor_bounds_and_size_checks, +//! owned_tensor_bounds_are_checked_before_any_callback_and_stream_can_recover, +//! pathname_replacement_keeps_original_verified_file_and_index, +//! opened_file_size_changes_are_refused_and_same_size_mutation_is_not_immutability. #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/gguf/tests/original_first_source_fence_retains.rs b/crates/model-format/src/gguf/tests/original_first_source_fence_retains.rs index 069e4be5..15312305 100644 --- a/crates/model-format/src/gguf/tests/original_first_source_fence_retains.rs +++ b/crates/model-format/src/gguf/tests/original_first_source_fence_retains.rs @@ -1,4 +1,5 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): original_first_source_fence_retains_opened_fd_cursor_and_refuses_length_changes. +//! Tests of tests by topic (moved out of the test file by STRA-338): +//! original_first_source_fence_retains_opened_fd_cursor_and_refuses_length_changes. #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/gguf_resident/impl_verifiedgguffile.rs b/crates/model-format/src/gguf_resident/impl_verifiedgguffile.rs index 1f853899..60b9c49a 100644 --- a/crates/model-format/src/gguf_resident/impl_verifiedgguffile.rs +++ b/crates/model-format/src/gguf_resident/impl_verifiedgguffile.rs @@ -152,7 +152,8 @@ impl VerifiedGgufFile { #[allow(unsafe_code)] fn map_view(&self, map_offset: u64, map_len: usize) -> LoadResult<*mut std::ffi::c_void> { use std::os::windows::io::AsRawHandle; - // SAFETY: a fresh read-only view of the retained verified handle at a granularity-aligned offset inside the indexed file. + // SAFETY: a fresh read-only view of the retained verified handle at a granularity-aligned offset inside the + // indexed file. let view = unsafe { leleka_libc_shim::map_file_readonly(self.file.as_raw_handle().cast(), map_offset, map_len) }; if view.is_null() { @@ -183,7 +184,8 @@ impl VerifiedGgufFile { Ok(output) } - /// The indexed tensor of `resident` holds exactly its bytes, and `length` bytes at `offset` lie inside it and the file. + /// The indexed tensor of `resident` holds exactly its bytes, and `length` bytes at `offset` lie inside it and the + /// file. fn check_resident_span(&self, resident: &ResidentTensor, offset: u64, length: u64) -> Result<()> { let tensor = self.index.tensors.get(resident.tensor_number).ok_or("GGUF tensor index is out of bounds")?; if tensor.bytes == 0 diff --git a/crates/model-format/src/gguf_resident/impl_verifiedgguffile_2.rs b/crates/model-format/src/gguf_resident/impl_verifiedgguffile_2.rs index ce1f20b7..225f4921 100644 --- a/crates/model-format/src/gguf_resident/impl_verifiedgguffile_2.rs +++ b/crates/model-format/src/gguf_resident/impl_verifiedgguffile_2.rs @@ -1,4 +1,5 @@ -//! Moved out of the parent module by STRA-338: impl VerifiedGgufFile, impl VerifiedGgufFile, impl ResidentTensor, impl VerifiedGgufFile. +//! Moved out of the parent module by STRA-338: impl VerifiedGgufFile, impl VerifiedGgufFile, impl ResidentTensor, impl +//! VerifiedGgufFile. #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/gguf_resident/next_source_id.rs b/crates/model-format/src/gguf_resident/next_source_id.rs index 8c1a59ba..7b018cd2 100644 --- a/crates/model-format/src/gguf_resident/next_source_id.rs +++ b/crates/model-format/src/gguf_resident/next_source_id.rs @@ -1,4 +1,5 @@ -//! Moved out of the parent module by STRA-338: fn next_source_id, impl ResidentTensor, impl ResidentStorage, impl std_ops_Deref, impl FileSpan, impl Drop_for_FileSpan. +//! Moved out of the parent module by STRA-338: fn next_source_id, impl ResidentTensor, impl ResidentStorage, impl +//! std_ops_Deref, impl FileSpan, impl Drop_for_FileSpan. #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/huge_pages.rs b/crates/model-format/src/huge_pages.rs index f9749c43..582a6c08 100644 --- a/crates/model-format/src/huge_pages.rs +++ b/crates/model-format/src/huge_pages.rs @@ -12,10 +12,12 @@ //! lets the fault compact) and `MADV_POPULATE_WRITE` to fault the whole range in before the file is read into it. //! //! [`settle`] (called by the stack after the bank load and the shard page-cache drop, before the banks are page-locked) -//! reports the coverage from `/proc/self/smaps` and, when some 2 MiB ranges fell back to 4 KiB pages, asks the kernel to +//! reports the coverage from `/proc/self/smaps` and, when some 2 MiB ranges fell back to 4 KiB pages, asks the kernel +//! to //! collapse them synchronously (`MADV_COLLAPSE`, Linux 6.1+, independent of the THP sysfs knobs; best effort). //! -//! `LELEKA_HUGEPAGES=thp` skips the hugetlbfs attempt. `LELEKA_BANK_THP=on` (the older claude/decode-parity knob, which only +//! `LELEKA_HUGEPAGES=thp` skips the hugetlbfs attempt. `LELEKA_BANK_THP=on` (the older claude/decode-parity knob, which +//! only //! advised the unaligned heap `Vec`) now selects `thp` too. Off by default. The bytes are the file's either way: this //! changes where the banks live, never what they hold. No system setting is read-write here. #![allow(unsafe_code)] @@ -31,7 +33,8 @@ pub enum Mode { Thp, } -/// The mode of this process (`LELEKA_HUGEPAGES` = `on` | `thp` | `off`; unset = `off`, or `thp` with `LELEKA_BANK_THP=on`). +/// The mode of this process (`LELEKA_HUGEPAGES` = `on` | `thp` | `off`; unset = `off`, or `thp` with +/// `LELEKA_BANK_THP=on`). pub fn mode() -> Mode { static MODE: std::sync::OnceLock = std::sync::OnceLock::new(); *MODE.get_or_init(|| { @@ -189,7 +192,8 @@ mod linux { fn advise_and_populate(&self) -> std::io::Result<()> { let (base, map_len) = (self.base, self.map_len); - // SAFETY: advice over our own live mapping; MADV_HUGEPAGE changes no contents (EINVAL without THP support: ignored). + // SAFETY: advice over our own live mapping; MADV_HUGEPAGE changes no contents (EINVAL without THP support: + // ignored). unsafe { libc::madvise(base as *mut libc::c_void, map_len, libc::MADV_HUGEPAGE); } @@ -217,7 +221,8 @@ mod linux { if self.hugetlb { self.map_len } else { self.len } } pub(crate) fn as_slice(&self) -> &[u8] { - // SAFETY: `base..base + map_len` is our live mapping and `len <= map_len`; anonymous memory is initialised (zero or written). + // SAFETY: `base..base + map_len` is our live mapping and `len <= map_len`; anonymous memory is initialised + // (zero or written). unsafe { std::slice::from_raw_parts(self.base as *const u8, self.len) } } pub(crate) fn as_mut_slice(&mut self) -> &mut [u8] { @@ -295,7 +300,11 @@ mod linux { fn line(label: &str, c: &Coverage) -> String { let huge = c.thp_bytes + c.hugetlb_bytes; format!( - "leleka-hugepages: {label}: {} bank buffers {:.2} GiB, huge {:.2} GiB ({:.1} %; THP {:.2}, hugetlbfs {:.2})", + concat!( + "leleka-hugepages: {}: {} bank buffers {:.2} GiB, huge {:.2} GiB ", + "({:.1} %; THP {:.2}, hugetlbfs {:.2})" + ), + label, c.buffers, gib(c.mapped_bytes), gib(huge), @@ -305,8 +314,10 @@ mod linux { ) } - /// Report the coverage and collapse the 2 MiB ranges that fell back to 4 KiB pages (`MADV_COLLAPSE`, synchronous, best - /// effort). Call before the banks are page-locked (a pinned page cannot be collapsed). `None` when nothing is placed. + /// Report the coverage and collapse the 2 MiB ranges that fell back to 4 KiB pages (`MADV_COLLAPSE`, synchronous, + /// best + /// effort). Call before the banks are page-locked (a pinned page cannot be collapsed). `None` when nothing is + /// placed. pub fn settle() -> Option { if mode() == Mode::Off { return None; @@ -335,13 +346,15 @@ mod linux { /// Asks the kernel to collapse each range into huge pages; returns (ranges that failed, last errno). fn collapse(ranges: &[(usize, usize)]) -> (usize, i32) { - // linux/mman-common.h MADV_COLLAPSE = 25 (6.1+). Spelled out because libc 0.2.190 does not define it for the musl targets + // linux/mman-common.h MADV_COLLAPSE = 25 (6.1+). Spelled out because libc 0.2.190 does not define it for the + // musl targets // (the static CLI build failed to compile); glibc's libc::MADV_COLLAPSE has the same value. const MADV_COLLAPSE: libc::c_int = 25; let mut failed = 0usize; let mut last_error = 0i32; for &(base, len) in ranges.iter().filter(|r| r.1 > 0) { - // SAFETY: advice over a live mapping of ours; MADV_COLLAPSE copies pages into a huge page without changing contents. + // SAFETY: advice over a live mapping of ours; MADV_COLLAPSE copies pages into a huge page without changing + // contents. if unsafe { libc::madvise(base as *mut libc::c_void, len, MADV_COLLAPSE) } != 0 { failed += 1; last_error = std::io::Error::last_os_error().raw_os_error().unwrap_or(0); diff --git a/crates/model-format/src/kar.rs b/crates/model-format/src/kar.rs index 55c52b61..4c6d9b42 100644 --- a/crates/model-format/src/kar.rs +++ b/crates/model-format/src/kar.rs @@ -158,11 +158,13 @@ struct VerifiedPart { pub enum KarTrust { /// The whole archive was read once and matched its pinned SHA-256 and every section CRC-32. FullPass, - /// A verification stamp for exactly this file in exactly this state (device, inode, size, mtime, ctime) stood in for the pass. + /// A verification stamp for exactly this file in exactly this state (device, inode, size, mtime, ctime) stood in + /// for the pass. Stamp, /// The parent process copied this unlinked memfd from a stamped file and said so (`--kar-attested-by-stamp`). AttestedMemfd, - /// A sparse memfd (`verify_sparse`): the bytes of its extents matched the pinned digest of the extents; the rest is a hole. + /// A sparse memfd (`verify_sparse`): the bytes of its extents matched the pinned digest of the extents; the rest is + /// a hole. SparseExtents, } @@ -174,7 +176,8 @@ pub struct KarStartupRead { pub metadata_bytes: u64, /// The partition books (8 bytes each). pub book_bytes: u64, - /// Bytes hashed by the verification: the whole archive for `FullPass`, the extents for `SparseExtents`, otherwise 0. + /// Bytes hashed by the verification: the whole archive for `FullPass`, the extents for `SparseExtents`, otherwise + /// 0. pub hashed_bytes: u64, } @@ -190,12 +193,16 @@ pub struct VerifiedKarPleArtifact { /// Verified against a pinned digest of `serve_extents` instead of the whole archive (a sparse memfd). sparse: bool, startup: KarStartupRead, - /// The state of an ordinary archive file when it was verified (`None` for a sealed memfd, which cannot change, and where the - /// platform has no such fields). Every row read compares the open file with it: a write, `touch`, `chmod` or rename of the - /// file after verification refuses the read instead of serving bytes nobody checked. See `identity_recheck_enabled`. + /// The state of an ordinary archive file when it was verified (`None` for a sealed memfd, which cannot change, and + /// where the + /// platform has no such fields). Every row read compares the open file with it: a write, `touch`, `chmod` or rename + /// of the + /// file after verification refuses the read instead of serving bytes nobody checked. See + /// `identity_recheck_enabled`. identity: Option, } -/// Handles a row read spreads its threads over. On Windows each has a file object of its own (a synchronous handle serializes the +/// Handles a row read spreads its threads over. On Windows each has a file object of its own (a synchronous handle +/// serializes the /// requests made through it, whatever the number of threads: 100,000 random reads of a cold chunk took 10 s that way). const ROW_HANDLES: usize = 16; /// Rows of the PLE table read through an owned handle of the archive (`VerifiedKarPleArtifact::row_reader`): the same @@ -206,10 +213,13 @@ pub struct KarPleRowReader { archive_bytes: u64, identity: Option, } -/// A row read (three positional reads) that a warm file serves in this many nanoseconds or less takes the single-thread path. -/// Memory-served reads of 10-20 bytes take about 1 us each; a read that waits for a device takes tens of microseconds or more. +/// A row read (three positional reads) that a warm file serves in this many nanoseconds or less takes the single-thread +/// path. +/// Memory-served reads of 10-20 bytes take about 1 us each; a read that waits for a device takes tens of microseconds +/// or more. const WARM_ROW_NS: u128 = 20_000; -/// After a cold verdict the next calls read in parallel without probing (a cold file would pay the probe's latency each time). +/// After a cold verdict the next calls read in parallel without probing (a cold file would pay the probe's latency each +/// time). const COLD_SKIP_CALLS: u32 = 256; static COLD_SKIP: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0); @@ -293,7 +303,8 @@ mod row_read_tests { // the reference: one thread, no probe let mut reference = vec![KarPleRowPacket { payload: [0; 50], partition: 0 }; 16]; read_rows_chunk(&file, &parts, &rows, &mut reference).unwrap(); - // the file is in the page cache: the probe takes the single-thread path (or, on a loaded machine, falls back to threads; + // the file is in the page cache: the probe takes the single-thread path (or, on a loaded machine, falls + // back to threads; // the packets are the same either way) COLD_SKIP.store(0, Ordering::Relaxed); let probed = read_rows_parallel(&files, &parts, total, None, &rows, 8, 2, true).unwrap(); diff --git a/crates/model-format/src/kar/impl_karpleprofile.rs b/crates/model-format/src/kar/impl_karpleprofile.rs index 3212ff49..aad30c3c 100644 --- a/crates/model-format/src/kar/impl_karpleprofile.rs +++ b/crates/model-format/src/kar/impl_karpleprofile.rs @@ -1,4 +1,5 @@ -//! Moved out of the parent module by STRA-338: impl KarPleProfile, impl KarPleRowPacket, fn is_unlinked, fn is_unlinked, impl KarTrust, impl KarStartupRead. +//! Moved out of the parent module by STRA-338: impl KarPleProfile, impl KarPleRowPacket, fn is_unlinked, fn +//! is_unlinked, impl KarTrust, impl KarStartupRead. #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/kar/impl_std_fmt_display.rs b/crates/model-format/src/kar/impl_std_fmt_display.rs index 3dc437e7..6ae6d7c9 100644 --- a/crates/model-format/src/kar/impl_std_fmt_display.rs +++ b/crates/model-format/src/kar/impl_std_fmt_display.rs @@ -1,4 +1,5 @@ -//! Moved out of the parent module by STRA-338: impl std_fmt_Display, impl std_error_Error, fn typed, impl KarTensorSource, impl KarInspection. +//! Moved out of the parent module by STRA-338: impl std_fmt_Display, impl std_error_Error, fn typed, impl +//! KarTensorSource, impl KarInspection. #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/kar/impl_verifiedkarpleartifact.rs b/crates/model-format/src/kar/impl_verifiedkarpleartifact.rs index f4998f48..4b870fb7 100644 --- a/crates/model-format/src/kar/impl_verifiedkarpleartifact.rs +++ b/crates/model-format/src/kar/impl_verifiedkarpleartifact.rs @@ -10,7 +10,8 @@ impl VerifiedKarPleArtifact { pub fn verify(source: KarImmutableSource, profile: KarPleProfile) -> Result { Self::verify_with(source, profile, None) } - /// `verify` for a sealed memfd that holds only the bytes the serve path reads (holes elsewhere, same file offsets and + /// `verify` for a sealed memfd that holds only the bytes the serve path reads (holes elsewhere, same file offsets + /// and /// length): the full-archive SHA-256 and the payload CRCs cannot be computed, so the pinned `extents_sha256` /// ([`digest_extents_with`] over `serve_extents`, measured once from the archive that matched its full pin) stands /// in for them, and the directory digest in the header (checked by `inspect`, inside the extents) covers the rest. @@ -80,9 +81,12 @@ impl VerifiedKarPleArtifact { if rows.iter().any(|r| *r >= PLE_ROWS) { return Err(KarError::Range("KAR PLE row outside table")); } - // 16 rows are 48 random reads of a cold file: eight threads on handles of their own, two rows each. A file the page cache - // holds answers each read in about a microsecond, and eight thread starts and joins then cost more than the reads - // (about 0.1 ms per token of a decode window); `warm_probe` reads the first row on this thread, times it, and reads the + // 16 rows are 48 random reads of a cold file: eight threads on handles of their own, two rows each. A file the + // page cache + // holds answers each read in about a microsecond, and eight thread starts and joins then cost more than the + // reads + // (about 0.1 ms per token of a decode window); `warm_probe` reads the first row on this thread, times it, and + // reads the // other fifteen here too when it was served from memory. let packets = read_rows_parallel( self.row_handles(), diff --git a/crates/model-format/src/kar/impl_verifiedkarpleartifact/verify.rs b/crates/model-format/src/kar/impl_verifiedkarpleartifact/verify.rs index a3ec4f73..2a392472 100644 --- a/crates/model-format/src/kar/impl_verifiedkarpleartifact/verify.rs +++ b/crates/model-format/src/kar/impl_verifiedkarpleartifact/verify.rs @@ -34,7 +34,10 @@ impl Admission { let stamps = crate::verify_stamp::global(); // An unlinked sealed memfd: only if the parent attested the copy (see `set_attested_archive`). let attested_memfd = identity.is_none() && crate::verify_stamp::attested_archive() && is_unlinked(&reader.file); - let stamped = matches!((stamps, identity.as_ref()), (Some(s), Some(id)) if s.trusts("kar", &profile.spec.archive_sha256, id)); + let stamped = match (stamps, identity.as_ref()) { + (Some(s), Some(id)) => s.trusts("kar", &profile.spec.archive_sha256, id), + _ => false, + }; Self { identity, stamps, attested_memfd, stamped } } diff --git a/crates/model-format/src/kar/independent_handles.rs b/crates/model-format/src/kar/independent_handles.rs index 711ad1f3..10cd74fb 100644 --- a/crates/model-format/src/kar/independent_handles.rs +++ b/crates/model-format/src/kar/independent_handles.rs @@ -1,4 +1,5 @@ -//! Moved out of the parent module by STRA-338: fn independent_handles, fn reopen_independent, fn reopen_independent, impl KarPleRowReader, fn read_rows_parallel, fn check_archive_state .... +//! Moved out of the parent module by STRA-338: fn independent_handles, fn reopen_independent, fn reopen_independent, +//! impl KarPleRowReader, fn read_rows_parallel, fn check_archive_state .... #[allow(unused_imports)] use super::*; @@ -125,8 +126,10 @@ fn read_fanned_out( }); results.into_iter().collect() } -/// The per-read guard of the archive: the pinned length, and for an ordinary file the state it had when it was verified. One `fstat` (the -/// length check always did one); a different size, modification time or change time (any write, `touch`, `chmod`, rename or hard link made +/// The per-read guard of the archive: the pinned length, and for an ordinary file the state it had when it was +/// verified. One `fstat` (the +/// length check always did one); a different size, modification time or change time (any write, `touch`, `chmod`, +/// rename or hard link made /// after verification) is refused rather than served. pub(super) fn check_archive_state( file: &File, @@ -145,7 +148,8 @@ pub(super) fn check_archive_state( Ok(()) } -/// `LELEKA_KAR_IDENTITY_RECHECK=off` (or `0`) turns the per-read comparison with the verified file state off (a file system that does not +/// `LELEKA_KAR_IDENTITY_RECHECK=off` (or `0`) turns the per-read comparison with the verified file state off (a file +/// system that does not /// keep `ctime` stable, for example). Read once; the default is on. pub(super) fn identity_recheck_enabled() -> bool { static ENABLED: std::sync::OnceLock = std::sync::OnceLock::new(); diff --git a/crates/model-format/src/kar/read_region.rs b/crates/model-format/src/kar/read_region.rs index 79e1131b..cc52c9c1 100644 --- a/crates/model-format/src/kar/read_region.rs +++ b/crates/model-format/src/kar/read_region.rs @@ -1,4 +1,5 @@ -//! Moved out of the parent module by STRA-338: fn read_region, fn u16_at, fn u32_at, fn u64_at, fn crc32, fn crc32_step .... +//! Moved out of the parent module by STRA-338: fn read_region, fn u16_at, fn u32_at, fn u64_at, fn crc32, fn crc32_step +//! .... #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/kar_extents.rs b/crates/model-format/src/kar_extents.rs index d7278113..b5c6d04a 100644 --- a/crates/model-format/src/kar_extents.rs +++ b/crates/model-format/src/kar_extents.rs @@ -33,10 +33,13 @@ pub const PLE_ROW_PLANE_BYTES: u64 = 20; /// Planes the serve path reads (level 2). pub const PLE_PLANES: u64 = 2; -/// SHA-256 of the extents of the pinned archive (see [`digest_extents_with`]): 2 extents, 16,000,348,672 bytes, measured on the -/// real archive file on the 5090 server (2026-11-02, `kar_census ARCHIVE --hash-extents`, 161.9 s at <= 300 MiB/s) -- the file +/// SHA-256 of the extents of the pinned archive (see [`digest_extents_with`]): 2 extents, 16,000,348,672 bytes, +/// measured on the +/// real archive file on the 5090 server (2026-11-02, `kar_census ARCHIVE --hash-extents`, 161.9 s at <= 300 MiB/s) -- +/// the file /// that every holder job copies and whose full SHA-256 the engine checks on each of those copies. Hex: -/// 7568b1211419a7c10a9b39a86230f75b7fa9c02839e36c9b5f2494ec7af72143. While it is all zero a sparse copy is refused unless the +/// 7568b1211419a7c10a9b39a86230f75b7fa9c02839e36c9b5f2494ec7af72143. While it is all zero a sparse copy is refused +/// unless the /// operator supplies the digest explicitly. pub const PLE_EXTENTS_SHA256: [u8; 32] = [ 117, 104, 177, 33, 20, 25, 167, 193, 10, 155, 57, 168, 98, 48, 247, 91, 127, 169, 192, 40, 57, 227, 108, 155, 95, diff --git a/crates/model-format/src/kar_extents/impl_extent.rs b/crates/model-format/src/kar_extents/impl_extent.rs index 187085a8..60ddeda9 100644 --- a/crates/model-format/src/kar_extents/impl_extent.rs +++ b/crates/model-format/src/kar_extents/impl_extent.rs @@ -1,4 +1,5 @@ -//! Moved out of the parent module by STRA-338: impl Extent, fn extents_bytes, fn normalize_extents, fn extents_cover, fn extents_overlap, fn digest_extents_with .... +//! Moved out of the parent module by STRA-338: impl Extent, fn extents_bytes, fn normalize_extents, fn extents_cover, +//! fn extents_overlap, fn digest_extents_with .... #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/kar_kernel_model/decode_params_valid.rs b/crates/model-format/src/kar_kernel_model/decode_params_valid.rs index 43e37676..f1696bed 100644 --- a/crates/model-format/src/kar_kernel_model/decode_params_valid.rs +++ b/crates/model-format/src/kar_kernel_model/decode_params_valid.rs @@ -1,4 +1,5 @@ -//! Moved out of the parent module by STRA-338: fn decode_params_valid, fn decode_grid, fn kernel_decode, fn kernel_multiply, fn kernel_swiglu, fn stage_packet. +//! Moved out of the parent module by STRA-338: fn decode_params_valid, fn decode_grid, fn kernel_decode, fn +//! kernel_multiply, fn kernel_swiglu, fn stage_packet. #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/kar_kernel_model/impl_fmt_display_for.rs b/crates/model-format/src/kar_kernel_model/impl_fmt_display_for.rs index 8e4cb482..3dfe69c8 100644 --- a/crates/model-format/src/kar_kernel_model/impl_fmt_display_for.rs +++ b/crates/model-format/src/kar_kernel_model/impl_fmt_display_for.rs @@ -1,4 +1,5 @@ -//! Moved out of the parent module by STRA-338: impl fmt_Display_for, impl std_error_Error, fn reject, fn round_up, impl WindowPlan, fn plan_window .... +//! Moved out of the parent module by STRA-338: impl fmt_Display_for, impl std_error_Error, fn reject, fn round_up, impl +//! WindowPlan, fn plan_window .... #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/kar_levels/impl_fmt_display_for.rs b/crates/model-format/src/kar_levels/impl_fmt_display_for.rs index 057d0e1d..2d36a0c1 100644 --- a/crates/model-format/src/kar_levels/impl_fmt_display_for.rs +++ b/crates/model-format/src/kar_levels/impl_fmt_display_for.rs @@ -1,4 +1,5 @@ -//! Moved out of the parent module by STRA-338: impl fmt_Display_for, impl std_error_Error, impl TensorClass, impl ClassLevels, fn check_level, impl ArchiveView .... +//! Moved out of the parent module by STRA-338: impl fmt_Display_for, impl std_error_Error, impl TensorClass, impl +//! ClassLevels, fn check_level, impl ArchiveView .... #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/kar_levels/impl_selection.rs b/crates/model-format/src/kar_levels/impl_selection.rs index c2af56b8..b6868d9b 100644 --- a/crates/model-format/src/kar_levels/impl_selection.rs +++ b/crates/model-format/src/kar_levels/impl_selection.rs @@ -1,4 +1,5 @@ -//! Moved out of the parent module by STRA-338: impl Selection, fn align, impl GpuWindow, impl RowShape, impl GpuRows, impl ScratchBytes .... +//! Moved out of the parent module by STRA-338: impl Selection, fn align, impl GpuWindow, impl RowShape, impl GpuRows, +//! impl ScratchBytes .... #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/native_dense_plan.rs b/crates/model-format/src/native_dense_plan.rs index 497419a7..c80ea631 100644 --- a/crates/model-format/src/native_dense_plan.rs +++ b/crates/model-format/src/native_dense_plan.rs @@ -1,6 +1,7 @@ //! Literal host port of the Original `src/core/native_dense.cpp` (`NativeDense::served_names`, //! `keep_unquantized_ple_key`, and the whole planning/validation half of `NativeDense::load`): which GGUF tensors are -//! served natively, split-shard consistency, payload span validation, bytes per matrix and the shared Q8_1 scratch size. +//! served natively, split-shard consistency, payload span validation, bytes per matrix and the shared Q8_1 scratch +//! size. //! The device upload (`cudaMalloc` + `cudaMemcpy` + attaching `native_data`/`native_type`/`native_q8_1`) is the //! runtime's; this module produces the exact list it must perform and refuses with the Original's messages. //! @@ -92,7 +93,8 @@ pub fn eligible(row: &TensorRow, include_ple_key: bool) -> bool { if !name.starts_with("blk.") { return false; } - // Match the native PLE kernel: Q2_0, IQ3_XXS, IQ4_XS and Q8_0 (UD-Q4_K_XL). Other keys retain the packed BF16 fallback. + // Match the native PLE kernel: Q2_0, IQ3_XXS, IQ4_XS and Q8_0 (UD-Q4_K_XL). Other keys retain the packed BF16 + // fallback. if name == "blk.1.ple_key.weight" { return include_ple_key && matches!(row.kind, 42 | 18 | 23 | 8); } diff --git a/crates/model-format/src/pinned_arena_plan/fnv1a64_fn.rs b/crates/model-format/src/pinned_arena_plan/fnv1a64_fn.rs index 0cf7e39f..1cd2a572 100644 --- a/crates/model-format/src/pinned_arena_plan/fnv1a64_fn.rs +++ b/crates/model-format/src/pinned_arena_plan/fnv1a64_fn.rs @@ -1,4 +1,5 @@ -//! Moved out of the parent module by STRA-338: fn fnv1a64, impl SharedArenaHeader, fn plan_shared_file, fn shared_mapping_note, fn open_shared_arena_file, fn arena_pin_cap_gib .... +//! Moved out of the parent module by STRA-338: fn fnv1a64, impl SharedArenaHeader, fn plan_shared_file, fn +//! shared_mapping_note, fn open_shared_arena_file, fn arena_pin_cap_gib .... #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/pinned_arena_plan/load_experts_fn.rs b/crates/model-format/src/pinned_arena_plan/load_experts_fn.rs index 1518f18c..9dc0a6e3 100644 --- a/crates/model-format/src/pinned_arena_plan/load_experts_fn.rs +++ b/crates/model-format/src/pinned_arena_plan/load_experts_fn.rs @@ -18,7 +18,8 @@ pub fn load_experts( let off: Vec = (0..layers).map(|l| l * blobs_per_layer * blob_bytes).collect(); load_experts_ranges(path, dst, &off, &vec![n; layers as usize], threads, chunk) } -/// `load_experts_ranges`: reads layer `L` (`layer_bytes[L]` bytes at file offset `layer_off[L]`) into `dst[layer_off[L]..]` +/// `load_experts_ranges`: reads layer `L` (`layer_bytes[L]` bytes at file offset `layer_off[L]`) into +/// `dst[layer_off[L]..]` /// with `threads` workers, `chunk` bytes per read, and returns one FNV-1a per layer. A short read is an error, never a /// zero fill. #[cfg(unix)] diff --git a/crates/model-format/src/ple_reader/impl_pagesource_for_file.rs b/crates/model-format/src/ple_reader/impl_pagesource_for_file.rs index 851ca517..fccb98d6 100644 --- a/crates/model-format/src/ple_reader/impl_pagesource_for_file.rs +++ b/crates/model-format/src/ple_reader/impl_pagesource_for_file.rs @@ -1,4 +1,5 @@ -//! Moved out of the parent module by STRA-338: impl PageSource_for_File, impl fmt_Display_for, impl std_error_Error, fn err, impl PleReaderConfig, impl ReaderStats .... +//! Moved out of the parent module by STRA-338: impl PageSource_for_File, impl fmt_Display_for, impl std_error_Error, fn +//! err, impl PleReaderConfig, impl ReaderStats .... #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/ple_reader/impl_state.rs b/crates/model-format/src/ple_reader/impl_state.rs index fa56b907..b431a6dd 100644 --- a/crates/model-format/src/ple_reader/impl_state.rs +++ b/crates/model-format/src/ple_reader/impl_state.rs @@ -105,8 +105,10 @@ impl Shared { pub(super) fn run(&self, job: Job, issued: Instant, delay: Duration) { let mut buf = AlignedBuf::new(2 * PAGE); let length = job.read.length; - // A source that panics is a failed read like any other: the worker survives, the reader fails and every ticket is released. - // Unwinding past this point would end the worker with the job's ticket still pending, and its `collect` would wait for ever. + // A source that panics is a failed read like any other: the worker survives, the reader fails and every ticket + // is released. + // Unwinding past this point would end the worker with the job's ticket still pending, and its `collect` would + // wait for ever. let read = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { read_full_at(self.source.as_ref(), buf.window(length), job.read.offset) })) diff --git a/crates/model-format/src/ple_reader/tests.rs b/crates/model-format/src/ple_reader/tests.rs index 1d215f76..100459a9 100644 --- a/crates/model-format/src/ple_reader/tests.rs +++ b/crates/model-format/src/ple_reader/tests.rs @@ -79,10 +79,12 @@ fn cfg(offset: u64, rows: u64) -> PleReaderConfig { PleReaderConfig::new(offset, rows) } -// ---- a failed read never leaves a later ticket waiting (upstream ebe3383a: after a failed read the worker parked, `issue` kept +// ---- a failed read never leaves a later ticket waiting (upstream ebe3383a: after a failed read the worker parked, +// `issue` kept // queueing and the next `collect` blocked for ever). Every blocking call below runs on its own thread with a deadline. -/// Run `f` on a thread and return its result, or panic when it does not finish in five seconds (the hang this guards against). +/// Run `f` on a thread and return its result, or panic when it does not finish in five seconds (the hang this guards +/// against). fn within(what: &str, f: impl FnOnce() -> T + Send + 'static) -> T { let (tx, rx) = std::sync::mpsc::channel(); thread::spawn(move || { @@ -115,7 +117,8 @@ impl PageSource for Flaky { } } -/// Rows whose first page is page `page` of a table at offset 0 with 90-byte rows (row 45 = byte 4050 straddles pages 0 and 1). +/// Rows whose first page is page `page` of a table at offset 0 with 90-byte rows (row 45 = byte 4050 straddles pages 0 +/// and 1). fn row_on_page(page: u64) -> u32 { (page * PAGE as u64 / 90 + 1) as u32 } diff --git a/crates/model-format/src/ple_reader/tests/max_inflight_bounds_concurrent_reads.rs b/crates/model-format/src/ple_reader/tests/max_inflight_bounds_concurrent_reads.rs index 8345655f..fad90043 100644 --- a/crates/model-format/src/ple_reader/tests/max_inflight_bounds_concurrent_reads.rs +++ b/crates/model-format/src/ple_reader/tests/max_inflight_bounds_concurrent_reads.rs @@ -1,4 +1,6 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): max_inflight_bounds_concurrent_reads, keepalive_reads_a_table_page_when_idle_and_stops_after_the_window, a_failing_keepalive_turns_itself_off_not_the_reader, latency_ring_is_bounded .... +//! Tests of tests by topic (moved out of the test file by STRA-338): max_inflight_bounds_concurrent_reads, +//! keepalive_reads_a_table_page_when_idle_and_stops_after_the_window, +//! a_failing_keepalive_turns_itself_off_not_the_reader, latency_ring_is_bounded .... #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/ple_reader/tests/prefetched_keys_are_matched.rs b/crates/model-format/src/ple_reader/tests/prefetched_keys_are_matched.rs index 41127f5f..46a802ea 100644 --- a/crates/model-format/src/ple_reader/tests/prefetched_keys_are_matched.rs +++ b/crates/model-format/src/ple_reader/tests/prefetched_keys_are_matched.rs @@ -1,12 +1,20 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): prefetched_keys_are_matched_by_row_never_by_position, after_a_failed_read_every_ticket_and_every_later_issue_returns_the_error_and_never_blocks, a_dropped_ticket_and_a_failed_read_together_do_not_wedge_the_reader, a_source_that_panics_is_a_failed_read_not_a_hang. +//! Tests of tests by topic (moved out of the test file by STRA-338): +//! prefetched_keys_are_matched_by_row_never_by_position, +//! after_a_failed_read_every_ticket_and_every_later_issue_returns_the_error_and_never_blocks, +//! a_dropped_ticket_and_a_failed_read_together_do_not_wedge_the_reader, +//! a_source_that_panics_is_a_failed_read_not_a_hang. #[allow(unused_imports)] use super::*; -/// Upstream 41cf05a0 `36381540` (`ngram/ple_reader_test.cpp` `prefetched_keys_are_reused`, issue #2622): `gather_batch` matched -/// the prefetched tokens by position, so a prefetch of A..F gathered as D,E,F,A,B,C (or A gathered as A,A,A) read rows that were -/// already in flight a second time. Here a ticket owns its rows and the row cache is keyed by row, so there is no position to -/// match; this pins that: every output slot holds the bytes of ITS row whatever the order, duplication or overlap of the tickets +/// Upstream 41cf05a0 `36381540` (`ngram/ple_reader_test.cpp` `prefetched_keys_are_reused`, issue #2622): `gather_batch` +/// matched +/// the prefetched tokens by position, so a prefetch of A..F gathered as D,E,F,A,B,C (or A gathered as A,A,A) read rows +/// that were +/// already in flight a second time. Here a ticket owns its rows and the row cache is keyed by row, so there is no +/// position to +/// match; this pins that: every output slot holds the bytes of ITS row whatever the order, duplication or overlap of +/// the tickets /// in flight, and a row already fetched is not read again. #[test] fn prefetched_keys_are_matched_by_row_never_by_position() { @@ -60,7 +68,8 @@ fn prefetched_keys_are_matched_by_row_never_by_position() { let tag = format!("{} (cache {cache_rows}, io {io_threads:?})", case.name); let src = Mem::new(table(100, 2000 * 90, 90)); let reader = PleReader::open(src.clone(), c.clone()).unwrap(); - // everything below is in flight at once; the wanted ticket is issued last, collected first, the others in + // everything below is in flight at once; the wanted ticket is issued last, collected first, the others + // in // reverse order of issue let tickets: Vec<_> = case.pre.iter().map(|&r| reader.issue(&[r])).collect(); let wanted = reader.issue(&case.want); @@ -158,7 +167,8 @@ fn a_source_that_panics_is_a_failed_read_not_a_hang() { let r = Arc::clone(&reader); let first = within("collect after a panicking read", move || r.read_rows(&[row_on_page(10)])); assert!(first.is_err(), "{threads:?}"); - // the worker that met the panic is still there (or the reads run inline): later tickets fail promptly, they do not wait + // the worker that met the panic is still there (or the reads run inline): later tickets fail promptly, they do + // not wait let r = Arc::clone(&reader); assert!(within("later ticket", move || r.read_rows(&[row_on_page(2)])).is_err(), "{threads:?}"); } diff --git a/crates/model-format/src/ple_reader/tests/rows_match_the_oracle_including.rs b/crates/model-format/src/ple_reader/tests/rows_match_the_oracle_including.rs index dd8fd2dd..d4a39a60 100644 --- a/crates/model-format/src/ple_reader/tests/rows_match_the_oracle_including.rs +++ b/crates/model-format/src/ple_reader/tests/rows_match_the_oracle_including.rs @@ -1,4 +1,6 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): rows_match_the_oracle_including_out_of_range, rows_on_one_page_share_one_read_and_straddlers_read_two_pages, a_later_straddler_widens_the_read_of_its_first_page, plan_is_sorted_by_offset_and_covers_every_missing_row_once .... +//! Tests of tests by topic (moved out of the test file by STRA-338): rows_match_the_oracle_including_out_of_range, +//! rows_on_one_page_share_one_read_and_straddlers_read_two_pages, a_later_straddler_widens_the_read_of_its_first_page, +//! plan_is_sorted_by_offset_and_covers_every_missing_row_once .... #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/qwen4exp/expected_inventory.rs b/crates/model-format/src/qwen4exp/expected_inventory.rs index b052dcba..e3ac8cd0 100644 --- a/crates/model-format/src/qwen4exp/expected_inventory.rs +++ b/crates/model-format/src/qwen4exp/expected_inventory.rs @@ -3,7 +3,8 @@ #[allow(unused_imports)] use super::*; -/// (role, name suffix, dimensions, GGUF kind pinned for it if any) of a tensor of every layer or of one family of layers. +/// (role, name suffix, dimensions, GGUF kind pinned for it if any) of a tensor of every layer or of one family of +/// layers. type LayerEntry = (LayerRole, &'static str, &'static [u64], Option); const GLOBAL_TENSORS: [(GlobalRole, &str, &[u64], Option); 5] = [ diff --git a/crates/model-format/src/qwen4exp/impl_fmt_display_for.rs b/crates/model-format/src/qwen4exp/impl_fmt_display_for.rs index 23a1399a..6396ae91 100644 --- a/crates/model-format/src/qwen4exp/impl_fmt_display_for.rs +++ b/crates/model-format/src/qwen4exp/impl_fmt_display_for.rs @@ -1,4 +1,5 @@ -//! Moved out of the parent module by STRA-338: impl fmt_Display_for, impl Error_for_BindingError, impl Qwen4ExpTopology, impl ResolvedTensor. +//! Moved out of the parent module by STRA-338: impl fmt_Display_for, impl Error_for_BindingError, impl +//! Qwen4ExpTopology, impl ResolvedTensor. #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/qwen4exp/validate_owner_index_split.rs b/crates/model-format/src/qwen4exp/validate_owner_index_split.rs index 1267801b..718030a8 100644 --- a/crates/model-format/src/qwen4exp/validate_owner_index_split.rs +++ b/crates/model-format/src/qwen4exp/validate_owner_index_split.rs @@ -1,4 +1,5 @@ -//! Moved out of the parent module by STRA-338: fn validate_owner_index_split, fn validate_owner_metadata_split, fn required_uint, fn required_u32, fn required_float, fn required_array .... +//! Moved out of the parent module by STRA-338: fn validate_owner_index_split, fn validate_owner_metadata_split, fn +//! required_uint, fn required_u32, fn required_float, fn required_array .... #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/qwen4exp_digest_capture/impl_qwen4expartifact.rs b/crates/model-format/src/qwen4exp_digest_capture/impl_qwen4expartifact.rs index 398f8e9d..84b933a2 100644 --- a/crates/model-format/src/qwen4exp_digest_capture/impl_qwen4expartifact.rs +++ b/crates/model-format/src/qwen4exp_digest_capture/impl_qwen4expartifact.rs @@ -1,4 +1,5 @@ -//! Moved out of the parent module by STRA-338: impl Qwen4ExpArtifact, impl ProvisionalExpertSource, impl IncrementalCapture. +//! Moved out of the parent module by STRA-338: impl Qwen4ExpArtifact, impl ProvisionalExpertSource, impl +//! IncrementalCapture. #[allow(unused_imports)] use super::*; @@ -204,7 +205,8 @@ impl IncrementalCapture { } } -/// The part of a chunk that falls inside one cell: where it goes in the cell, how long it is, where it starts in the chunk. +/// The part of a chunk that falls inside one cell: where it goes in the cell, how long it is, where it starts in the +/// chunk. struct ChunkSpan { offset: usize, count: usize, diff --git a/crates/model-format/src/qwen4exp_expert_source_bank/impl_qwen4expartifact.rs b/crates/model-format/src/qwen4exp_expert_source_bank/impl_qwen4expartifact.rs index dab52a4d..aaa5f274 100644 --- a/crates/model-format/src/qwen4exp_expert_source_bank/impl_qwen4expartifact.rs +++ b/crates/model-format/src/qwen4exp_expert_source_bank/impl_qwen4expartifact.rs @@ -1,4 +1,5 @@ -//! Moved out of the parent module by STRA-338: impl Qwen4ExpArtifact, impl ResidentExpertBankLease, impl ResidentExpertBankMember. +//! Moved out of the parent module by STRA-338: impl Qwen4ExpArtifact, impl ResidentExpertBankLease, impl +//! ResidentExpertBankMember. #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/qwen4exp_expert_source_bank/impl_qwen4expartifact_2.rs b/crates/model-format/src/qwen4exp_expert_source_bank/impl_qwen4expartifact_2.rs index 73116299..c4a40b37 100644 --- a/crates/model-format/src/qwen4exp_expert_source_bank/impl_qwen4expartifact_2.rs +++ b/crates/model-format/src/qwen4exp_expert_source_bank/impl_qwen4expartifact_2.rs @@ -1,4 +1,5 @@ -//! Moved out of the parent module by STRA-338: impl Qwen4ExpArtifact, impl ResidentExpertBankSpan, impl ResidentExpertBank. +//! Moved out of the parent module by STRA-338: impl Qwen4ExpArtifact, impl ResidentExpertBankSpan, impl +//! ResidentExpertBank. #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/qwen4exp_expert_source_bank/retention_metadata_bytes.rs b/crates/model-format/src/qwen4exp_expert_source_bank/retention_metadata_bytes.rs index 60d1d614..6123e765 100644 --- a/crates/model-format/src/qwen4exp_expert_source_bank/retention_metadata_bytes.rs +++ b/crates/model-format/src/qwen4exp_expert_source_bank/retention_metadata_bytes.rs @@ -1,4 +1,5 @@ -//! Moved out of the parent module by STRA-338: fn retention_metadata_bytes, impl fmt_Display_for, impl Error_for_ResidentExpertSourceError, fn checked_descriptor, fn slot, fn memory_available .... +//! Moved out of the parent module by STRA-338: fn retention_metadata_bytes, impl fmt_Display_for, impl +//! Error_for_ResidentExpertSourceError, fn checked_descriptor, fn slot, fn memory_available .... #[allow(unused_imports)] use super::*; diff --git a/crates/model-format/src/readahead.rs b/crates/model-format/src/readahead.rs index b58313dd..6be80f28 100644 --- a/crates/model-format/src/readahead.rs +++ b/crates/model-format/src/readahead.rs @@ -87,7 +87,8 @@ fn advise_sequential(file: &File) { #[cfg(not(target_os = "linux"))] fn advise_sequential(_file: &File) {} -/// How far ahead of the reader the kernel is asked to fetch (`POSIX_FADV_WILLNEED`). A cold NVMe that serves one 128 KiB +/// How far ahead of the reader the kernel is asked to fetch (`POSIX_FADV_WILLNEED`). A cold NVMe that serves one 128 +/// KiB /// window at a time reads at tens of MB/s; a few hundred MB of asynchronous readahead keeps its queue full while the /// hash runs. #[cfg(target_os = "linux")] @@ -103,9 +104,12 @@ fn advise_willneed(file: &File, offset: u64, len: u64) { #[cfg(not(target_os = "linux"))] fn advise_willneed(_file: &File, _offset: u64, _len: u64) {} -/// Drop the clean page-cache pages of a span that has been read and handed on (`POSIX_FADV_DONTNEED`, never `drop_caches`; -/// best effort, a no-op for a memfd). A hash pass reads each byte once: without this the 55 GB archive and the 84 GB of shards -/// would sit in the page cache after the pass as a second copy of what the process keeps (or does not need) in its own memory. +/// Drop the clean page-cache pages of a span that has been read and handed on (`POSIX_FADV_DONTNEED`, never +/// `drop_caches`; +/// best effort, a no-op for a memfd). A hash pass reads each byte once: without this the 55 GB archive and the 84 GB of +/// shards +/// would sit in the page cache after the pass as a second copy of what the process keeps (or does not need) in its own +/// memory. #[cfg(target_os = "linux")] fn evict_span(file: &File, offset: u64, len: u64) { if let Some(len) = std::num::NonZeroU64::new(len) {