Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them.
Page: /drakestapleton/synapse/patches/89e91c8a30c12fa4
# synapse
A component of the AienOS ecosystem.
Brought by drakestapleton
Sign in to star 0 stars 0 watching
About Files History Releases Proposed changes Issues For developers
## GitHub aien-dev/synapse#110 (code only)
closed derived `89e91c8a30c12fa4` #110
Imported from GitHub aien-dev/synapse#110 (code only)
GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).
Base `3d78efe83d5d08b67848e4b32a83112a95dd2a9d` · Head `b1cc199a63744efb6919ba0873b98e32cddb87a8`
### Fetch it
A git bundle of the pull request's head, 921152 bytes.
```
curl -fsSL https://interplane.io/drakestapleton/synapse/patches/89e91c8a30c12fa4.bundle -o 89e91c8a30c12fa4.bundle
git fetch 89e91c8a30c12fa4.bundle refs/pull/110/head
```
Raw bundle · Diff
### Provenance
This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:
```
github-import 1
aien-dev/synapse
110
b1cc199a63744efb6919ba0873b98e32cddb87a8
```
```
{"kind":"github-import","owner":"aien-dev","repo":"synapse","number":110,"url":"https://github.com/aien-dev/synapse/pull/110","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:39:11Z","metadata":"unavailable","state_derived":true}
```
### Changes
```
diff --git a/.crumb b/.crumb
index 495a32d..4dc63ee 100644
--- a/.crumb
+++ b/.crumb
@@ -45,14 +45,14 @@
"generated": {
"children": [],
"children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- "compiled_at": "2026-10-16T09:12:08Z",
+ "compiled_at": "2026-10-18T13:19:15Z",
"compiler": "crumb-compile/1",
- "digest": "sha256:279410a8da95ac0a5c9e9cf32a56684e2ca85469ad52267efcce5e6dbbbef821",
- "evidence_files": 241,
- "evidence_root": "sha256:f103bd6c7728e5a399cede51d9c64e4d42afc97e0d48dd424536b6cc72e48314",
- "files": 411,
- "generated_at_commit": "5d287e0e4ab4439f79711243518c0a83cce56eff",
- "source_tree": "sha256:07947598e29d8d8fca9b546541ebe7e575c954cf18901eeb74304d2a9f594e2b"
+ "digest": "sha256:3118b072efa85d38cb4d52b39439b4d9066145ed23d85f086febf7e9889f6e29",
+ "evidence_files": 310,
+ "evidence_root": "sha256:eb1b3ff3aa1aaf9ab8b5fec5a63280c848d478c4404a2fae36a72bc007b8dc54",
+ "files": 490,
+ "generated_at_commit": "765521b5178d36e2585373377006f851305bb81f",
+ "source_tree": "sha256:b37c19f97908dd5d2aeef260030ec860eb063bb1427599e76cc51163baab979a"
},
"synapse": {
"component_paths": {
diff --git a/Cargo.lock b/Cargo.lock
index 8fb6001..89ab25e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -495,6 +495,7 @@ version = "0.1.0"
dependencies = [
"ed25519-dalek",
"hex",
+ "libc",
"serde",
"serde_json",
"sha2",
diff --git a/crates/synapse-bench/src/main.rs b/crates/synapse-bench/src/main.rs
index d14e90a..8634339 100644
--- a/crates/synapse-bench/src/main.rs
+++ b/crates/synapse-bench/src/main.rs
@@ -17,6 +17,7 @@
//! synapse-bench pmu-verify --evidence
//! synapse-bench segments --dir --out [--agents 1,4,8,32]
//! [--changes N] [--reps N] [--blob-bytes N] [--segment-mib N] [--checkpoint-every N] [--idle-window-s S]
+//! [--block-device [--block-device-mib N] [--block-meta-mib N]]
//! synapse-bench segments-report --raw --floor (prints the A2 report)
//! ```
@@ -477,6 +478,9 @@ fn segments(args: &[String]) -> Result<(), String> {
"--segment-mib",
"--checkpoint-every",
"--idle-window-s",
+ "--block-device",
+ "--block-device-mib",
+ "--block-meta-mib",
],
)?;
let get = |k: &str| {
@@ -498,6 +502,15 @@ fn segments(args: &[String]) -> Result<(), String> {
segment_bytes: num("--segment-mib", 16)? * 1024 * 1024,
checkpoint_every: num("--checkpoint-every", 1000)? as usize,
idle_window_s: num("--idle-window-s", 30)?,
+ block_device: get("--block-device"),
+ block_device_bytes: num(
+ "--block-device-mib",
+ synapse_bench::segments::DEFAULT_BLOCK_DEVICE_BYTES >> 20,
+ )? << 20,
+ block_meta_bytes: num(
+ "--block-meta-mib",
+ synapse_bench::segments::DEFAULT_BLOCK_META_BYTES >> 20,
+ )? << 20,
};
let dir = PathBuf::from(get("--dir").ok_or("missing --dir")?);
let out = PathBuf::from(get("--out").ok_or("missing --out")?);
@@ -505,6 +518,44 @@ fn segments(args: &[String]) -> Result<(), String> {
synapse_bench::write_json(&out, &raw)
}
+/// R1 store repair (issue #105). Without `--drop-acknowledged-range` it only reports and
+/// never writes. With it, `--backup ` is required: the damaged superblocks and
+/// the bytes about to be zeroed are saved there first.
+fn store_repair(args: &[String]) -> Result<(), String> {
+ use synapse_store::blockdev::repair::{diagnose, repair_dropping_acknowledged_range};
+ use synapse_store::blockdev::DirectFile;
+ let drop_flag = args.iter().any(|a| a == "--drop-acknowledged-range");
+ let rest: Vec = args
+ .iter()
+ .filter(|a| *a != "--drop-acknowledged-range")
+ .cloned()
+ .collect();
+ let opts = parse_pairs(&rest, &["--device", "--backup"])?;
+ let get = |k: &str| {
+ opts.iter()
+ .rev()
+ .find(|(key, _)| key == k)
+ .map(|(_, v)| PathBuf::from(v))
+ };
+ let device = get("--device").ok_or("missing --device (absolute path)")?;
+ if !drop_flag {
+ let io = DirectFile::open_read_only(&device).map_err(|e| e.to_string())?;
+ print!("{}", diagnose(&io).map_err(|e| e.to_string())?);
+ return Ok(());
+ }
+ let backup = get("--backup").ok_or("--drop-acknowledged-range needs --backup ")?;
+ let io = DirectFile::open(&device).map_err(|e| e.to_string())?;
+ let report =
+ repair_dropping_acknowledged_range(&io, &backup, true).map_err(|e| e.to_string())?;
+ print!("{report}");
+ if report.verdict == synapse_store::blockdev::repair::Verdict::OlderCheckpointLosesRange {
+ println!("repair applied; backup at {}", backup.display());
+ } else {
+ println!("nothing was written");
+ }
+ Ok(())
+}
+
/// `segments-report`: recompute the A2 report from `--raw` and a `--floor` report.
fn segments_report(args: &[String]) -> Result<(), String> {
use std::io::Write;
@@ -541,6 +592,7 @@ fn main() -> ExitCode {
Some("crypto-vectors-verify") => crypto_vectors_verify(&args[1..]),
Some("segments") => segments(&args[1..]),
Some("segments-report") => segments_report(&args[1..]),
+ Some("store-repair") => store_repair(&args[1..]),
_ => Err("usage: synapse-bench run ... | synapse-bench child ... (see crate docs)".into()),
};
match outcome {
diff --git a/crates/synapse-bench/src/segments.rs b/crates/synapse-bench/src/segments.rs
index 14144cc..5ea2305 100644
--- a/crates/synapse-bench/src/segments.rs
+++ b/crates/synapse-bench/src/segments.rs
@@ -36,7 +36,12 @@ use synapse_core::{
BlobDigest, ChangesetEnvelope, FileMode, GitOid, IdempotencyKey, MutationOp, PathMutation,
RepoId, SYNAPSE_ENVELOPE_VERSION,
};
-use synapse_store::{FsyncPolicy, IngestOutcome, RecoveryPolicy, SharedStore, StoreLimits};
+use synapse_core::{RefusalCode, SynapseError};
+use synapse_store::blockdev::BlockDevice;
+use synapse_store::{
+ BlockDeviceConfig, FormatPolicy, FsyncPolicy, IngestOutcome, RecoveryPolicy, SharedStore,
+ StoreLimits,
+};
/// Memory bandwidth, bytes per second: NVIDIA DGX Spark specification, 273 GB/s (A0).
pub const MEMORY_BW_BPS: f64 = 273e9;
@@ -57,6 +62,18 @@ pub struct SegmentsConfig {
pub segment_bytes: u64,
pub checkpoint_every: usize,
pub idle_window_s: u64,
+ /// R1 (issue #47): run every cell on a raw block store device at this absolute path
+ /// instead of a store directory. The path must not exist: for each cell the bench
+ /// creates a regular file there (preallocated, `block_device_bytes`), formats it,
+ /// and removes it afterwards. It never writes to a file it did not create.
+ #[serde(default)]
+ pub block_device: Option,
+ /// Size of that device file.
+ #[serde(default = "default_block_device_bytes")]
+ pub block_device_bytes: u64,
+ /// Metadata region size of that device.
+ #[serde(default = "default_block_meta_bytes")]
+ pub block_meta_bytes: u64,
}
/// One measured cell (raw samples).
@@ -248,6 +265,87 @@ fn count_files(dir: &Path, pred: &dyn Fn(&str) -> bool) -> usize {
.sum()
}
+/// Default size of the device file the bench creates for each R1 cell.
+pub const DEFAULT_BLOCK_DEVICE_BYTES: u64 = 512 << 20;
+/// Default metadata region size of that device.
+pub const DEFAULT_BLOCK_META_BYTES: u64 = 64 << 20;
+
+fn default_block_device_bytes() -> u64 {
+ DEFAULT_BLOCK_DEVICE_BYTES
+}
+
+fn default_block_meta_bytes() -> u64 {
+ DEFAULT_BLOCK_META_BYTES
+}
+
+/// The R1 device of one cell: a regular file the bench creates itself at the configured
+/// path, preallocated with zeros, and removes after the cell. The bench formats only
+/// a file it created: an existing path (a file, a symbolic link, anything) is refused
+/// before a byte is written, and it never opens a block device.
+struct BenchDevice {
+ path: PathBuf,
+ dev: u64,
+ ino: u64,
+}
+
+impl BenchDevice {
+ fn create(path: &str, bytes: u64) -> Result {
+ use std::os::unix::fs::{FileExt, MetadataExt, OpenOptionsExt};
+ let p = PathBuf::from(path);
+ if !p.is_absolute() {
+ return Err(format!("--block-device {path}: must be an absolute path"));
+ }
+ if bytes == 0 || !bytes.is_multiple_of(4096) {
+ return Err(format!(
+ "block device size {bytes} is not a positive multiple of 4096"
+ ));
+ }
+ // create_new (O_CREAT | O_EXCL) fails on any existing path, a dangling symbolic
+ // link included; O_NOFOLLOW as well.
+ let f = std::fs::OpenOptions::new()
+ .write(true)
+ .create_new(true)
+ .custom_flags(libc::O_NOFOLLOW)
+ .open(&p)
+ .map_err(|e| match e.kind() {
+ std::io::ErrorKind::AlreadyExists => format!(
+ "--block-device {path}: refusing, it already exists; the bench formats \
+ only a device file it creates itself (name a path that does not exist)"
+ ),
+ _ => format!("create {path}: {e}"),
+ })?;
+ let m = f.metadata().map_err(|e| format!("stat {path}: {e}"))?;
+ let device = Self {
+ path: p,
+ dev: m.dev(),
+ ino: m.ino(),
+ };
+ // Preallocate: every block written once (no sparse holes), then synced.
+ let zeros = vec![0u8; 1 << 20];
+ let mut at = 0u64;
+ while at < bytes {
+ let n = (bytes - at).min(zeros.len() as u64) as usize;
+ f.write_all_at(&zeros[..n], at)
+ .map_err(|e| format!("preallocate {path}: {e}"))?;
+ at += n as u64;
+ }
+ f.sync_all().map_err(|e| format!("sync {path}: {e}"))?;
+ Ok(device)
+ }
+}
+
+impl Drop for BenchDevice {
+ /// Remove the device file, only if the path still is the file this bench created.
+ fn drop(&mut self) {
+ use std::os::unix::fs::MetadataExt;
+ if let Ok(m) = std::fs::symlink_metadata(&self.path) {
+ if m.file_type().is_file() && m.dev() == self.dev && m.ino() == self.ino {
+ let _ = std::fs::remove_file(&self.path);
+ }
+ }
+ }
+}
+
fn run_cell(
dir: &Path,
cfg: &SegmentsConfig,
@@ -260,12 +358,30 @@ fn run_cell(
segment_bytes: cfg.segment_bytes,
..Default::default()
};
- let shared = SharedStore::open(
- dir,
- FsyncPolicy::GROUP_COMMIT_DEFAULT,
- RecoveryPolicy::StrictFailClosed,
- limits,
- )
+ let device = match cfg.block_device.as_deref() {
+ Some(p) => Some(BenchDevice::create(p, cfg.block_device_bytes)?),
+ None => None,
+ };
+ let block = device.as_ref().map(|d| BlockDeviceConfig {
+ path: d.path.clone(),
+ format: FormatPolicy::FormatIfBlank,
+ meta_region_bytes: cfg.block_meta_bytes,
+ allow_foreign_signature: false,
+ });
+ let shared = match &block {
+ Some(bc) => SharedStore::open_block_device(
+ bc,
+ FsyncPolicy::GROUP_COMMIT_DEFAULT,
+ RecoveryPolicy::StrictFailClosed,
+ limits,
+ ),
+ None => SharedStore::open(
+ dir,
+ FsyncPolicy::GROUP_COMMIT_DEFAULT,
+ RecoveryPolicy::StrictFailClosed,
+ limits,
+ ),
+ }
.map_err(|e| format!("open store: {e:?}"))?;
// Prepare every agent's changesets before timing (signing is the agent's own work).
let per_agent = cfg.changes.div_ceil(agents);
@@ -348,9 +464,24 @@ fn run_cell(
}
let batches = shared.stats().batches - batches_before;
drop(shared);
- let segment_files = count_files(dir, &|n| {
- synapse_store::segment::parse_segment_file_name(n).is_some()
- });
+ let segment_files = match &block {
+ Some(bc) => {
+ let cfg = BlockDeviceConfig {
+ format: FormatPolicy::OpenExisting,
+ ..bc.clone()
+ };
+ BlockDevice::open_path(&cfg, 0)
+ .and_then(|d| {
+ d.list_segments()
+ .map_err(|e| SynapseError::new(RefusalCode::IoFailure, e.to_string()))
+ })
+ .map_err(|e| format!("reopen device: {e:?}"))?
+ .len()
+ }
+ None => count_files(dir, &|n| {
+ synapse_store::segment::parse_segment_file_name(n).is_some()
+ }),
+ };
let blob_files = count_files(&dir.join("blobs"), &|_| true);
Ok(CellRaw {
agents,
@@ -438,6 +569,72 @@ mod tests {
}
}
+ /// B1 (review of PR #103): `--block-device` never writes to a file the bench did not
+ /// create itself, and never follows a symbolic link to one.
+ #[test]
+ fn block_device_bench_never_writes_to_a_file_it_did_not_create() {
+ let dir = crate::fixture::test_support::temp_dir("r1-bench-victim");
+ let victim = dir.join("victim.img");
+ let mut bytes: Vec = (0..4u32 << 20).map(|i| (i % 251) as u8).collect();
+ bytes[1080..1082].copy_from_slice(&[0x53, 0xEF]);
+ std::fs::write(&victim, &bytes).unwrap();
+ let link = dir.join("link.img");
+ std::os::unix::fs::symlink(&victim, &link).unwrap();
+ for target in [&victim, &link] {
+ let cfg = SegmentsConfig {
+ agents: vec![1],
+ changes: 4,
+ reps: 1,
+ blob_bytes: 64,
+ segment_bytes: 1 << 20,
+ checkpoint_every: 2,
+ idle_window_s: 0,
+ block_device: Some(target.display().to_string()),
+ block_device_bytes: 8 << 20,
+ block_meta_bytes: 1 << 20,
+ };
+ assert!(
+ run_cell(&dir.join("store"), &cfg, 1, 0).is_err(),
+ "{}",
+ target.display()
+ );
+ assert_eq!(
+ std::fs::read(&victim).unwrap(),
+ bytes,
+ "{}: victim changed",
+ target.display()
+ );
+ }
+ let _ = std::fs::remove_dir_all(&dir);
+ }
+
+ /// The bench creates its own device file for a cell, formats it, and removes it.
+ #[test]
+ fn block_device_bench_creates_formats_and_removes_its_own_device() {
+ let dir = crate::fixture::test_support::temp_dir("r1-bench-own");
+ let path = dir.join("device.img");
+ let cfg = SegmentsConfig {
+ agents: vec![2],
+ changes: 6,
+ reps: 1,
+ blob_bytes: 64,
+ segment_bytes: 1 << 20,
+ checkpoint_every: 3,
+ idle_window_s: 0,
+ block_device: Some(path.display().to_string()),
+ block_device_bytes: 8 << 20,
+ block_meta_bytes: 1 << 20,
+ };
+ let cell = run_cell(&dir.join("store"), &cfg, 2, 0).unwrap();
+ assert_eq!(cell.accepted, 6);
+ assert_eq!(cell.segment_files, 1);
+ assert!(
+ !path.exists(),
+ "the bench removes the device file it created"
+ );
+ let _ = std::fs::remove_dir_all(&dir);
+ }
+
#[test]
fn interval_bound_is_flush_shared_by_agents_until_crypto_dominates() {
let b = inputs();
diff --git a/crates/synapse-store/Cargo.toml b/crates/synapse-store/Cargo.toml
index 34588f6..bcf21a9 100644
--- a/crates/synapse-store/Cargo.toml
+++ b/crates/synapse-store/Cargo.toml
@@ -10,6 +10,7 @@ description = "Durable single-writer WAL, content-addressed blob store, checkpoi
[dependencies]
ed25519-dalek.workspace = true
hex.workspace = true
+libc.workspace = true
serde.workspace = true
serde_json.workspace = true
sha2.workspace = true
diff --git a/crates/synapse-store/src/blockdev.rs b/crates/synapse-store/src/blockdev.rs
new file mode 100644
index 0000000..c1281a8
--- /dev/null
+++ b/crates/synapse-store/src/blockdev.rs
@@ -0,0 +1,1312 @@
+//! R1 raw block segment store (ADR 0003 section 9 step 27): the A2 segment store on a
+//! block device with no filesystem. The specification is `docs/R1_RAW_BLOCK_STORE.md`.
+//!
+//! The device is one byte range opened with `O_DIRECT` (page cache bypassed). On Linux
+//! that is a dedicated partition; tests and benchmarks use a preallocated regular file at
+//! a path the caller names. Nothing else is ever opened: no `/dev` scan, no globbing, no
+//! derived paths. The opened device is held under an exclusive lock (`flock`, plus
+//! `O_EXCL` for a block device). A device that carries a recognisable filesystem,
+//! partition, or volume signature anywhere it is looked for ([`SIGNATURES`], including
+//! the backup GPT header, MD RAID and ZFS labels near the end), or any other non-zero
+//! byte in its label area, is refused unless the caller sets
+//! [`BlockDeviceConfig::allow_foreign_signature`]. Formatting is never the default.
+//!
+//! On-device layout (little-endian, 4 KiB blocks):
+//!
+//! * `0..128 KiB` label area. Superblock copy 0 at byte 0, copy 1 at byte 4096; the rest
+//! is zero. Generation `g` is written to copy `g % 2`, so the newest valid copy and
+//! the one before it are always on the device.
+//! * Two metadata regions of `meta_region_bytes` each (region 0 at 1 MiB). A metadata
+//! region holds the named objects the A2 store keeps as small files (`wal.log`,
+//! `checkpoint.v1`, `checkpoint.v2`, `wal.v2.index.*`): `"SBM1" | u32 count |
+//! count x (u16 name_len | name | u64 len | bytes)`, names strictly increasing.
+//! * Segment slots from `data_offset` (1 MiB aligned): slot `k >= 1` is a 4 KiB segment
+//! header (`"SBSG" | u32 version | uuid[16] | u64 segment id | u64 segment_bytes |
+//! u32 crc32c`) followed by `segment_bytes` of segment data in the WAL v2 batch format
+//! ([`crate::wal2`]), unchanged from A2.
+//!
+//! Superblock (first 164 bytes of its 4 KiB block, rest zero): `"SYNBLKS1" | u32 version
+//! | u32 block | uuid[16] | u64 generation | u64 device_bytes | u64 meta_offset0 | u64
+//! meta_offset1 | u64 meta_region_bytes | u64 data_offset | u64 slot_stride | u64
+//! segment_bytes | u64 slot_count | u64 segment_count | u64 meta_len | u8 meta_slot |
+//! 7 zero bytes | meta_sha256[32] | u32 crc32c(preceding 160 bytes)`, where `meta_sha256
+//! = SHA-256("SYNAPSE_BLOCK_META_V1\0" || meta bytes)`.
+//!
+//! Durability (one `fdatasync` of the device per step; on a block device that is a
+//! FLUSH of the drive's volatile cache):
+//!
+//! * Metadata commit (the A2 "temp file, sync, rename, directory sync"): write the whole
+//! new namespace into the region no valid superblock copy points at, write superblock
+//! generation `g + 1` into copy `(g + 1) % 2`, `fdatasync`. Recovery takes the newest
+//! copy whose CRC holds and whose region matches its digest, else the older copy,
+//! whose region was not touched. One flush suffices because a superblock without its
+//! region is detected and skipped.
+//! * Segment rotation (the A2 "create, sync, directory flush"): zero the whole data area,
+//! `fdatasync`; write the slot header, `fdatasync`; then a superblock-only commit
+//! raises `segment_count`, `fdatasync`. Only then does a batch go into the slot. A slot
+//! past `segment_count` is never data: without a valid header its bytes are ignored
+//! (they may be stale from earlier use of the device) and the next rotation zeroes it.
+//! A valid header always sits on a zeroed slot, so slot `segment_count + 1` with a valid
+//! header and any non-zero byte means its commit was flushed and the superblock copy
+//! in use is older than the newest: mount refuses it (`CheckpointCorrupt`) rather than
+//! drop the changes acknowledged there.
+//! * Batch: one aligned positioned write plus one `fdatasync` (unchanged from A2).
+
+use super::*;
+
+pub mod repair;
+
+use std::os::unix::fs::{FileExt, FileTypeExt, MetadataExt, OpenOptionsExt};
+use std::sync::{Arc, Mutex};
+
+/// I/O block size: offsets, lengths and buffers of `O_DIRECT` transfers are multiples of it.
+pub const BLOCK: u64 = 4096;
+/// Superblock magic.
+pub const SUPERBLOCK_MAGIC: [u8; 8] = *b"SYNBLKS1";
+/// Superblock format version.
+pub const SUPERBLOCK_VERSION: u32 = 1;
+/// Label area at the start of the device: superblocks plus zeros. It covers the
+/// start-of-device offsets of the common signatures; [`classify_device`] also checks the
+/// ones further in and near the end of the device.
+pub const LABEL_BYTES: u64 = 128 * 1024;
+/// Segment header magic.
+pub const SEGMENT_HEADER_MAGIC: [u8; 4] = *b"SBSG";
+/// Metadata region magic.
+pub const META_MAGIC: [u8; 4] = *b"SBM1";
+/// Domain tag of the metadata digest.
+pub const DOMAIN_BLOCK_META: &[u8] = b"SYNAPSE_BLOCK_META_V1\0";
+/// Default size of each of the two metadata regions.
+pub const DEFAULT_META_REGION_BYTES: u64 = 64 << 20;
+/// Byte offset of metadata region 0.
+const META_START: u64 = 1 << 20;
+/// Bytes zeroed per write when a segment slot is cleared.
+const ZERO_CHUNK: usize = 1 << 20;
+const SB_LEN: usize = 164;
+
+const fn align_up(x: u64, a: u64) -> u64 {
+ x.div_ceil(a) * a
+}
+
+fn refuse(msg: impl Into) -> SynapseError {
+ SynapseError::new(RefusalCode::IoFailure, msg.into())
+}
+
+fn corrupt(msg: impl Into) -> SynapseError {
+ SynapseError::new(RefusalCode::CheckpointCorrupt, msg.into())
+}
+
+// --- device I/O ----------------------------------------------------------------
+
+/// Byte-addressed device I/O. Implementations may require nothing of the caller's
+/// alignment; [`DirectFile`] turns every call into aligned `O_DIRECT` transfers.
+pub trait BlockIo: Send + Sync + std::fmt::Debug {
+ /// Device length in bytes.
+ fn len(&self) -> u64;
+ /// True when the device has no bytes.
+ fn is_empty(&self) -> bool {
+ self.len() == 0
+ }
+ /// Read exactly `buf.len()` bytes at `off`.
+ fn read_at(&self, buf: &mut [u8], off: u64) -> std::io::Result<()>;
+ /// Write all of `data` at `off`. Not durable until [`BlockIo::flush`] returns.
+ fn write_at(&self, data: &[u8], off: u64) -> std::io::Result<()>;
+ /// Make every completed write durable (`fdatasync`).
+ fn flush(&self) -> std::io::Result<()>;
+}
+
+/// A heap buffer whose usable part starts at a [`BLOCK`]-aligned address (safe Rust:
+/// the start is found with `align_offset` inside an over-allocated `Vec`).
+struct AlignedBuf {
+ raw: Vec,
+ start: usize,
+ len: usize,
+}
+
+impl AlignedBuf {
+ fn zeroed(len: usize) -> Self {
+ let raw = vec![0u8; len + BLOCK as usize];
+ let start = raw.as_ptr().align_offset(BLOCK as usize);
+ assert!(start <= BLOCK as usize, "alignment offset out of range");
+ Self { raw, start, len }
+ }
+ fn as_slice(&self) -> &[u8] {
+ &self.raw[self.start..self.start + self.len]
+ }
+ fn as_mut_slice(&mut self) -> &mut [u8] {
+ &mut self.raw[self.start..self.start + self.len]
+ }
+}
+
+const O_DIRECT: i32 = libc::O_DIRECT;
+
+/// The device opened with `O_DIRECT`: a dedicated partition, or for tests and benchmarks a
+/// preallocated regular file. Unaligned requests are served through aligned bounce
+/// buffers (read-modify-write of the edge blocks for writes); the store's batch, zeroing,
+/// header and metadata writes are all block-aligned.
+#[derive(Debug)]
+pub struct DirectFile {
+ file: File,
+ len: u64,
+}
+
+impl DirectFile {
+ /// Open exactly `path` (absolute; a regular file or a block device, nothing else).
+ /// A block device is opened with `O_EXCL`, so the kernel refuses one that is mounted
+ /// or held by another opener. The opened file must be the one `path` named when it
+ /// was checked (same device and inode). The opened file is held under an exclusive
+ /// advisory lock (`flock`): a second opener is refused while this one lives.
+ pub fn open(path: &Path) -> SynapseResult {
+ Self::open_with(path, true, true)
+ }
+
+ /// Like [`Self::open`] but the file is opened read-only (still exclusive-locked):
+ /// every write through it fails. The diagnosis mode of the repair tool uses it.
+ pub fn open_read_only(path: &Path) -> SynapseResult {
+ Self::open_with(path, true, false)
+ }
+
+ /// Test inspection only: open without taking the lock (the A2 suite shim reads the
+ /// device while the store under test holds it).
+ #[cfg(test)]
+ pub(crate) fn open_unlocked(path: &Path) -> SynapseResult {
+ Self::open_with(path, false, true)
+ }
+
+ fn open_with(path: &Path, lock: bool, write: bool) -> SynapseResult {
+ if !path.is_absolute() {
+ return Err(refuse(format!(
+ "block device path must be absolute: {}",
+ path.display()
+ )));
+ }
+ // `symlink_metadata` plus `O_NOFOLLOW`: a symbolic link is refused, so the path
+ // opened is the configured one and never a link target.
+ let meta = fs::symlink_metadata(path)
+ .map_err(|e| refuse(format!("block device {}: {e}", path.display())))?;
+ let ft = meta.file_type();
+ let is_block = ft.is_block_device();
+ if !is_block && !ft.is_file() {
+ return Err(refuse(format!(
+ "{} is neither a block device nor a regular file (symbolic links are refused)",
+ path.display()
+ )));
+ }
+ let mut flags = O_DIRECT | libc::O_NOFOLLOW;
+ if is_block {
+ flags |= libc::O_EXCL;
+ }
+ let file = OpenOptions::new()
+ .read(true)
+ .write(write)
+ .custom_flags(flags)
+ .open(path)
+ .map_err(|e| refuse(format!("open {} with O_DIRECT: {e}", path.display())))?;
+ let opened = file.metadata().map_err(io_err)?;
+ if opened.dev() != meta.dev() || opened.ino() != meta.ino() || opened.rdev() != meta.rdev()
+ {
+ return Err(refuse(format!(
+ "{} changed between the check and the open",
+ path.display()
+ )));
+ }
+ // One opener at a time: an exclusive advisory lock (flock) on the opened file, on
+ // top of O_EXCL for block devices. A second store on the same device would
+ // overwrite the first one's slots and metadata.
+ match if lock { file.try_lock() } else { Ok(()) } {
+ Ok(()) => {}
+ Err(fs::TryLockError::WouldBlock) => {
+ return Err(refuse(format!(
+ "{} is in use: another opener holds its exclusive lock",
+ path.display()
+ )))
+ }
+ Err(fs::TryLockError::Error(e)) => {
+ return Err(refuse(format!("lock {}: {e}", path.display())))
+ }
+ }
+ let len = if is_block {
+ use std::io::Seek;
+ let mut f = &file;
+ f.seek(SeekFrom::End(0)).map_err(io_err)?
+ } else {
+ opened.len()
+ };
+ if len % BLOCK != 0 {
+ return Err(refuse(format!(
+ "{}: length {len} is not a multiple of {BLOCK}",
+ path.display()
+ )));
+ }
+ Ok(Self { file, len })
+ }
+}
+
+impl BlockIo for DirectFile {
+ fn len(&self) -> u64 {
+ self.len
+ }
+
+ fn read_at(&self, buf: &mut [u8], off: u64) -> std::io::Result<()> {
+ if buf.is_empty() {
+ return Ok(());
+ }
+ let end = off
+ .checked_add(buf.len() as u64)
+ .filter(|e| *e <= self.len)
+ .ok_or_else(|| std::io::Error::other("read past the end of the device"))?;
+ let a = off / BLOCK * BLOCK;
+ let b = align_up(end, BLOCK);
+ let mut bounce = AlignedBuf::zeroed((b - a) as usize);
+ self.file.read_exact_at(bounce.as_mut_slice(), a)?;
+ let at = (off - a) as usize;
+ buf.copy_from_slice(&bounce.as_slice()[at..at + buf.len()]);
+ Ok(())
+ }
+
+ fn write_at(&self, data: &[u8], off: u64) -> std::io::Result<()> {
+ if data.is_empty() {
+ return Ok(());
+ }
+ let end = off
+ .checked_add(data.len() as u64)
+ .filter(|e| *e <= self.len)
+ .ok_or_else(|| std::io::Error::other("write past the end of the device"))?;
+ let a = off / BLOCK * BLOCK;
+ let b = align_up(end, BLOCK);
+ let mut bounce = AlignedBuf::zeroed((b - a) as usize);
+ let s = bounce.as_mut_slice();
+ // Read-modify-write of partly covered edge blocks.
+ if off != a {
+ self.file.read_exact_at(&mut s[..BLOCK as usize], a)?;
+ }
+ if end != b && (b - BLOCK >= a + BLOCK || off == a) {
+ let last = s.len() - BLOCK as usize;
+ self.file.read_exact_at(&mut s[last..], b - BLOCK)?;
+ }
+ let at = (off - a) as usize;
+ s[at..at + data.len()].copy_from_slice(data);
+ self.file.write_all_at(bounce.as_slice(), a)
+ }
+
+ fn flush(&self) -> std::io::Result<()> {
+ self.file.sync_data()
+ }
+}
+
+// --- label classification -------------------------------------------------------
+
+/// What a device holds before Synapse touches it.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub enum DeviceLabel {
+ /// Every byte of the label area is zero and no known signature is anywhere.
+ Blank,
+ /// A Synapse superblock magic is present at byte 0 or 4096 (valid or not).
+ Synapse,
+ /// A recognised filesystem, partition table, or volume signature.
+ Foreign(&'static str),
+ /// Non-zero bytes in the label area that match no known signature.
+ Unknown,
+}
+
+/// Where a signature sits on a device of `len` bytes.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum SigAt {
+ /// Byte offset from the start.
+ Start(u64),
+ /// Bytes before the end.
+ End(u64),
+ /// Linux MD RAID 0.90 superblock: `(len & !(64 KiB - 1)) - 64 KiB`.
+ Md090,
+ /// Linux MD RAID 1.0 superblock: `(len - 8 KiB) & !(4 KiB - 1)`.
+ Md10,
+ /// ZFS vdev label `n` (L0 at 0, L1 at 256 KiB, L2 and L3 at 512 KiB and 256 KiB
+ /// below the length rounded down to 256 KiB): any 1 KiB uberblock slot of its
+ /// 128 KiB uberblock array (label offset 128 KiB).
+ ZfsLabel(u8),
+}
+
+/// One recognised signature.
+#[derive(Debug, Clone, Copy)]
+pub struct Signature {
+ pub name: &'static str,
+ pub at: SigAt,
+ pub magic: &'static [u8],
+}
+
+const fn sig(name: &'static str, at: SigAt, magic: &'static [u8]) -> Signature {
+ Signature { name, at, magic }
+}
+
+const MD_MAGIC: &[u8] = &[0xFC, 0x4E, 0x2B, 0xA9];
+const ZFS_UB_LE: &[u8] = &[0x0C, 0xB1, 0xBA, 0, 0, 0, 0, 0];
+const ZFS_UB_BE: &[u8] = &[0, 0, 0, 0, 0, 0xBA, 0xB1, 0x0C];
+const KIB: u64 = 1024;
+
+/// Every signature that makes a device foreign, in the order they are checked (the
+/// first match names the refusal). Each entry is pinned by its own test.
+pub const SIGNATURES: &[Signature] = &[
+ sig("GPT partition table", SigAt::Start(512), b"EFI PART"),
+ sig(
+ "GPT partition table (4 KiB sectors)",
+ SigAt::Start(4096),
+ b"EFI PART",
+ ),
+ sig("GPT backup header", SigAt::End(512), b"EFI PART"),
+ sig(
+ "GPT backup header (4 KiB sectors)",
+ SigAt::End(4096),
+ b"EFI PART",
+ ),
+ sig("ext2/ext3/ext4", SigAt::Start(1080), &[0x53, 0xEF]),
+ sig("XFS", SigAt::Start(0), b"XFSB"),
+ sig("btrfs", SigAt::Start(0x1_0040), b"_BHRfS_M"),
+ sig(
+ "btrfs (mirror at 64 MiB)",
+ SigAt::Start(0x400_0040),
+ b"_BHRfS_M",
+ ),
+ sig(
+ "btrfs (mirror at 256 GiB)",
+ SigAt::Start(0x40_0000_0040),
+ b"_BHRfS_M",
+ ),
+ sig("NTFS", SigAt::Start(3), b"NTFS "),
+ sig("exFAT", SigAt::Start(3), b"EXFAT "),
+ sig("FAT12/FAT16", SigAt::Start(54), b"FAT1"),
+ sig("FAT32", SigAt::Start(82), b"FAT32 "),
+ sig("LUKS", SigAt::Start(0), b"LUKS\xba\xbe"),
+ sig(
+ "LVM2 physical volume (sector 0)",
+ SigAt::Start(0),
+ b"LABELONE",
+ ),
+ sig(
+ "LVM2 physical volume (sector 1)",
+ SigAt::Start(512),
+ b"LABELONE",
+ ),
+ sig(
+ "LVM2 physical volume (sector 2)",
+ SigAt::Start(1024),
+ b"LABELONE",
+ ),
+ sig(
+ "LVM2 physical volume (sector 3)",
+ SigAt::Start(1536),
+ b"LABELONE",
+ ),
+ sig(
+ "Linux swap (4 KiB pages)",
+ SigAt::Start(4096 - 10),
+ b"SWAPSPACE2",
+ ),
+ sig(
+ "Linux swap, old (4 KiB pages)",
+ SigAt::Start(4096 - 10),
+ b"SWAP-SPACE",
+ ),
+ sig(
+ "Linux swap (16 KiB pages)",
+ SigAt::Start(16384 - 10),
+ b"SWAPSPACE2",
+ ),
+ sig(
+ "Linux swap (64 KiB pages)",
+ SigAt::Start(65536 - 10),
+ b"SWAPSPACE2",
+ ),
+ sig("ISO 9660", SigAt::Start(0x8001), b"CD001"),
+ sig("squashfs", SigAt::Start(0), b"hsqs"),
+ sig("F2FS", SigAt::Start(1024), &[0x10, 0x20, 0xF5, 0xF2]),
+ sig("Linux MD RAID (1.2)", SigAt::Start(4096), MD_MAGIC),
+ sig("Linux MD RAID (1.1)", SigAt::Start(0), MD_MAGIC),
+ sig("Linux MD RAID (1.0)", SigAt::Md10, MD_MAGIC),
+ sig("Linux MD RAID (0.90)", SigAt::Md090, MD_MAGIC),
+ sig("ZFS label L0", SigAt::ZfsLabel(0), ZFS_UB_LE),
+ sig("ZFS label L0 (big-endian)", SigAt::ZfsLabel(0), ZFS_UB_BE),
+ sig("ZFS label L1", SigAt::ZfsLabel(1), ZFS_UB_LE),
+ sig("ZFS label L1 (big-endian)", SigAt::ZfsLabel(1), ZFS_UB_BE),
+ sig("ZFS label L2", SigAt::ZfsLabel(2), ZFS_UB_LE),
+ sig("ZFS label L2 (big-endian)", SigAt::ZfsLabel(2), ZFS_UB_BE),
+ sig("ZFS label L3", SigAt::ZfsLabel(3), ZFS_UB_LE),
+ sig("ZFS label L3 (big-endian)", SigAt::ZfsLabel(3), ZFS_UB_BE),
+ sig("MBR or boot sector", SigAt::Start(510), &[0x55, 0xAA]),
+];
+
+impl Signature {
+ /// Whether this signature is on `io`.
+ pub fn found(&self, io: &dyn BlockIo) -> std::io::Result {
+ let len = io.len();
+ let n = self.magic.len() as u64;
+ let at = |off: Option| -> std::io::Result {
+ match off.filter(|o| o.checked_add(n).is_some_and(|e| e <= len)) {
+ Some(o) => {
+ let mut b = vec![0u8; n as usize];
+ io.read_at(&mut b, o)?;
+ Ok(b == self.magic)
+ }
+ None => Ok(false),
+ }
+ };
+ match self.at {
+ SigAt::Start(o) => at(Some(o)),
+ SigAt::End(b) => at(len.checked_sub(b)),
+ SigAt::Md090 => at((len & !(64 * KIB - 1)).checked_sub(64 * KIB)),
+ SigAt::Md10 => at(len.checked_sub(8 * KIB).map(|o| o & !(4 * KIB - 1))),
+ SigAt::ZfsLabel(l) => {
+ let end = len & !(256 * KIB - 1);
+ let base = match l {
+ 0 => Some(0),
+ 1 => Some(256 * KIB),
+ 2 => end.checked_sub(512 * KIB),
+ _ => end.checked_sub(256 * KIB),
+ };
+ let Some(arr) = base.map(|b| b + 128 * KIB) else {
+ return Ok(false);
+ };
+ if arr + 128 * KIB > len {
+ return Ok(false);
+ }
+ let mut b = vec![0u8; (128 * KIB) as usize];
+ io.read_at(&mut b, arr)?;
+ Ok(b.chunks(KIB as usize).any(|s| s.starts_with(self.magic)))
+ }
+ }
+ }
+}
+
+/// Classify a device: its label area (the first [`LABEL_BYTES`]) and every
+/// [`SIGNATURES`] location, including the ones near the end of the device.
+pub fn classify_device(io: &dyn BlockIo) -> std::io::Result {
+ let mut label = vec![0u8; LABEL_BYTES.min(io.len()) as usize];
+ io.read_at(&mut label, 0)?;
+ let at =
+ |off: usize| label.get(off..off + SUPERBLOCK_MAGIC.len()) == Some(&SUPERBLOCK_MAGIC[..]);
+ if at(0) || at(BLOCK as usize) {
+ return Ok(DeviceLabel::Synapse);
+ }
+ for s in SIGNATURES {
+ if s.found(io)? {
+ return Ok(DeviceLabel::Foreign(s.name));
+ }
+ }
+ Ok(if label.iter().all(|b| *b == 0) {
+ DeviceLabel::Blank
+ } else {
+ DeviceLabel::Unknown
+ })
+}
+
+// --- superblock -----------------------------------------------------------------
+
+/// Fixed geometry of a formatted device.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub struct Geometry {
+ pub uuid: [u8; 16],
+ pub device_bytes: u64,
+ pub meta_offset: [u64; 2],
+ pub meta_region_bytes: u64,
+ pub data_offset: u64,
+ pub slot_stride: u64,
+ pub segment_bytes: u64,
+ pub slot_count: u64,
+}
+
+impl Geometry {
+ fn new(
+ uuid: [u8; 16],
+ device_bytes: u64,
+ meta_region_bytes: u64,
+ segment_bytes: u64,
+ ) -> SynapseResult {
+ let meta_region_bytes = align_up(meta_region_bytes.max(BLOCK), BLOCK);
+ let segment_bytes = align_up(segment_bytes.max(BLOCK), BLOCK);
+ let meta_offset = [META_START, META_START + meta_region_bytes];
+ let data_offset = align_up(meta_offset[1] + meta_region_bytes, 1 << 20);
+ let slot_stride = BLOCK + segment_bytes;
+ let slot_count = device_bytes.saturating_sub(data_offset) / slot_stride;
+ if slot_count < 2 {
+ return Err(refuse(format!(
+ "device of {device_bytes} bytes holds {slot_count} segment slots of {segment_bytes} bytes after {data_offset} bytes of label and metadata; at least 2 are needed"
+ )));
+ }
+ Ok(Self {
+ uuid,
+ device_bytes,
+ meta_offset,
+ meta_region_bytes,
+ data_offset,
+ slot_stride,
+ segment_bytes,
+ slot_count,
+ })
+ }
+
+ /// Byte offset of slot `id`'s header (`1 <= id <= slot_count`).
+ pub fn slot_offset(&self, id: u64) -> u64 {
+ self.data_offset + (id - 1) * self.slot_stride
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, Eq)]
+struct Superblock {
+ geo: Geometry,
+ generation: u64,
+ segment_count: u64,
+ meta_len: u64,
+ meta_slot: u8,
+ meta_sha256: [u8; 32],
+}
+
+fn meta_digest(bytes: &[u8]) -> [u8; 32] {
+ let mut h = Sha256::new();
+ h.update(DOMAIN_BLOCK_META);
+ h.update(bytes);
+ h.finalize().into()
+}
+
+impl Superblock {
+ fn encode(&self) -> Vec {
+ let g = &self.geo;
+ let mut b = Vec::with_capacity(BLOCK as usize);
+ b.extend_from_slice(&SUPERBLOCK_MAGIC);
+ b.extend_from_slice(&SUPERBLOCK_VERSION.to_le_bytes());
+ b.extend_from_slice(&(BLOCK as u32).to_le_bytes());
+ b.extend_from_slice(&g.uuid);
+ for v in [
+ self.generation,
+ g.device_bytes,
+ g.meta_offset[0],
+ g.meta_offset[1],
+ g.meta_region_bytes,
+ g.data_offset,
+ g.slot_stride,
+ g.segment_bytes,
+ g.slot_count,
+ self.segment_count,
+ self.meta_len,
+ ] {
+ b.extend_from_slice(&v.to_le_bytes());
+ }
+ b.push(self.meta_slot);
+ b.extend_from_slice(&[0u8; 7]);
+ b.extend_from_slice(&self.meta_sha256);
+ let crc = crc32c(&b);
+ b.extend_from_slice(&crc.to_le_bytes());
+ debug_assert_eq!(b.len(), SB_LEN);
+ b.resize(BLOCK as usize, 0);
+ b
+ }
+
+ /// Strict decoder; `None` for anything but a valid superblock.
+ fn decode(b: &[u8]) -> Option {
+ if b.len() < BLOCK as usize || b[0..8] != SUPERBLOCK_MAGIC {
+ return None;
+ }
+ let crc = u32::from_le_bytes(b[160..164].try_into().ok()?);
+ if crc32c(&b[..160]) != crc || b[SB_LEN..BLOCK as usize].iter().any(|x| *x != 0) {
+ return None;
+ }
+ let u32_at = |at: usize| u32::from_le_bytes(b[at..at + 4].try_into().expect("4"));
+ let u64_at = |at: usize| u64::from_le_bytes(b[at..at + 8].try_into().expect("8"));
+ if u32_at(8) != SUPERBLOCK_VERSION || u64::from(u32_at(12)) != BLOCK {
+ return None;
+ }
+ if b[121..128].iter().any(|x| *x != 0) || b[120] > 1 {
+ return None;
+ }
+ let uuid: [u8; 16] = b[16..32].try_into().ok()?;
+ let sb = Self {
+ geo: Geometry {
+ uuid,
+ device_bytes: u64_at(40),
+ meta_offset: [u64_at(48), u64_at(56)],
+ meta_region_bytes: u64_at(64),
+ data_offset: u64_at(72),
+ slot_stride: u64_at(80),
+ segment_bytes: u64_at(88),
+ slot_count: u64_at(96),
+ },
+ generation: u64_at(32),
+ segment_count: u64_at(104),
+ meta_len: u64_at(112),
+ meta_slot: b[120],
+ meta_sha256: b[128..160].try_into().ok()?,
+ };
+ // The geometry must be the one `Geometry::new` derives from its own inputs.
+ let expect = Geometry::new(
+ uuid,
+ sb.geo.device_bytes,
+ sb.geo.meta_region_bytes,
+ sb.geo.segment_bytes,
+ )
+ .ok()?;
+ if expect != sb.geo
+ || sb.meta_len > sb.geo.meta_region_bytes
+ || sb.segment_count > sb.geo.slot_count
+ || sb.generation == 0
+ {
+ return None;
+ }
+ Some(sb)
+ }
+}
+
+fn encode_meta(names: &BTreeMap>) -> Vec {
+ let mut b = Vec::new();
+ b.extend_from_slice(&META_MAGIC);
+ b.extend_from_slice(&(names.len() as u32).to_le_bytes());
+ for (name, bytes) in names {
+ b.extend_from_slice(&(name.len() as u16).to_le_bytes());
+ b.extend_from_slice(name.as_bytes());
+ b.extend_from_slice(&(bytes.len() as u64).to_le_bytes());
+ b.extend_from_slice(bytes);
+ }
+ b
+}
+
+fn decode_meta(b: &[u8]) -> Option>> {
+ let take = |at: &mut usize, n: usize| -> Option<&[u8]> {
+ let s = b.get(*at..at.checked_add(n)?)?;
+ *at += n;
+ Some(s)
+ };
+ let mut at = 0usize;
+ if take(&mut at, 4)? != META_MAGIC {
+ return None;
+ }
+ let count = u32::from_le_bytes(take(&mut at, 4)?.try_into().ok()?);
+ let mut names = BTreeMap::new();
+ let mut prev: Option = None;
+ for _ in 0..count {
+ let nl = u16::from_le_bytes(take(&mut at, 2)?.try_into().ok()?) as usize;
+ let name = std::str::from_utf8(take(&mut at, nl)?).ok()?.to_string();
+ if name.is_empty() || prev.as_ref().is_some_and(|p| *p >= name) {
+ return None;
+ }
+ let len = usize::try_from(u64::from_le_bytes(take(&mut at, 8)?.try_into().ok()?)).ok()?;
+ let bytes = take(&mut at, len)?.to_vec();
+ prev = Some(name.clone());
+ names.insert(name, bytes);
+ }
+ (at == b.len()).then_some(names)
+}
+
+fn segment_header(geo: &Geometry, id: u64) -> Vec {
+ let mut b = Vec::with_capacity(BLOCK as usize);
+ b.extend_from_slice(&SEGMENT_HEADER_MAGIC);
+ b.extend_from_slice(&1u32.to_le_bytes());
+ b.extend_from_slice(&geo.uuid);
+ b.extend_from_slice(&id.to_le_bytes());
+ b.extend_from_slice(&geo.segment_bytes.to_le_bytes());
+ let crc = crc32c(&b);
+ b.extend_from_slice(&crc.to_le_bytes());
+ b.resize(BLOCK as usize, 0);
+ b
+}
+
+// --- the device -------------------------------------------------------------------
+
+/// How [`BlockDevice::open`] treats a device without a Synapse superblock.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum FormatPolicy {
+ /// Open only a device that already holds a Synapse store.
+ OpenExisting,
+ /// Format a blank device (label area all zero); open an existing store as it is.
+ FormatIfBlank,
+}
+
+/// Where and how to open the raw block store.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct BlockDeviceConfig {
+ /// The one device path this store may open (absolute). Nothing else is opened.
+ pub path: PathBuf,
+ /// Treatment of a device without a Synapse superblock.
+ pub format: FormatPolicy,
+ /// Size of each of the two metadata regions, used when formatting.
+ pub meta_region_bytes: u64,
+ /// Format over a recognised filesystem/partition signature or other non-zero label
+ /// bytes. Destroys what was there; never set it for a device you have not checked.
+ pub allow_foreign_signature: bool,
+}
+
+impl BlockDeviceConfig {
+ /// Open the existing store at `path`: no formatting (set [`FormatPolicy::FormatIfBlank`]
+ /// to format a blank device deliberately), default metadata regions, no override.
+ pub fn new(path: impl Into) -> Self {
+ Self {
+ path: path.into(),
+ format: FormatPolicy::OpenExisting,
+ meta_region_bytes: DEFAULT_META_REGION_BYTES,
+ allow_foreign_signature: false,
+ }
+ }
+}
+
+#[derive(Debug)]
+struct MetaState {
+ generation: u64,
+ meta_slot: u8,
+ segment_count: u64,
+ names: BTreeMap>,
+}
+
+/// An opened raw block store device: geometry, the committed metadata namespace and
+/// segment count, and the segment slots.
+#[derive(Debug)]
+pub struct BlockDevice {
+ io: Box,
+ geo: Geometry,
+ state: Mutex,
+}
+
+fn new_uuid(io: &dyn BlockIo) -> [u8; 16] {
+ let mut h = Sha256::new();
+ h.update(b"SYNAPSE_BLOCK_UUID_V1\0");
+ let now = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)
+ .map(|d| d.as_nanos())
+ .unwrap_or(0);
+ h.update(now.to_le_bytes());
+ h.update(std::process::id().to_le_bytes());
+ h.update(io.len().to_le_bytes());
+ let d: [u8; 32] = h.finalize().into();
+ d[..16].try_into().expect("16")
+}
+
+impl BlockDevice {
+ /// Open the device at `cfg.path` with `O_DIRECT`. `segment_bytes` is used only when
+ /// a blank device is formatted; an existing store keeps its own.
+ pub fn open_path(cfg: &BlockDeviceConfig, segment_bytes: u64) -> SynapseResult> {
+ let io = DirectFile::open(&cfg.path)?;
+ Self::open(Box::new(io), cfg, segment_bytes)
+ }
+
+ /// Test inspection only: [`Self::open_path`] without the exclusive lock.
+ #[cfg(test)]
+ pub(crate) fn open_path_unlocked(cfg: &BlockDeviceConfig) -> SynapseResult> {
+ let io = DirectFile::open_unlocked(&cfg.path)?;
+ Self::open(Box::new(io), cfg, 0)
+ }
+
+ /// Open (or format, per `cfg`) the store on `io`.
+ pub fn open(
+ io: Box,
+ cfg: &BlockDeviceConfig,
+ segment_bytes: u64,
+ ) -> SynapseResult> {
+ if io.len() < LABEL_BYTES {
+ return Err(refuse(format!(
+ "device of {} bytes is smaller than the label area",
+ io.len()
+ )));
+ }
+ match classify_device(io.as_ref()).map_err(io_err)? {
+ DeviceLabel::Synapse => {}
+ DeviceLabel::Blank if cfg.format == FormatPolicy::FormatIfBlank => {
+ Self::format(io.as_ref(), cfg.meta_region_bytes, segment_bytes)?;
+ }
+ DeviceLabel::Blank => {
+ return Err(refuse(format!(
+ "{} is blank and the format policy is OpenExisting",
+ cfg.path.display()
+ )))
+ }
+ other if cfg.allow_foreign_signature && cfg.format == FormatPolicy::FormatIfBlank => {
+ let _ = other;
+ Self::format(io.as_ref(), cfg.meta_region_bytes, segment_bytes)?;
+ }
+ DeviceLabel::Foreign(what) => {
+ return Err(refuse(format!(
+ "refusing {}: it carries a {what} signature (set allow_foreign_signature to format over it)",
+ cfg.path.display()
+ )))
+ }
+ DeviceLabel::Unknown => {
+ return Err(refuse(format!(
+ "refusing {}: its first {LABEL_BYTES} bytes are not blank and hold no Synapse superblock (set allow_foreign_signature to format over them)",
+ cfg.path.display()
+ )))
+ }
+ }
+ Self::mount(io)
+ }
+
+ /// Write a new, empty store: zero the label area, write an empty namespace into
+ /// metadata region 0 and superblock generation 1, `fdatasync`.
+ fn format(io: &dyn BlockIo, meta_region_bytes: u64, segment_bytes: u64) -> SynapseResult<()> {
+ let geo = Geometry::new(new_uuid(io), io.len(), meta_region_bytes, segment_bytes)?;
+ let meta = encode_meta(&BTreeMap::new());
+ let sb = Superblock {
+ geo,
+ generation: 1,
+ segment_count: 0,
+ meta_len: meta.len() as u64,
+ meta_slot: 0,
+ meta_sha256: meta_digest(&meta),
+ };
+ let mut label = vec![0u8; LABEL_BYTES as usize];
+ label[BLOCK as usize..2 * BLOCK as usize].copy_from_slice(&sb.encode());
+ let mut region = meta;
+ region.resize(align_up(region.len() as u64, BLOCK) as usize, 0);
+ io.write_at(®ion, geo.meta_offset[0]).map_err(io_err)?;
+ io.write_at(&label, 0).map_err(io_err)?;
+ io.flush().map_err(io_err)
+ }
+
+ /// Recover the committed state: the newest superblock copy whose CRC holds and whose
+ /// metadata region matches its digest, else the older copy.
+ fn mount(io: Box) -> SynapseResult> {
+ let mut copies = Vec::new();
+ for i in 0..2u64 {
+ let mut b = vec![0u8; BLOCK as usize];
+ io.read_at(&mut b, i * BLOCK).map_err(io_err)?;
+ if let Some(sb) = Superblock::decode(&b) {
+ if sb.generation % 2 == i {
+ copies.push(sb);
+ }
+ }
+ }
+ copies.sort_by_key(|sb| std::cmp::Reverse(sb.generation));
+ if copies.len() == 2 && copies[0].geo != copies[1].geo {
+ return Err(corrupt(
+ "the two superblock copies disagree on the geometry",
+ ));
+ }
+ for sb in copies {
+ if sb.geo.device_bytes > io.len() {
+ return Err(corrupt(format!(
+ "superblock describes {} bytes, device has {}",
+ sb.geo.device_bytes,
+ io.len()
+ )));
+ }
+ let mut meta = vec![0u8; sb.meta_len as usize];
+ io.read_at(&mut meta, sb.geo.meta_offset[sb.meta_slot as usize])
+ .map_err(io_err)?;
+ if meta_digest(&meta) != sb.meta_sha256 {
+ continue;
+ }
+ let Some(names) = decode_meta(&meta) else {
+ continue;
+ };
+ let dev = Self {
+ io,
+ geo: sb.geo,
+ state: Mutex::new(MetaState {
+ generation: sb.generation,
+ meta_slot: sb.meta_slot,
+ segment_count: sb.segment_count,
+ names,
+ }),
+ };
+ dev.refuse_data_past_segment_count()?;
+ return Ok(Arc::new(dev));
+ }
+ Err(corrupt(
+ "no superblock copy with an intact metadata region (the device carries the Synapse magic but no valid store)",
+ ))
+ }
+
+ /// Refuse a mount whose segment count is behind the data on the device. Slot
+ /// `segment_count + 1` can hold a non-zero byte only after the commit that raised the
+ /// count to it was flushed (a rotation zeroes the slot and flushes before that
+ /// commit, and no batch goes in before it). So a valid header there with data means
+ /// the newest superblock copy was lost (damaged) and the copy in use is older:
+ /// mounting it would silently drop every change acknowledged in that slot.
+ fn refuse_data_past_segment_count(&self) -> SynapseResult<()> {
+ let next = self.lock().segment_count + 1;
+ if !self.header_valid(next).map_err(io_err)? {
+ return Ok(());
+ }
+ let start = self.data_offset(next);
+ let mut buf = vec![0u8; (ZERO_CHUNK as u64).min(self.geo.segment_bytes) as usize];
+ let mut at = 0;
+ while at < self.geo.segment_bytes {
+ let n = buf.len().min((self.geo.segment_bytes - at) as usize);
+ self.io.read_at(&mut buf[..n], start + at).map_err(io_err)?;
+ if buf[..n].iter().any(|b| *b != 0) {
+ return Err(corrupt(format!(
+ "segment slot {next} holds data past the committed segment count {}: the \
+ newest superblock copy is damaged and the older copy would drop \
+ acknowledged changes",
+ next - 1
+ )));
+ }
+ at += n as u64;
+ }
+ Ok(())
+ }
+
+ fn lock(&self) -> std::sync::MutexGuard<'_, MetaState> {
+ self.state.lock().unwrap_or_else(|p| p.into_inner())
+ }
+
+ /// The device geometry.
+ pub fn geometry(&self) -> Geometry {
+ self.geo
+ }
+
+ /// Committed segment count (segments `1..=count` may hold data).
+ pub fn segment_count(&self) -> u64 {
+ self.lock().segment_count
+ }
+
+ /// Metadata region the superblock in force points at.
+ #[cfg(test)]
+ pub(crate) fn meta_slot(&self) -> u8 {
+ self.lock().meta_slot
+ }
+
+ /// Commit generation of the superblock in force.
+ pub fn generation(&self) -> u64 {
+ self.lock().generation
+ }
+
+ /// `fdatasync` the device.
+ pub fn flush(&self) -> std::io::Result<()> {
+ self.io.flush()
+ }
+
+ /// Write a new superblock generation (and, with `names`, a new metadata region),
+ /// then `fdatasync`. On failure the in-memory state is unchanged.
+ fn commit(
+ &self,
+ st: &mut MetaState,
+ names: Option>>,
+ segment_count: u64,
+ ) -> std::io::Result<()> {
+ let generation = st.generation + 1;
+ let (meta_slot, meta) = match &names {
+ Some(n) => (1 - st.meta_slot, encode_meta(n)),
+ None => (st.meta_slot, encode_meta(&st.names)),
+ };
+ if meta.len() as u64 > self.geo.meta_region_bytes {
+ return Err(std::io::Error::other(format!(
+ "metadata of {} bytes does not fit the {}-byte metadata region",
+ meta.len(),
+ self.geo.meta_region_bytes
+ )));
+ }
+ if names.is_some() {
+ let mut region = meta.clone();
+ region.resize(align_up(region.len() as u64, BLOCK) as usize, 0);
+ self.io
+ .write_at(®ion, self.geo.meta_offset[meta_slot as usize])?;
+ }
+ let sb = Superblock {
+ geo: self.geo,
+ generation,
+ segment_count,
+ meta_len: meta.len() as u64,
+ meta_slot,
+ meta_sha256: meta_digest(&meta),
+ };
+ self.io.write_at(&sb.encode(), (generation % 2) * BLOCK)?;
+ self.io.flush()?;
+ st.generation = generation;
+ st.meta_slot = meta_slot;
+ st.segment_count = segment_count;
+ if let Some(n) = names {
+ st.names = n;
+ }
+ Ok(())
+ }
+
+ // --- named objects (the A2 store's small files) ---
+
+ /// Bytes of named object `name`, if present.
+ pub fn read_named(&self, name: &str) -> Option> {
+ self.lock().names.get(name).cloned()
+ }
+
+ /// Names of every object, ascending.
+ pub fn list_named(&self) -> Vec {
+ self.lock().names.keys().cloned().collect()
+ }
+
+ /// Atomically create or replace `name` (one metadata commit).
+ pub fn write_named(&self, name: &str, bytes: &[u8]) -> std::io::Result<()> {
+ if name.is_empty() || name.len() > usize::from(u16::MAX) {
+ return Err(std::io::Error::other("invalid object name"));
+ }
+ let mut st = self.lock();
+ let mut names = st.names.clone();
+ names.insert(name.to_string(), bytes.to_vec());
+ let count = st.segment_count;
+ self.commit(&mut st, Some(names), count)
+ }
+
+ /// Atomically remove every object whose name satisfies `pred` (one metadata commit,
+ /// none when nothing matches). Returns whether anything was removed.
+ pub fn remove_named_where(&self, pred: impl Fn(&str) -> bool) -> std::io::Result {
+ let mut st = self.lock();
+ let mut names = st.names.clone();
+ names.retain(|n, _| !pred(n));
+ if names.len() == st.names.len() {
+ return Ok(false);
+ }
+ let count = st.segment_count;
+ self.commit(&mut st, Some(names), count)?;
+ Ok(true)
+ }
+
+ // --- segment slots ---
+
+ fn check_slot(&self, id: u64) -> std::io::Result<()> {
+ if id == 0 || id > self.geo.slot_count {
+ return Err(std::io::Error::other(format!(
+ "no segment slot {id}: the device has {} slots (device full)",
+ self.geo.slot_count
+ )));
+ }
+ Ok(())
+ }
+
+ fn data_offset(&self, id: u64) -> u64 {
+ self.geo.slot_offset(id) + BLOCK
+ }
+
+ /// True when slot `id` carries this store's header for segment `id`.
+ pub fn header_valid(&self, id: u64) -> std::io::Result {
+ if id == 0 || id > self.geo.slot_count {
+ return Ok(false);
+ }
+ let mut b = vec![0u8; BLOCK as usize];
+ self.io.read_at(&mut b, self.geo.slot_offset(id))?;
+ Ok(b == segment_header(&self.geo, id))
+ }
+
+ /// Segment ids present: slots `1..=count` with a valid header, plus slot `count + 1`
+ /// when it carries a header (created by a rotation that never committed). A missing
+ /// id inside `1..=count` is reported by recovery as a gap.
+ pub fn list_segments(&self) -> std::io::Result> {
+ let count = self.segment_count();
+ let mut ids = Vec::new();
+ for id in 1..=count + 1 {
+ if self.header_valid(id)? {
+ ids.push(id);
+ }
+ }
+ Ok(ids)
+ }
+
+ /// Segment `id`'s data from byte `from` on. A slot past the committed count is never
+ /// data: it reads back empty.
+ pub fn read_segment(&self, id: u64, from: u64) -> std::io::Result> {
+ if id > self.segment_count() || from >= self.geo.segment_bytes {
+ return Ok(Vec::new());
+ }
+ self.check_slot(id)?;
+ let mut b = vec![0u8; (self.geo.segment_bytes - from) as usize];
+ self.io.read_at(&mut b, self.data_offset(id) + from)?;
+ Ok(b)
+ }
+
+ /// Read `len` bytes at `offset` of segment `id` (blob reads).
+ pub fn read_segment_at(&self, id: u64, offset: u64, len: u32) -> std::io::Result> {
+ self.check_slot(id)?;
+ if offset + u64::from(len) > self.geo.segment_bytes {
+ return Err(std::io::Error::other("read past the end of the segment"));
+ }
+ let mut b = vec![0u8; len as usize];
+ self.io.read_at(&mut b, self.data_offset(id) + offset)?;
+ Ok(b)
+ }
+
+ /// Write `data` at `offset` of segment `id` (not durable until [`Self::flush`]).
+ pub fn write_segment(&self, id: u64, offset: u64, data: &[u8]) -> std::io::Result<()> {
+ self.check_slot(id)?;
+ if offset + data.len() as u64 > self.geo.segment_bytes {
+ return Err(std::io::Error::other(format!(
+ "write of {} bytes at {offset} does not fit the {}-byte segment slot",
+ data.len(),
+ self.geo.segment_bytes
+ )));
+ }
+ self.io.write_at(data, self.data_offset(id) + offset)
+ }
+
+ /// Rotation step 2: write slot `id`'s header (not yet durable; the caller flushes).
+ pub fn write_segment_header(&self, id: u64) -> std::io::Result<()> {
+ self.check_slot(id)?;
+ self.io
+ .write_at(&segment_header(&self.geo, id), self.geo.slot_offset(id))
+ }
+
+ /// Rotation step 1: zero slot `id`'s whole data area, then `fdatasync`.
+ pub fn zero_segment(&self, id: u64) -> std::io::Result<()> {
+ self.check_slot(id)?;
+ let zeros = vec![0u8; ZERO_CHUNK];
+ let mut at = 0u64;
+ while at < self.geo.segment_bytes {
+ let n = ((self.geo.segment_bytes - at) as usize).min(ZERO_CHUNK);
+ self.io.write_at(&zeros[..n], self.data_offset(id) + at)?;
+ at += n as u64;
+ }
+ self.io.flush()
+ }
+
+ /// Rotation step 3 (the directory flush): commit `segment_count = id`. Only the next
+ /// segment can be committed.
+ pub fn commit_segment(&self, id: u64) -> std::io::Result<()> {
+ let mut st = self.lock();
+ if st.segment_count >= id {
+ return Ok(());
+ }
+ if id != st.segment_count + 1 {
+ return Err(std::io::Error::other(format!(
+ "segment {id} cannot follow committed segment {}",
+ st.segment_count
+ )));
+ }
+ self.commit(&mut st, None, id)
+ }
+
+ /// Zero bytes `from..to` of segment `id`, then `fdatasync` (torn-tail truncation).
+ pub fn zero_segment_range(&self, id: u64, from: u64, to: u64) -> std::io::Result<()> {
+ if to > from {
+ self.write_segment(id, from, &vec![0u8; (to - from) as usize])?;
+ }
+ self.io.flush()
+ }
+
+ /// Erase slot `id`'s header (test view: a lost segment file).
+ #[cfg(test)]
+ pub(crate) fn erase_segment_header(&self, id: u64) -> std::io::Result<()> {
+ self.check_slot(id)?;
+ self.io
+ .write_at(&vec![0u8; BLOCK as usize], self.geo.slot_offset(id))?;
+ self.io.flush()
+ }
+}
+
+/// The segment medium of a store: a directory of files (A2) or a raw block device (R1).
+#[derive(Debug, Clone)]
+pub(crate) enum Medium {
+ Dir(PathBuf),
+ Block(Arc),
+}
+
+impl Medium {
+ pub fn exists(&self, name: &str) -> bool {
+ match self {
+ Medium::Dir(root) => root.join(name).exists(),
+ Medium::Block(dev) => dev.read_named(name).is_some(),
+ }
+ }
+
+ pub fn read(&self, name: &str) -> std::io::Result> {
+ match self {
+ Medium::Dir(root) => fs::read(root.join(name)),
+ Medium::Block(dev) => dev.read_named(name).ok_or_else(|| {
+ std::io::Error::new(std::io::ErrorKind::NotFound, format!("no object {name}"))
+ }),
+ }
+ }
+
+ /// Atomically create or replace `name` (A2: `.tmp`, sync, rename, directory
+ /// sync; R1: one metadata commit).
+ pub fn write_atomic(&self, name: &str, bytes: &[u8]) -> SynapseResult<()> {
+ match self {
+ Medium::Dir(root) => write_file_atomic(
+ root,
+ &root.join(format!("{name}.tmp")),
+ &root.join(name),
+ bytes,
+ ),
+ Medium::Block(dev) => dev.write_named(name, bytes).map_err(io_err),
+ }
+ }
+
+ pub fn list_segments(&self) -> SynapseResult> {
+ match self {
+ Medium::Dir(root) => segment::list_segments(root),
+ Medium::Block(dev) => dev.list_segments().map_err(io_err),
+ }
+ }
+
+ /// True when segment `id` exists and holds a non-zero byte.
+ pub fn segment_has_data(&self, id: u64) -> SynapseResult {
+ match self {
+ Medium::Dir(root) => match fs::read(root.join(segment::segment_file_name(id))) {
+ Ok(b) => Ok(b.iter().any(|x| *x != 0)),
+ Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(false),
+ Err(e) => Err(io_err(e)),
+ },
+ Medium::Block(dev) => Ok(dev
+ .read_segment(id, 0)
+ .map_err(io_err)?
+ .iter()
+ .any(|x| *x != 0)),
+ }
+ }
+
+ /// Segment `id` from byte `base` on; `None` when the segment does not exist.
+ pub fn read_segment_from(&self, id: u64, base: u64) -> SynapseResult>> {
+ match self {
+ Medium::Dir(root) => {
+ let path = root.join(segment::segment_file_name(id));
+ if !path.exists() {
+ return Ok(None);
+ }
+ let mut f = File::open(&path).map_err(io_err)?;
+ f.seek(SeekFrom::Start(base)).map_err(io_err)?;
+ let mut b = Vec::new();
+ f.read_to_end(&mut b).map_err(io_err)?;
+ Ok(Some(b))
+ }
+ Medium::Block(dev) => {
+ if !dev.header_valid(id).map_err(io_err)? {
+ return Ok(None);
+ }
+ Ok(Some(dev.read_segment(id, base).map_err(io_err)?))
+ }
+ }
+ }
+
+ /// Zero bytes `from..to` of segment `id` and `fdatasync` it (torn-tail truncation).
+ pub fn zero_segment_range(&self, id: u64, from: u64, to: u64) -> SynapseResult<()> {
+ match self {
+ Medium::Dir(root) => {
+ let f = OpenOptions::new()
+ .write(true)
+ .open(root.join(segment::segment_file_name(id)))
+ .map_err(io_err)?;
+ f.write_all_at(&vec![0u8; (to - from) as usize], from)
+ .map_err(io_err)?;
+ f.sync_data().map_err(io_err)
+ }
+ Medium::Block(dev) => dev.zero_segment_range(id, from, to).map_err(io_err),
+ }
+ }
+
+ /// A read handle on segment `id` (`NotFound` when it does not exist or, on a
+ /// device, is not committed).
+ pub fn open_reader(&self, id: u64) -> std::io::Result {
+ match self {
+ Medium::Dir(root) => {
+ File::open(root.join(segment::segment_file_name(id))).map(segment::SegReader::File)
+ }
+ Medium::Block(dev) => {
+ if id <= dev.segment_count() && dev.header_valid(id)? {
+ Ok(segment::SegReader::Block(dev.clone(), id))
+ } else {
+ Err(std::io::Error::new(
+ std::io::ErrorKind::NotFound,
+ format!("segment {id} is not on the device"),
+ ))
+ }
+ }
+ }
+ }
+
+ /// Flush the namespace (A2: `fsync` the store directory; R1: every metadata commit
+ /// is already durable, so nothing is left to do).
+ pub fn sync_namespace(&self) -> SynapseResult<()> {
+ match self {
+ Medium::Dir(root) => sync_dir(root),
+ Medium::Block(_) => Ok(()),
+ }
+ }
+}
diff --git a/crates/synapse-store/src/blockdev/repair.rs b/crates/synapse-store/src/blockdev/repair.rs
new file mode 100644
index 0000000..a18254e
--- /dev/null
+++ b/crates/synapse-store/src/blockdev/repair.rs
@@ -0,0 +1,463 @@
+//! R1 store repair, non-destructive path (issue #105, follow-up to #103).
+//!
+//! When the newest superblock copy is damaged, mount refuses with `CheckpointCorrupt`
+//! because the older copy would silently drop batches acknowledged after it. This module
+//! gives the operator what the refusal lacks:
+//!
+//! * [`diagnose`] reads both superblock copies (read-only, no write of any kind) and says
+//! which copy is damaged, which checkpoint an older copy would fall back to, and the
+//! exact device byte range of the acknowledged data that fallback would lose.
+//! * [`repair_dropping_acknowledged_range`] adopts that older checkpoint. It writes
+//! nothing unless the caller passes `accept_loss = true` (CLI flag
+//! `--drop-acknowledged-range`), and before its first device write it saves the
+//! superblocks and the exact bytes it is about to zero to a new backup file and syncs
+//! it ([`read_backup`] reads it back). It zeroes only the reported range.
+//!
+//! Not here (the policy is Drake's to set): rolling the log forward past the older
+//! checkpoint, and a signed repair entry in the log.
+
+use super::*;
+
+/// State of one superblock copy.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub enum CopyState {
+ /// All 4 KiB are zero.
+ Blank,
+ /// A valid superblock whose metadata region matches its digest.
+ Intact {
+ generation: u64,
+ segment_count: u64,
+ meta_slot: u8,
+ },
+ /// A valid superblock whose metadata region does not match its digest.
+ MetaDamaged { generation: u64, segment_count: u64 },
+ /// Not a valid superblock (the reason names the first failed check).
+ Damaged(String),
+}
+
+/// One superblock copy: index 0 or 1, at byte `copy * 4096`.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct CopyReport {
+ pub copy: u8,
+ pub state: CopyState,
+}
+
+/// Acknowledged data in a slot past the checkpoint an older copy would adopt.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct LostRange {
+ /// Segment slot id.
+ pub slot: u64,
+ /// Device byte offset of the first and one past the last non-zero byte.
+ pub start: u64,
+ pub end: u64,
+ /// Number of non-zero bytes in the slot.
+ pub nonzero_bytes: u64,
+}
+
+/// What the diagnosis concludes.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub enum Verdict {
+ /// The store opens as it is; nothing to repair.
+ Healthy,
+ /// A superblock copy is unusable but the other one loses no acknowledged data.
+ OneCopyDamagedNothingLost,
+ /// Adopting the older checkpoint drops the listed ranges.
+ OlderCheckpointLosesRange,
+ /// No usable checkpoint (or contradictory geometry): this tool cannot repair it.
+ Unrepairable(String),
+}
+
+/// Result of [`diagnose`].
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct RepairReport {
+ pub device_uuid: Option<[u8; 16]>,
+ pub copies: [CopyReport; 2],
+ /// Copy and generation of the checkpoint an older copy would adopt.
+ pub adopt: Option<(u8, u64)>,
+ pub segment_count: u64,
+ pub lost: Vec,
+ pub verdict: Verdict,
+}
+
+impl std::fmt::Display for RepairReport {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ writeln!(f, "R1 store diagnosis")?;
+ for c in &self.copies {
+ let at = u64::from(c.copy) * BLOCK;
+ match &c.state {
+ CopyState::Blank => {
+ writeln!(f, "superblock copy {} (byte {at}): blank", c.copy)?
+ }
+ CopyState::Intact {
+ generation,
+ segment_count,
+ meta_slot,
+ } => writeln!(
+ f,
+ "superblock copy {} (byte {at}): intact, generation {generation}, checkpoint: {segment_count} committed segments, metadata region {meta_slot}",
+ c.copy
+ )?,
+ CopyState::MetaDamaged {
+ generation,
+ segment_count,
+ } => writeln!(
+ f,
+ "superblock copy {} (byte {at}): CORRUPT metadata region, generation {generation}, {segment_count} committed segments",
+ c.copy
+ )?,
+ CopyState::Damaged(why) => {
+ writeln!(f, "superblock copy {} (byte {at}): CORRUPT, {why}", c.copy)?
+ }
+ }
+ }
+ match &self.verdict {
+ Verdict::Healthy => writeln!(f, "verdict: healthy, nothing to repair")?,
+ Verdict::OneCopyDamagedNothingLost => writeln!(
+ f,
+ "verdict: one copy is unusable, but the checkpoint in force loses no acknowledged data; the next commit rewrites the bad copy"
+ )?,
+ Verdict::Unrepairable(why) => {
+ writeln!(f, "verdict: cannot be repaired by this tool: {why}")?
+ }
+ Verdict::OlderCheckpointLosesRange => {
+ let (copy, generation) = self.adopt.unwrap_or((0, 0));
+ writeln!(
+ f,
+ "verdict: the store refuses to open (CheckpointCorrupt). Adopting the older checkpoint (copy {copy}, generation {generation}, {} committed segments) would DROP acknowledged data:",
+ self.segment_count
+ )?;
+ for r in &self.lost {
+ writeln!(
+ f,
+ " segment slot {}: device bytes {}..{} ({} non-zero bytes)",
+ r.slot, r.start, r.end, r.nonzero_bytes
+ )?;
+ }
+ writeln!(
+ f,
+ " metadata changes committed by the damaged superblock cannot be read and are lost too"
+ )?;
+ writeln!(
+ f,
+ "nothing was written. To accept this loss re-run with --drop-acknowledged-range and --backup "
+ )?;
+ }
+ }
+ Ok(())
+ }
+}
+
+fn classify_copy(
+ b: &[u8],
+ i: u64,
+ io: &dyn BlockIo,
+) -> std::io::Result<(CopyState, Option)> {
+ if b.iter().all(|x| *x == 0) {
+ return Ok((CopyState::Blank, None));
+ }
+ let bad = |why: &str| Ok((CopyState::Damaged(why.to_string()), None));
+ if b[0..8] != SUPERBLOCK_MAGIC {
+ return bad("the Synapse magic is missing");
+ }
+ if u32::from_le_bytes(b[160..164].try_into().expect("4")) != crc32c(&b[..160]) {
+ return bad("CRC-32C mismatch");
+ }
+ let Some(sb) = Superblock::decode(b) else {
+ return bad("fields fail validation");
+ };
+ if sb.generation % 2 != i {
+ return bad("generation does not belong in this copy");
+ }
+ if sb.geo.device_bytes > io.len() {
+ return bad("describes more bytes than the device holds");
+ }
+ let mut meta = vec![0u8; sb.meta_len as usize];
+ io.read_at(&mut meta, sb.geo.meta_offset[sb.meta_slot as usize])?;
+ if meta_digest(&meta) != sb.meta_sha256 || decode_meta(&meta).is_none() {
+ return Ok((
+ CopyState::MetaDamaged {
+ generation: sb.generation,
+ segment_count: sb.segment_count,
+ },
+ Some(sb),
+ ));
+ }
+ Ok((
+ CopyState::Intact {
+ generation: sb.generation,
+ segment_count: sb.segment_count,
+ meta_slot: sb.meta_slot,
+ },
+ Some(sb),
+ ))
+}
+
+/// Non-zero extent of slot `id`'s data: (first, one past last, count), block-unaligned.
+fn nonzero_extent(
+ io: &dyn BlockIo,
+ geo: &Geometry,
+ id: u64,
+) -> std::io::Result> {
+ let start = geo.slot_offset(id) + BLOCK;
+ let mut buf = vec![0u8; (ZERO_CHUNK as u64).min(geo.segment_bytes) as usize];
+ let (mut first, mut last, mut count) = (None, 0u64, 0u64);
+ let mut at = 0;
+ while at < geo.segment_bytes {
+ let n = buf.len().min((geo.segment_bytes - at) as usize);
+ io.read_at(&mut buf[..n], start + at)?;
+ for (k, b) in buf[..n].iter().enumerate() {
+ if *b != 0 {
+ let pos = start + at + k as u64;
+ first.get_or_insert(pos);
+ last = pos + 1;
+ count += 1;
+ }
+ }
+ at += n as u64;
+ }
+ Ok(first.map(|f| (f, last, count)))
+}
+
+fn slot_header_valid(io: &dyn BlockIo, geo: &Geometry, id: u64) -> std::io::Result {
+ if id == 0 || id > geo.slot_count {
+ return Ok(false);
+ }
+ let mut b = vec![0u8; BLOCK as usize];
+ io.read_at(&mut b, geo.slot_offset(id))?;
+ Ok(b == segment_header(geo, id))
+}
+
+/// Read-only diagnosis of the device. Writes nothing. Refuses a device that does not
+/// carry the Synapse magic (never inspects a foreign device further).
+pub fn diagnose(io: &dyn BlockIo) -> SynapseResult {
+ if io.len() < LABEL_BYTES {
+ return Err(refuse("device is smaller than the label area"));
+ }
+ match classify_device(io).map_err(io_err)? {
+ DeviceLabel::Synapse => {}
+ other => {
+ return Err(refuse(format!(
+ "refusing to diagnose: the device is not a Synapse store ({other:?})"
+ )))
+ }
+ }
+ let mut parsed = Vec::new();
+ for i in 0..2u64 {
+ let mut b = vec![0u8; BLOCK as usize];
+ io.read_at(&mut b, i * BLOCK).map_err(io_err)?;
+ parsed.push(classify_copy(&b, i, io).map_err(io_err)?);
+ }
+ let copies = [
+ CopyReport {
+ copy: 0,
+ state: parsed[0].0.clone(),
+ },
+ CopyReport {
+ copy: 1,
+ state: parsed[1].0.clone(),
+ },
+ ];
+ let valid: Vec<&Superblock> = parsed.iter().filter_map(|(_, s)| s.as_ref()).collect();
+ let device_uuid = valid.first().map(|s| s.geo.uuid);
+ let mk = |adopt, segment_count, lost, verdict| RepairReport {
+ device_uuid,
+ copies: copies.clone(),
+ adopt,
+ segment_count,
+ lost,
+ verdict,
+ };
+ if valid.len() == 2 && valid[0].geo != valid[1].geo {
+ return Ok(mk(
+ None,
+ 0,
+ vec![],
+ Verdict::Unrepairable("the two superblock copies disagree on the geometry".into()),
+ ));
+ }
+ // The checkpoint mount would use: newest intact copy.
+ let mut intact: Vec<(u8, &Superblock)> = parsed
+ .iter()
+ .enumerate()
+ .filter(|(_, (st, _))| matches!(st, CopyState::Intact { .. }))
+ .filter_map(|(i, (_, sb))| sb.as_ref().map(|s| (i as u8, s)))
+ .collect();
+ intact.sort_by_key(|(_, s)| std::cmp::Reverse(s.generation));
+ let Some((copy, sb)) = intact.first().copied() else {
+ return Ok(mk(
+ None,
+ 0,
+ vec![],
+ Verdict::Unrepairable("no superblock copy with an intact metadata region".into()),
+ ));
+ };
+ let mut lost = Vec::new();
+ let mut id = sb.segment_count + 1;
+ while slot_header_valid(io, &sb.geo, id).map_err(io_err)? {
+ if let Some((start, end, nonzero_bytes)) =
+ nonzero_extent(io, &sb.geo, id).map_err(io_err)?
+ {
+ lost.push(LostRange {
+ slot: id,
+ start,
+ end,
+ nonzero_bytes,
+ });
+ }
+ id += 1;
+ }
+ let both_ok = intact.len() == 2;
+ let verdict = if !lost.is_empty() {
+ Verdict::OlderCheckpointLosesRange
+ } else if both_ok {
+ Verdict::Healthy
+ } else {
+ Verdict::OneCopyDamagedNothingLost
+ };
+ Ok(mk(
+ Some((copy, sb.generation)),
+ sb.segment_count,
+ lost,
+ verdict,
+ ))
+}
+
+// --- backup ---------------------------------------------------------------------
+
+const BACKUP_MAGIC: &[u8; 16] = b"SYNREPAIRBAK001\n";
+
+/// One saved byte range.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct BackupSection {
+ pub offset: u64,
+ pub bytes: Vec,
+}
+
+/// Contents of a repair backup file.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct Backup {
+ pub device_uuid: [u8; 16],
+ pub sections: Vec,
+}
+
+fn block_range(r: &LostRange) -> (u64, u64) {
+ (r.start / BLOCK * BLOCK, align_up(r.end, BLOCK))
+}
+
+/// Parse and verify (trailing SHA-256) a backup file written by the repair.
+pub fn read_backup(path: &Path) -> SynapseResult {
+ let b = fs::read(path).map_err(io_err)?;
+ if b.len() < 16 + 16 + 4 + 32 || &b[..16] != BACKUP_MAGIC {
+ return Err(refuse("not a repair backup file"));
+ }
+ let (body, tail) = b.split_at(b.len() - 32);
+ if Sha256::digest(body).as_slice() != tail {
+ return Err(refuse("repair backup digest mismatch"));
+ }
+ let device_uuid: [u8; 16] = body[16..32].try_into().expect("16");
+ let n = u32::from_le_bytes(body[32..36].try_into().expect("4"));
+ let mut at = 36;
+ let mut sections = Vec::new();
+ for _ in 0..n {
+ let hdr = body
+ .get(at..at + 16)
+ .ok_or_else(|| refuse("truncated repair backup"))?;
+ let offset = u64::from_le_bytes(hdr[..8].try_into().expect("8"));
+ let len = u64::from_le_bytes(hdr[8..].try_into().expect("8")) as usize;
+ let bytes = body
+ .get(at + 16..at + 16 + len)
+ .ok_or_else(|| refuse("truncated repair backup"))?
+ .to_vec();
+ sections.push(BackupSection { offset, bytes });
+ at += 16 + len;
+ }
+ Ok(Backup {
+ device_uuid,
+ sections,
+ })
+}
+
+fn write_backup(
+ io: &dyn BlockIo,
+ path: &Path,
+ uuid: [u8; 16],
+ report: &RepairReport,
+) -> SynapseResult<()> {
+ let mut ranges = vec![(0u64, 2 * BLOCK)];
+ for r in &report.lost {
+ ranges.push(block_range(r));
+ }
+ let mut body = Vec::new();
+ body.extend_from_slice(BACKUP_MAGIC);
+ body.extend_from_slice(&uuid);
+ body.extend_from_slice(&(ranges.len() as u32).to_le_bytes());
+ for (a, b) in ranges {
+ let mut bytes = vec![0u8; (b - a) as usize];
+ io.read_at(&mut bytes, a).map_err(io_err)?;
+ body.extend_from_slice(&a.to_le_bytes());
+ body.extend_from_slice(&(bytes.len() as u64).to_le_bytes());
+ body.extend_from_slice(&bytes);
+ }
+ let digest = Sha256::digest(&body);
+ body.extend_from_slice(&digest);
+ // create_new: an existing file is never overwritten; owner-only.
+ let mut f = {
+ use std::os::unix::fs::OpenOptionsExt;
+ OpenOptions::new()
+ .write(true)
+ .create_new(true)
+ .mode(0o600)
+ .open(path)
+ .map_err(|e| refuse(format!("backup file {}: {e}", path.display())))?
+ };
+ f.write_all(&body).map_err(io_err)?;
+ f.sync_all().map_err(io_err)?;
+ if let Some(dir) = path.parent().filter(|d| !d.as_os_str().is_empty()) {
+ File::open(dir).and_then(|d| d.sync_all()).map_err(io_err)?;
+ }
+ Ok(())
+}
+
+/// Adopt the older checkpoint by zeroing exactly the ranges [`diagnose`] reports.
+///
+/// * Without `accept_loss` nothing is written and the call fails, naming the range.
+/// * When the diagnosis finds no acknowledged data at risk, nothing is written and the
+/// report is returned.
+/// * Otherwise the backup file is written and synced first (it must not exist), then
+/// only the reported blocks are zeroed and flushed. Superblocks are not touched: the
+/// damaged copy fails its CRC and is rewritten by the next commit.
+pub fn repair_dropping_acknowledged_range(
+ io: &dyn BlockIo,
+ backup_path: &Path,
+ accept_loss: bool,
+) -> SynapseResult {
+ let report = diagnose(io)?;
+ if report.verdict != Verdict::OlderCheckpointLosesRange {
+ if matches!(report.verdict, Verdict::Unrepairable(_)) {
+ return Err(corrupt(format!("{report}")));
+ }
+ return Ok(report);
+ }
+ if !accept_loss {
+ return Err(refuse(format!(
+ "refusing to drop acknowledged data without --drop-acknowledged-range; nothing was written.\n{report}"
+ )));
+ }
+ let uuid = report.device_uuid.expect("a usable copy has a uuid");
+ write_backup(io, backup_path, uuid, &report)?;
+ let zero = vec![0u8; ZERO_CHUNK];
+ for r in &report.lost {
+ let (mut at, end) = block_range(r);
+ while at < end {
+ let n = (ZERO_CHUNK as u64).min(end - at) as usize;
+ io.write_at(&zero[..n], at).map_err(io_err)?;
+ at += n as u64;
+ }
+ }
+ io.flush().map_err(io_err)?;
+ let after = diagnose(io)?;
+ if !after.lost.is_empty() {
+ return Err(corrupt("range still holds data after the repair write"));
+ }
+ Ok(report)
+}
diff --git a/crates/synapse-store/src/blockdev_a2_suite.rs b/crates/synapse-store/src/blockdev_a2_suite.rs
new file mode 100644
index 0000000..0cb379f
--- /dev/null
+++ b/crates/synapse-store/src/blockdev_a2_suite.rs
@@ -0,0 +1,239 @@
+//! The A2 crash suite (`segment_tests.rs`, compiled here a second time, unchanged)
+//! against the R1 raw block store.
+//!
+//! The suite reaches the store through `super::*`, so this module provides what it
+//! names: `tests::temp_store_dir` makes a store directory holding a zero-filled device
+//! file ([`blockdev_tests::TEST_DEVICE_FILE`]), which [`SynapseStore::open`] opens as a
+//! raw block store (the crash children, which run the original `segment_tests` module,
+//! reopen through the same hook). `fs` and `segment` give the suite's file-level
+//! damage (read, overwrite, empty, or delete a segment file; list segments and index
+//! files) its device meaning: a segment file is the data area of a committed or
+//! headed slot, deleting it erases the slot header, and the small files are the
+//! device's named metadata objects. Everything else passes through to `std::fs`.
+//!
+//! Limit: the pre-A2 upgrade test copies directory fixtures (there are no pre-A2 raw
+//! block stores), so in this module it exercises the directory store again.
+
+use super::*;
+
+// Compiled a second time on purpose: the suite runs unchanged against the device.
+#[allow(clippy::duplicate_mod)]
+#[path = "segment_tests.rs"]
+mod segment_tests;
+
+/// Open the device in `dir`, if `dir` is a raw block test store.
+fn device_in(dir: &Path) -> Option> {
+ let mut cfg = blockdev_tests::redirect(dir)?;
+ cfg.format = FormatPolicy::OpenExisting;
+ Some(blockdev::BlockDevice::open_path_unlocked(&cfg).expect("open the test device"))
+}
+
+use std::sync::Arc;
+
+pub(crate) mod tests {
+ pub(crate) use crate::tests::make_signed_changeset;
+ use std::path::PathBuf;
+
+ /// A new store directory holding a zero-filled raw device file.
+ pub(crate) fn temp_store_dir(label: &str) -> PathBuf {
+ let dir = crate::tests::temp_store_dir(&format!("r1dev-{label}"));
+ crate::blockdev_tests::make_device_file(
+ &dir.join(crate::blockdev_tests::TEST_DEVICE_FILE),
+ crate::blockdev_tests::TEST_DEVICE_BYTES,
+ );
+ dir
+ }
+}
+
+pub(crate) mod segment {
+ pub(crate) use crate::segment::*;
+ use crate::SynapseResult;
+ use std::path::Path;
+
+ /// Segment ids present: on the device in `dir`, or as files.
+ pub(crate) fn list_segments(dir: &Path) -> SynapseResult> {
+ match super::device_in(dir) {
+ Some(dev) => Ok(dev.list_segments().expect("list device segments")),
+ None => crate::segment::list_segments(dir),
+ }
+ }
+}
+
+pub(crate) mod fs {
+ use std::ffi::OsString;
+ pub(crate) use std::fs::{read_to_string, remove_dir_all};
+ use std::io::{Error, ErrorKind, Result};
+ use std::path::{Path, PathBuf};
+ use std::sync::Arc;
+
+ enum Target {
+ Segment(Arc, u64),
+ Object(Arc, String),
+ Plain,
+ }
+
+ fn target(p: &Path) -> Target {
+ let (Some(dir), Some(name)) = (p.parent(), p.file_name().and_then(|n| n.to_str())) else {
+ return Target::Plain;
+ };
+ if name == crate::blockdev_tests::TEST_DEVICE_FILE || name == "acks.txt" {
+ return Target::Plain;
+ }
+ let Some(dev) = super::device_in(dir) else {
+ return Target::Plain;
+ };
+ match crate::segment::parse_segment_file_name(name) {
+ Some(id) => Target::Segment(dev, id),
+ None => Target::Object(dev, name.to_string()),
+ }
+ }
+
+ fn not_found(p: &Path) -> Error {
+ Error::new(
+ ErrorKind::NotFound,
+ format!("{} not on the device", p.display()),
+ )
+ }
+
+ pub(crate) fn read(p: impl AsRef) -> Result> {
+ let p = p.as_ref();
+ match target(p) {
+ Target::Segment(dev, id) => {
+ if !dev.header_valid(id)? {
+ return Err(not_found(p));
+ }
+ let len = dev.geometry().segment_bytes as u32;
+ dev.read_segment_at(id, 0, len)
+ }
+ Target::Object(dev, name) => dev.read_named(&name).ok_or_else(|| not_found(p)),
+ Target::Plain => std::fs::read(p),
+ }
+ }
+
+ /// Overwrite a segment's data area from byte 0 (the rest zeroed) and flush; give it a
+ /// header if it has none.
+ pub(crate) fn write(p: impl AsRef, bytes: impl AsRef<[u8]>) -> Result<()> {
+ let (p, bytes) = (p.as_ref(), bytes.as_ref());
+ match target(p) {
+ Target::Segment(dev, id) => {
+ let mut data = bytes.to_vec();
+ data.resize(dev.geometry().segment_bytes as usize, 0);
+ if !dev.header_valid(id)? {
+ dev.write_segment_header(id)?;
+ }
+ dev.write_segment(id, 0, &data)?;
+ dev.flush()
+ }
+ Target::Object(dev, name) => dev.write_named(&name, bytes),
+ Target::Plain => std::fs::write(p, bytes),
+ }
+ }
+
+ /// Delete a segment (erase its slot header) or a metadata object.
+ pub(crate) fn remove_file(p: impl AsRef) -> Result<()> {
+ let p = p.as_ref();
+ match target(p) {
+ Target::Segment(dev, id) => dev.erase_segment_header(id),
+ Target::Object(dev, name) => {
+ if dev.remove_named_where(|n| n == name)? {
+ Ok(())
+ } else {
+ Err(not_found(p))
+ }
+ }
+ Target::Plain => std::fs::remove_file(p),
+ }
+ }
+
+ pub(crate) struct Entry {
+ name: OsString,
+ path: PathBuf,
+ dir: bool,
+ }
+
+ pub(crate) struct Kind(bool);
+
+ impl Kind {
+ pub(crate) fn is_dir(&self) -> bool {
+ self.0
+ }
+ }
+
+ impl Entry {
+ pub(crate) fn file_name(&self) -> OsString {
+ self.name.clone()
+ }
+ pub(crate) fn path(&self) -> PathBuf {
+ self.path.clone()
+ }
+ pub(crate) fn file_type(&self) -> Result {
+ Ok(Kind(self.dir))
+ }
+ }
+
+ /// Directory listing; a raw block test store lists its device's objects and segments.
+ pub(crate) fn read_dir(p: impl AsRef) -> Result>> {
+ let p = p.as_ref();
+ let mut out = Vec::new();
+ if let Some(dev) = super::device_in(p) {
+ let mut names = dev.list_named();
+ names.extend(
+ dev.list_segments()?
+ .into_iter()
+ .map(crate::segment::segment_file_name),
+ );
+ for name in names {
+ out.push(Ok(Entry {
+ path: p.join(&name),
+ name: name.into(),
+ dir: false,
+ }));
+ }
+ return Ok(out.into_iter());
+ }
+ for e in std::fs::read_dir(p)? {
+ let e = e?;
+ out.push(Ok(Entry {
+ name: e.file_name(),
+ path: e.path(),
+ dir: e.file_type()?.is_dir(),
+ }));
+ }
+ Ok(out.into_iter())
+ }
+}
+
+/// Control: the stores the suite opens here are raw block stores (no segment files,
+/// no blob directory, no metadata files next to the device).
+#[test]
+fn r1_suite_stores_are_raw_block_stores() {
+ let dir = tests::temp_store_dir("control");
+ {
+ let mut s = SynapseStore::open(
+ &dir,
+ FsyncPolicy::GROUP_COMMIT_DEFAULT,
+ RecoveryPolicy::StrictFailClosed,
+ StoreLimits {
+ segment_bytes: 64 * 1024,
+ ..StoreLimits::default()
+ },
+ )
+ .unwrap();
+ assert!(matches!(s.medium, Medium::Block(_)));
+ let key = ed25519_dalek::SigningKey::from_bytes(&[3; 32]);
+ let (env, blobs) =
+ tests::make_signed_changeset(&key, "control", "src/c.rs", b"control", vec![], 1000);
+ s.ingest_changeset(env, &blobs).unwrap();
+ s.checkpoint_and_compact(1000).unwrap();
+ }
+ let names: Vec = std::fs::read_dir(&dir)
+ .unwrap()
+ .map(|e| e.unwrap().file_name().to_string_lossy().into_owned())
+ .collect();
+ assert_eq!(names, vec![blockdev_tests::TEST_DEVICE_FILE.to_string()]);
+ let dev = device_in(&dir).unwrap();
+ assert_eq!(dev.list_segments().unwrap(), vec![1]);
+ assert!(dev.read_named("checkpoint.v2").is_some());
+ assert!(dev.read_named("wal.log").is_some());
+ let _ = std::fs::remove_dir_all(&dir);
+}
diff --git a/crates/synapse-store/src/blockdev_tests.rs b/crates/synapse-store/src/blockdev_tests.rs
new file mode 100644
index 0000000..b709db0
--- /dev/null
+++ b/crates/synapse-store/src/blockdev_tests.rs
@@ -0,0 +1,1117 @@
+//! R1 raw block store tests (issue #47): device refusal rules, superblock fallback,
+//! slot exhaustion, and the power-cut simulation. The A2 crash suite itself runs
+//! unchanged against the device in `blockdev_a2_suite.rs`.
+//!
+//! Power-cut simulation: a workload runs on an in-memory device that records every
+//! write and every flush. Crash images are rebuilt from that log for every cut point,
+//! under four models of what reached the medium:
+//!
+//! * prefix tear: every write before the cut landed, the write at the cut landed for its
+//! first `k` 512-byte sectors, for every `k`;
+//! * suffix tear: the same with only the last `k` sectors landed;
+//! * lost write: one write issued since the last flush did not land at all (the drive
+//! may persist unflushed writes in any order), for every such write;
+//! * hole: the write at the cut landed except for one sector in its middle.
+//!
+//! Every acknowledged change must survive the first three models under
+//! `TruncateTornTail` (strict recovery may refuse only with `WalTornFrame`). A hole may
+//! make recovery fail closed (the A2 limit documented at `wal2::torn_evidence`), but it
+//! must never open with an acknowledged change missing.
+
+use super::blockdev::*;
+use super::tests::make_signed_changeset;
+use super::*;
+use ed25519_dalek::SigningKey;
+use std::sync::{Arc, Mutex};
+
+/// File in a test store directory that turns it into a raw block store.
+pub(crate) const TEST_DEVICE_FILE: &str = "raw.device";
+/// Size of the test devices (sparse files).
+pub(crate) const TEST_DEVICE_BYTES: u64 = 16 << 20;
+/// Metadata region size of the test devices.
+pub(crate) const TEST_META_BYTES: u64 = 1 << 20;
+
+/// Test hook of [`SynapseStore::open`]: a directory holding [`TEST_DEVICE_FILE`] is
+/// opened as a raw block store on that file.
+pub(crate) fn redirect(root: &Path) -> Option {
+ let path = root.join(TEST_DEVICE_FILE);
+ path.is_file().then_some(BlockDeviceConfig {
+ path,
+ format: FormatPolicy::FormatIfBlank,
+ meta_region_bytes: TEST_META_BYTES,
+ allow_foreign_signature: false,
+ })
+}
+
+/// Create a zero-filled (sparse) test device file of `len` bytes.
+pub(crate) fn make_device_file(path: &Path, len: u64) {
+ let f = File::create(path).unwrap();
+ f.set_len(len).unwrap();
+ f.sync_all().unwrap();
+}
+
+fn temp_dir(label: &str) -> PathBuf {
+ super::tests::temp_store_dir(&format!("r1-{label}"))
+}
+
+// --- in-memory device with a write log -------------------------------------------
+
+#[derive(Debug, Clone, PartialEq, Eq)]
+enum Op {
+ Write { off: u64, data: Vec },
+ Flush,
+}
+
+#[derive(Debug)]
+struct Rec {
+ image: Vec,
+ ops: Vec,
+ fail_flushes: bool,
+}
+
+#[derive(Debug, Clone)]
+struct MemIo(Arc>);
+
+impl MemIo {
+ fn new(image: Vec) -> Self {
+ Self(Arc::new(Mutex::new(Rec {
+ image,
+ ops: Vec::new(),
+ fail_flushes: false,
+ })))
+ }
+ fn rec(&self) -> std::sync::MutexGuard<'_, Rec> {
+ self.0.lock().unwrap()
+ }
+}
+
+impl BlockIo for MemIo {
+ fn len(&self) -> u64 {
+ self.rec().image.len() as u64
+ }
+ fn read_at(&self, buf: &mut [u8], off: u64) -> std::io::Result<()> {
+ let r = self.rec();
+ let src = r
+ .image
+ .get(off as usize..off as usize + buf.len())
+ .ok_or_else(|| std::io::Error::other("read past the end"))?;
+ buf.copy_from_slice(src);
+ Ok(())
+ }
+ fn write_at(&self, data: &[u8], off: u64) -> std::io::Result<()> {
+ let mut r = self.rec();
+ let dst = r
+ .image
+ .get_mut(off as usize..off as usize + data.len())
+ .ok_or_else(|| std::io::Error::other("write past the end"))?;
+ dst.copy_from_slice(data);
+ r.ops.push(Op::Write {
+ off,
+ data: data.to_vec(),
+ });
+ Ok(())
+ }
+ fn flush(&self) -> std::io::Result<()> {
+ let mut r = self.rec();
+ if r.fail_flushes {
+ return Err(std::io::Error::other("injected flush failure"));
+ }
+ r.ops.push(Op::Flush);
+ Ok(())
+ }
+}
+
+fn mem_cfg(format: FormatPolicy, meta: u64) -> BlockDeviceConfig {
+ BlockDeviceConfig {
+ path: PathBuf::from("/r1-test/in-memory"),
+ format,
+ meta_region_bytes: meta,
+ allow_foreign_signature: false,
+ }
+}
+
+/// Deterministic non-zero filler (xorshift), standing in for stale bytes from an
+/// earlier use of the device.
+fn garbage(len: usize, mut x: u64) -> Vec {
+ let mut v = Vec::with_capacity(len);
+ while v.len() < len {
+ x ^= x << 13;
+ x ^= x >> 7;
+ x ^= x << 17;
+ v.extend_from_slice(&x.to_le_bytes());
+ }
+ v.truncate(len);
+ v
+}
+
+// --- store helpers ---------------------------------------------------------------
+
+const SEG: u64 = 64 * 1024;
+const BLOB: usize = 6000;
+const STRICT: RecoveryPolicy = RecoveryPolicy::StrictFailClosed;
+const TRUNCATE: RecoveryPolicy = RecoveryPolicy::TruncateTornTail;
+
+fn limits() -> StoreLimits {
+ StoreLimits {
+ segment_bytes: SEG,
+ wal_prealloc_bytes: 16 * 1024,
+ ..Default::default()
+ }
+}
+
+fn key(n: u8) -> SigningKey {
+ SigningKey::from_bytes(&[n; 32])
+}
+
+fn commit(store: &mut SynapseStore, key: &SigningKey, label: &str) -> SynapseResult {
+ let mut content = format!("// {label}\n").into_bytes();
+ let mut x: u8 = label
+ .bytes()
+ .fold(7u8, |a, b| a.wrapping_mul(31).wrapping_add(b));
+ while content.len() < BLOB {
+ x = x.wrapping_mul(13).wrapping_add(1);
+ content.push(b'a' + x % 26);
+ }
+ let (env, blobs) = make_signed_changeset(
+ key,
+ label,
+ &format!("src/{label}.rs"),
+ &content,
+ vec![],
+ 1000,
+ );
+ match store.ingest_changeset(env, &blobs)? {
+ IngestOutcome::Committed {
+ wal_seq,
+ durability,
+ ..
+ } => {
+ assert_eq!(durability, DurabilityGuarantee::FsyncBeforeAck);
+ Ok(wal_seq)
+ }
+ other => panic!("expected Committed, got {other:?}"),
+ }
+}
+
+/// Every changeset is listed and every blob reads back with its digest.
+fn check_readable(store: &SynapseStore) -> Result {
+ let all = store
+ .list_changesets(None, None, None)
+ .map_err(|e| format!("list: {e:?}"))?;
+ for c in &all {
+ for m in &c.envelope.mutations {
+ if let MutationOp::Upsert {
+ blob_digest,
+ size_bytes,
+ ..
+ } = &m.op
+ {
+ let bytes = store
+ .get_blob_visible(*blob_digest, None, None)
+ .map_err(|e| format!("blob {blob_digest}: {e:?}"))?;
+ if bytes.len() as u64 != *size_bytes {
+ return Err(format!("blob {blob_digest}: wrong length"));
+ }
+ }
+ }
+ }
+ Ok(all.len())
+}
+
+// --- refusal rules ---------------------------------------------------------------
+
+#[test]
+fn r1_refuses_a_device_carrying_a_filesystem_or_partition_signature() {
+ let dir = temp_dir("sig");
+ let cases: [(&str, usize, &[u8]); 4] = [
+ ("ext4", 1080, &[0x53, 0xEF]),
+ ("gpt", 512, b"EFI PART"),
+ ("xfs", 0, b"XFSB"),
+ ("luks", 0, b"LUKS\xba\xbe"),
+ ];
+ for (name, off, sig) in cases {
+ let path = dir.join(format!("{name}.img"));
+ make_device_file(&path, TEST_DEVICE_BYTES);
+ {
+ use std::os::unix::fs::FileExt;
+ let f = OpenOptions::new().write(true).open(&path).unwrap();
+ f.write_all_at(sig, off as u64).unwrap();
+ f.write_all_at(b"user data that must survive", 64 * 1024 + 7)
+ .unwrap();
+ }
+ let before = fs::read(&path).unwrap();
+ let cfg = BlockDeviceConfig {
+ format: FormatPolicy::FormatIfBlank,
+ meta_region_bytes: TEST_META_BYTES,
+ ..BlockDeviceConfig::new(&path)
+ };
+ let err = SynapseStore::open_block_device(
+ &cfg,
+ FsyncPolicy::GROUP_COMMIT_DEFAULT,
+ STRICT,
+ limits(),
+ )
+ .err()
+ .unwrap_or_else(|| panic!("{name}: a device with a signature was opened"));
+ assert_eq!(err.code, RefusalCode::IoFailure, "{name}: {err:?}");
+ assert!(err.message.contains("carries a"), "{name}: {}", err.message);
+ assert_eq!(
+ fs::read(&path).unwrap(),
+ before,
+ "{name}: refused device changed"
+ );
+ // The explicit override formats over it.
+ let cfg = BlockDeviceConfig {
+ allow_foreign_signature: true,
+ ..cfg
+ };
+ let mut s = SynapseStore::open_block_device(
+ &cfg,
+ FsyncPolicy::GROUP_COMMIT_DEFAULT,
+ STRICT,
+ limits(),
+ )
+ .unwrap_or_else(|e| panic!("{name}: override refused: {e:?}"));
+ assert_eq!(commit(&mut s, &key(1), name).unwrap(), WalSeq(1));
+ drop(s);
+ let dev = DirectFile::open(&path).unwrap();
+ assert_eq!(
+ classify_device(&dev).unwrap(),
+ DeviceLabel::Synapse,
+ "{name}"
+ );
+ }
+ let _ = fs::remove_dir_all(&dir);
+}
+
+#[test]
+fn r1_refuses_unknown_label_bytes_and_blank_devices_without_format() {
+ let dir = temp_dir("unknown");
+ let path = dir.join("dev.img");
+ make_device_file(&path, TEST_DEVICE_BYTES);
+ let cfg = BlockDeviceConfig {
+ format: FormatPolicy::OpenExisting,
+ ..BlockDeviceConfig::new(&path)
+ };
+ let err = BlockDevice::open_path(&cfg, SEG).unwrap_err();
+ assert!(err.message.contains("blank"), "{}", err.message);
+ {
+ use std::os::unix::fs::FileExt;
+ let f = OpenOptions::new().write(true).open(&path).unwrap();
+ f.write_all_at(b"\x01", 100 * 1024).unwrap();
+ }
+ let cfg = BlockDeviceConfig::new(&path);
+ let err = BlockDevice::open_path(&cfg, SEG).unwrap_err();
+ assert!(err.message.contains("not blank"), "{}", err.message);
+ let _ = fs::remove_dir_all(&dir);
+}
+
+#[test]
+fn r1_opens_only_the_configured_path() {
+ let dir = temp_dir("paths");
+ let path = dir.join("dev.img");
+ make_device_file(&path, TEST_DEVICE_BYTES);
+ // Relative path.
+ let err = DirectFile::open(Path::new("dev.img")).unwrap_err();
+ assert!(err.message.contains("absolute"), "{}", err.message);
+ // A directory.
+ let err = DirectFile::open(&dir).unwrap_err();
+ assert!(err.message.contains("neither"), "{}", err.message);
+ // A symbolic link to a valid device file.
+ let link = dir.join("link.img");
+ std::os::unix::fs::symlink(&path, &link).unwrap();
+ let err = DirectFile::open(&link).unwrap_err();
+ assert!(err.message.contains("symbolic"), "{}", err.message);
+ // Missing file: nothing is created.
+ let missing = dir.join("missing.img");
+ assert!(DirectFile::open(&missing).is_err());
+ assert!(!missing.exists());
+ // Length not a multiple of the block size.
+ let odd = dir.join("odd.img");
+ make_device_file(&odd, TEST_DEVICE_BYTES + 512);
+ let err = DirectFile::open(&odd).unwrap_err();
+ assert!(err.message.contains("multiple"), "{}", err.message);
+ // The configured file itself opens, and unaligned I/O round-trips through O_DIRECT.
+ let d = DirectFile::open(&path).unwrap();
+ d.write_at(b"0123456789", 4090).unwrap();
+ d.flush().unwrap();
+ let mut b = [0u8; 12];
+ d.read_at(&mut b, 4089).unwrap();
+ assert_eq!(&b, b"\x000123456789\x00");
+ let _ = fs::remove_dir_all(&dir);
+}
+
+#[test]
+fn r1_classifies_known_signatures() {
+ let label = |patches: Vec<(u64, Vec)>| {
+ classify_device(&SparseIo {
+ len: LABEL_BYTES,
+ patches,
+ })
+ .unwrap()
+ };
+ assert_eq!(label(vec![]), DeviceLabel::Blank);
+ assert_eq!(label(vec![(100 * 1024, vec![1])]), DeviceLabel::Unknown);
+ assert_eq!(
+ label(vec![(4096, SUPERBLOCK_MAGIC.to_vec())]),
+ DeviceLabel::Synapse
+ );
+ // A GPT disk carries a protective MBR too: the GPT name wins.
+ assert_eq!(
+ label(vec![(510, vec![0x55, 0xAA]), (512, b"EFI PART".to_vec())]),
+ DeviceLabel::Foreign("GPT partition table")
+ );
+}
+
+/// A sparse read-only device: zeros except for `patches`.
+#[derive(Debug)]
+struct SparseIo {
+ len: u64,
+ patches: Vec<(u64, Vec)>,
+}
+
+impl BlockIo for SparseIo {
+ fn len(&self) -> u64 {
+ self.len
+ }
+ fn read_at(&self, buf: &mut [u8], off: u64) -> std::io::Result<()> {
+ buf.fill(0);
+ let end = off + buf.len() as u64;
+ for (at, bytes) in &self.patches {
+ for (i, b) in bytes.iter().enumerate() {
+ let p = at + i as u64;
+ if p >= off && p < end {
+ buf[(p - off) as usize] = *b;
+ }
+ }
+ }
+ Ok(())
+ }
+ fn write_at(&self, _: &[u8], _: u64) -> std::io::Result<()> {
+ Err(std::io::Error::other("read-only"))
+ }
+ fn flush(&self) -> std::io::Result<()> {
+ Ok(())
+ }
+}
+
+/// Large enough for every offset (btrfs's 256 GiB mirror) and not a multiple of 64 KiB,
+/// so the MD RAID and ZFS end rounding is exercised.
+const PIN_LEN: u64 = (300 << 30) + (12 << 20) + 3 * 4096;
+const PIN_ZFS_END: u64 = PIN_LEN & !(256 * 1024 - 1);
+const PIN_MD: &[u8] = &[0xFC, 0x4E, 0x2B, 0xA9];
+const PIN_ZFS_LE: &[u8] = &[0x0C, 0xB1, 0xBA, 0, 0, 0, 0, 0];
+const PIN_ZFS_BE: &[u8] = &[0, 0, 0, 0, 0, 0xBA, 0xB1, 0x0C];
+
+/// A device carrying only `magic` at `off` is refused as `name`.
+fn pinned(name: &str, off: u64, magic: &[u8]) {
+ let io = SparseIo {
+ len: PIN_LEN,
+ patches: vec![(off, magic.to_vec())],
+ };
+ match classify_device(&io).unwrap() {
+ DeviceLabel::Foreign(n) => assert_eq!(n, name),
+ other => panic!("{name}: classified {other:?}"),
+ }
+}
+
+// One test per signature, written independently of `SIGNATURES`: deleting or moving an
+// entry turns its test red.
+macro_rules! pin {
+ ($($t:ident: $name:expr, $off:expr, $magic:expr;)*) => {
+ $(#[test] fn $t() { pinned($name, $off, $magic) })*
+ };
+}
+
+pin! {
+ r1_sig_gpt: "GPT partition table", 512, b"EFI PART";
+ r1_sig_gpt_4k: "GPT partition table (4 KiB sectors)", 4096, b"EFI PART";
+ r1_sig_gpt_backup: "GPT backup header", PIN_LEN - 512, b"EFI PART";
+ r1_sig_gpt_backup_4k: "GPT backup header (4 KiB sectors)", PIN_LEN - 4096, b"EFI PART";
+ r1_sig_ext: "ext2/ext3/ext4", 1080, &[0x53, 0xEF];
+ r1_sig_xfs: "XFS", 0, b"XFSB";
+ r1_sig_btrfs: "btrfs", 0x1_0040, b"_BHRfS_M";
+ r1_sig_btrfs_64m: "btrfs (mirror at 64 MiB)", 64 * 1024 * 1024 + 0x40, b"_BHRfS_M";
+ r1_sig_btrfs_256g: "btrfs (mirror at 256 GiB)", (256 << 30) + 0x40, b"_BHRfS_M";
+ r1_sig_ntfs: "NTFS", 3, b"NTFS ";
+ r1_sig_exfat: "exFAT", 3, b"EXFAT ";
+ r1_sig_fat16: "FAT12/FAT16", 54, b"FAT1";
+ r1_sig_fat32: "FAT32", 82, b"FAT32 ";
+ r1_sig_luks: "LUKS", 0, b"LUKS\xba\xbe";
+ r1_sig_lvm0: "LVM2 physical volume (sector 0)", 0, b"LABELONE";
+ r1_sig_lvm1: "LVM2 physical volume (sector 1)", 512, b"LABELONE";
+ r1_sig_lvm2: "LVM2 physical volume (sector 2)", 1024, b"LABELONE";
+ r1_sig_lvm3: "LVM2 physical volume (sector 3)", 1536, b"LABELONE";
+ r1_sig_swap: "Linux swap (4 KiB pages)", 4086, b"SWAPSPACE2";
+ r1_sig_swap_old: "Linux swap, old (4 KiB pages)", 4086, b"SWAP-SPACE";
+ r1_sig_swap_16k: "Linux swap (16 KiB pages)", 16374, b"SWAPSPACE2";
+ r1_sig_swap_64k: "Linux swap (64 KiB pages)", 65526, b"SWAPSPACE2";
+ r1_sig_iso9660: "ISO 9660", 0x8001, b"CD001";
+ r1_sig_squashfs: "squashfs", 0, b"hsqs";
+ r1_sig_f2fs: "F2FS", 1024, &[0x10, 0x20, 0xF5, 0xF2];
+ r1_sig_md_1_2: "Linux MD RAID (1.2)", 4096, PIN_MD;
+ r1_sig_md_1_1: "Linux MD RAID (1.1)", 0, PIN_MD;
+ r1_sig_md_1_0: "Linux MD RAID (1.0)", (PIN_LEN - 8192) & !4095, PIN_MD;
+ r1_sig_md_0_90: "Linux MD RAID (0.90)", (PIN_LEN & !0xFFFF) - 0x10000, PIN_MD;
+ r1_sig_zfs_l0: "ZFS label L0", 128 * 1024 + 5 * 1024, PIN_ZFS_LE;
+ r1_sig_zfs_l0_be: "ZFS label L0 (big-endian)", 255 * 1024, PIN_ZFS_BE;
+ r1_sig_zfs_l1: "ZFS label L1", 384 * 1024, PIN_ZFS_LE;
+ r1_sig_zfs_l1_be: "ZFS label L1 (big-endian)", 400 * 1024, PIN_ZFS_BE;
+ r1_sig_zfs_l2: "ZFS label L2", PIN_ZFS_END - 512 * 1024 + 192 * 1024, PIN_ZFS_LE;
+ r1_sig_zfs_l2_be: "ZFS label L2 (big-endian)", PIN_ZFS_END - 384 * 1024, PIN_ZFS_BE;
+ r1_sig_zfs_l3: "ZFS label L3", PIN_ZFS_END - 128 * 1024, PIN_ZFS_LE;
+ r1_sig_zfs_l3_be: "ZFS label L3 (big-endian)", PIN_ZFS_END - 1024, PIN_ZFS_BE;
+ r1_sig_mbr: "MBR or boot sector", 510, &[0x55, 0xAA];
+}
+
+/// The pinned list and `SIGNATURES` have the same size: a new entry needs a pin test.
+#[test]
+fn r1_every_signature_has_a_pin_test() {
+ assert_eq!(SIGNATURES.len(), 38);
+}
+
+// --- superblock and metadata commits ----------------------------------------------
+
+#[test]
+fn r1_superblock_falls_back_to_the_older_copy_when_the_newest_is_damaged() {
+ let io = MemIo::new(vec![0u8; 8 << 20]);
+ let cfg = mem_cfg(FormatPolicy::FormatIfBlank, 64 * 1024);
+ let dev = BlockDevice::open(Box::new(io.clone()), &cfg, SEG).unwrap();
+ dev.write_named("a", b"first").unwrap();
+ dev.write_named("b", b"second").unwrap();
+ let g = dev.generation();
+ let geo = dev.geometry();
+ drop(dev);
+ let reopen = |io: &MemIo| {
+ BlockDevice::open(
+ Box::new(MemIo::new(io.rec().image.clone())),
+ &mem_cfg(FormatPolicy::OpenExisting, 64 * 1024),
+ SEG,
+ )
+ };
+ let d = reopen(&io).unwrap();
+ assert_eq!(d.read_named("b").as_deref(), Some(&b"second"[..]));
+ // Damage the newest superblock copy: the older one (without "b") is used.
+ let newest = (g % 2 * BLOCK) as usize;
+ let saved = io.rec().image[newest + 40];
+ io.rec().image[newest + 40] ^= 0xFF;
+ let d = reopen(&io).unwrap();
+ assert_eq!(d.generation(), g - 1);
+ assert_eq!(d.read_named("a").as_deref(), Some(&b"first"[..]));
+ assert_eq!(d.read_named("b"), None);
+ io.rec().image[newest + 40] = saved;
+ // Damage the metadata region the newest copy points at: same fallback. The byte is
+ // the last byte of "second" ("SBM1", count, then "a" and "b" entries: 41 bytes), so
+ // the region still decodes and only its digest catches the damage.
+ let d = reopen(&io).unwrap();
+ assert_eq!(d.generation(), g);
+ let slot = d.meta_slot() as usize;
+ let region = geo.meta_offset[slot] as usize;
+ io.rec().image[region + 40] ^= 0x01;
+ let d = reopen(&io).unwrap();
+ assert_eq!(d.generation(), g - 1);
+ assert_eq!(d.read_named("b"), None);
+ // Both copies damaged: refused, never formatted over.
+ let other = ((g - 1) % 2 * BLOCK) as usize;
+ io.rec().image[other + 40] ^= 0xFF;
+ let err = reopen(&io).unwrap_err();
+ assert_eq!(err.code, RefusalCode::CheckpointCorrupt, "{err:?}");
+}
+
+#[test]
+fn r1_full_device_refuses_the_batch_and_keeps_every_ack() {
+ // Room for exactly 2 slots of 64 KiB after 2 MiB of label and metadata.
+ let io = MemIo::new(vec![0u8; (2 << 20) + 2 * (BLOCK + SEG) as usize]);
+ let cfg = mem_cfg(FormatPolicy::FormatIfBlank, 256 * 1024);
+ let dev = BlockDevice::open(Box::new(io.clone()), &cfg, SEG).unwrap();
+ assert_eq!(dev.geometry().slot_count, 2);
+ let mut s = SynapseStore::open_on_device(dev, cfg.path.clone(), STRICT, limits()).unwrap();
+ let mut acked = 0;
+ let err = loop {
+ match commit(&mut s, &key(5), &format!("full-{acked}")) {
+ Ok(seq) => acked = seq.0,
+ Err(e) => break e,
+ }
+ };
+ assert_eq!(acked, 16, "two slots of 8 batches");
+ assert_eq!(err.code, RefusalCode::IoFailure, "{err:?}");
+ assert!(err.message.contains("device full"), "{}", err.message);
+ assert!(s.poisoned().is_none());
+ assert_eq!(check_readable(&s).unwrap(), 16);
+ drop(s);
+ let dev = BlockDevice::open(
+ Box::new(MemIo::new(io.rec().image.clone())),
+ &mem_cfg(FormatPolicy::OpenExisting, 256 * 1024),
+ SEG,
+ )
+ .unwrap();
+ let s = SynapseStore::open_on_device(dev, cfg.path, STRICT, limits()).unwrap();
+ assert_eq!(s.committed_seq(), WalSeq(16));
+}
+
+#[test]
+fn r1_failed_device_flush_acknowledges_nothing() {
+ let io = MemIo::new(vec![0u8; 4 << 20]);
+ let cfg = mem_cfg(FormatPolicy::FormatIfBlank, 256 * 1024);
+ let dev = BlockDevice::open(Box::new(io.clone()), &cfg, SEG).unwrap();
+ let mut s = SynapseStore::open_on_device(dev, cfg.path.clone(), STRICT, limits()).unwrap();
+ for i in 0..3 {
+ commit(&mut s, &key(6), &format!("ff-{i}")).unwrap();
+ }
+ io.rec().fail_flushes = true;
+ let err = commit(&mut s, &key(6), "ff-fail").unwrap_err();
+ assert_eq!(err.code, RefusalCode::IoFailure, "{err:?}");
+ assert_eq!(s.committed_seq(), WalSeq(3));
+ io.rec().fail_flushes = false;
+ drop(s);
+ let dev = BlockDevice::open(
+ Box::new(MemIo::new(io.rec().image.clone())),
+ &mem_cfg(FormatPolicy::OpenExisting, 256 * 1024),
+ SEG,
+ )
+ .unwrap();
+ let mut s = SynapseStore::open_on_device(dev, cfg.path, TRUNCATE, limits()).unwrap();
+ assert!(s.committed_seq() == WalSeq(3) || s.committed_seq() == WalSeq(4));
+ let next = commit(&mut s, &key(6), "ff-after").unwrap();
+ assert_eq!(next.0, s.committed_seq().0);
+ assert_eq!(check_readable(&s).unwrap() as u64, next.0);
+}
+
+// --- power-cut simulation -----------------------------------------------------------
+
+const PC_DEVICE: usize = 4 << 20;
+const PC_META: u64 = 256 * 1024;
+const SECTOR: usize = 512;
+
+struct Workload {
+ base: Vec,
+ ops: Vec,
+ /// `(ops completed when the ack returned, acknowledged seq)`.
+ acks: Vec<(usize, u64)>,
+ max_seq: u64,
+}
+
+/// Format, 20 commits across three segments, a checkpoint, 6 more commits, reopen,
+/// 2 more commits: every device write and flush is logged.
+fn record_workload() -> Workload {
+ let mut base = vec![0u8; PC_DEVICE];
+ base[LABEL_BYTES as usize..].copy_from_slice(&garbage(PC_DEVICE - LABEL_BYTES as usize, 47));
+ let io = MemIo::new(base.clone());
+ let cfg = mem_cfg(FormatPolicy::FormatIfBlank, PC_META);
+ let mut acks = Vec::new();
+ let mut n = 0u64;
+ let mut run = |s: &mut SynapseStore, count: usize, acks: &mut Vec<(usize, u64)>| {
+ for _ in 0..count {
+ let seq = commit(s, &key(9), &format!("pc-{n}")).unwrap();
+ n += 1;
+ acks.push((io.rec().ops.len(), seq.0));
+ }
+ };
+ {
+ let dev = BlockDevice::open(Box::new(io.clone()), &cfg, SEG).unwrap();
+ let mut s = SynapseStore::open_on_device(dev, cfg.path.clone(), STRICT, limits()).unwrap();
+ run(&mut s, 20, &mut acks);
+ s.checkpoint_and_compact(1000).unwrap();
+ // The checkpoint acknowledges nothing new, but its commits are cut points too.
+ run(&mut s, 6, &mut acks);
+ }
+ {
+ let dev = BlockDevice::open(Box::new(io.clone()), &cfg, SEG).unwrap();
+ let mut s = SynapseStore::open_on_device(dev, cfg.path.clone(), STRICT, limits()).unwrap();
+ run(&mut s, 2, &mut acks);
+ }
+ let ops = io.rec().ops.clone();
+ let max_seq = acks.last().unwrap().1;
+ Workload {
+ base,
+ ops,
+ acks,
+ max_seq,
+ }
+}
+
+fn apply(img: &mut [u8], op: &Op) {
+ if let Op::Write { off, data } = op {
+ img[*off as usize..*off as usize + data.len()].copy_from_slice(data);
+ }
+}
+
+#[derive(Debug, Default)]
+struct Tally {
+ states: usize,
+ opened: usize,
+ strict_torn_refusals: usize,
+ fail_closed: usize,
+ continued: usize,
+}
+
+/// Recover a crash image and check it. `must_open`: the image must open (with every
+/// ack) under `TruncateTornTail`; otherwise failing closed is allowed.
+fn check_image(img: &[u8], acked: u64, max_seq: u64, must_open: bool, what: &str, t: &mut Tally) {
+ t.states += 1;
+ let open = |policy| -> SynapseResult {
+ let dev = BlockDevice::open(
+ Box::new(MemIo::new(img.to_vec())),
+ &mem_cfg(FormatPolicy::OpenExisting, PC_META),
+ SEG,
+ )?;
+ SynapseStore::open_on_device(dev, PathBuf::from("/r1-test/in-memory"), policy, limits())
+ };
+ let verify = |s: &SynapseStore, policy: &str| {
+ let c = s.committed_seq().0;
+ assert!(
+ c >= acked && c <= max_seq,
+ "{what} ({policy}): committed {c}, acknowledged {acked}, written {max_seq}"
+ );
+ let listed = check_readable(s).unwrap_or_else(|e| panic!("{what} ({policy}): {e}"));
+ assert_eq!(listed as u64, c, "{what} ({policy}): changesets listed");
+ };
+ match open(TRUNCATE) {
+ Ok(mut s) => {
+ t.opened += 1;
+ verify(&s, "truncate");
+ // Sample: the recovered store keeps working and reopens.
+ if t.states.is_multiple_of(23) {
+ let next = commit(&mut s, &key(10), &format!("after-{}", t.states))
+ .unwrap_or_else(|e| panic!("{what}: commit after recovery: {e:?}"));
+ assert_eq!(next.0, s.committed_seq().0);
+ t.continued += 1;
+ }
+ }
+ Err(e) if acked == 0 => {
+ // Before the first acknowledgment (the format flush has not returned) a
+ // device may refuse to open; nothing was promised.
+ let _ = e;
+ }
+ Err(e) if !must_open => {
+ t.fail_closed += 1;
+ let _ = e;
+ }
+ Err(e) => panic!("{what}: truncating recovery refused with acks up to {acked}: {e:?}"),
+ }
+ match open(STRICT) {
+ Ok(s) => verify(&s, "strict"),
+ Err(e) if e.code == RefusalCode::WalTornFrame => t.strict_torn_refusals += 1,
+ Err(_) if acked == 0 || !must_open => {}
+ Err(e) => panic!("{what}: strict recovery refused other than as torn: {e:?}"),
+ }
+}
+
+fn acked_at(w: &Workload, completed_ops: usize) -> u64 {
+ w.acks
+ .iter()
+ .filter(|(at, _)| *at <= completed_ops)
+ .map(|(_, s)| *s)
+ .max()
+ .unwrap_or(0)
+}
+
+#[test]
+fn r1_power_cut_at_every_write_boundary_keeps_every_ack() {
+ let w = record_workload();
+ let writes = w
+ .ops
+ .iter()
+ .filter(|o| matches!(o, Op::Write { .. }))
+ .count();
+ let flushes = w.ops.len() - writes;
+ let mut prefix = Tally::default();
+ let mut suffix = Tally::default();
+ let mut lost = Tally::default();
+ let mut hole = Tally::default();
+ let mut img = w.base.clone();
+ let mut last_flush = 0usize; // ops[..last_flush] are durable for sure
+ for (i, op) in w.ops.iter().enumerate() {
+ // Cut while op `i` is in flight: ops[..i] were issued and completed.
+ let acked = acked_at(&w, i);
+ if let Op::Write { off, data } = op {
+ let sectors = data.len().div_ceil(SECTOR);
+ for k in 0..sectors {
+ let mut c = img.clone();
+ let n = k * SECTOR;
+ c[*off as usize..*off as usize + n].copy_from_slice(&data[..n]);
+ check_image(
+ &c,
+ acked,
+ w.max_seq,
+ true,
+ &format!("op {i} prefix {k}/{sectors}"),
+ &mut prefix,
+ );
+ let mut c = img.clone();
+ let from = data.len() - n;
+ c[*off as usize + from..*off as usize + data.len()].copy_from_slice(&data[from..]);
+ check_image(
+ &c,
+ acked,
+ w.max_seq,
+ true,
+ &format!("op {i} suffix {k}/{sectors}"),
+ &mut suffix,
+ );
+ }
+ for k in 1..sectors.saturating_sub(1) {
+ let mut c = img.clone();
+ apply(&mut c, op);
+ let at = *off as usize + k * SECTOR;
+ let end = (at + SECTOR).min(*off as usize + data.len());
+ c[at..end].copy_from_slice(&w_before(&w, i, at, end));
+ check_image(
+ &c,
+ acked,
+ w.max_seq,
+ false,
+ &format!("op {i} hole {k}/{sectors}"),
+ &mut hole,
+ );
+ }
+ }
+ // Lost write: one write issued since the last flush never landed.
+ for j in last_flush..i {
+ if !matches!(w.ops[j], Op::Write { .. }) {
+ continue;
+ }
+ let mut c = w.base.clone();
+ for (m, o) in w.ops[..i].iter().enumerate() {
+ if m != j {
+ apply(&mut c, o);
+ }
+ }
+ check_image(
+ &c,
+ acked,
+ w.max_seq,
+ true,
+ &format!("cut {i} lost write {j}"),
+ &mut lost,
+ );
+ }
+ apply(&mut img, op);
+ if matches!(op, Op::Flush) {
+ last_flush = i + 1;
+ }
+ }
+ // The finished workload.
+ check_image(&img, w.max_seq, w.max_seq, true, "complete", &mut prefix);
+ eprintln!(
+ "R1 power-cut simulation: {} device writes, {flushes} flushes, {} acks; \
+ prefix {prefix:?}; suffix {suffix:?}; lost-write {lost:?}; hole {hole:?}",
+ writes,
+ w.acks.len()
+ );
+ assert!(prefix.states > 1000 && suffix.states > 1000 && lost.states > 20);
+ assert_eq!(
+ prefix.fail_closed + suffix.fail_closed + lost.fail_closed,
+ 0
+ );
+}
+
+/// Bytes `at..end` of the device just before op `i` (for the hole model).
+fn w_before(w: &Workload, i: usize, at: usize, end: usize) -> Vec {
+ let mut v = w.base[at..end].to_vec();
+ for o in &w.ops[..i] {
+ if let Op::Write { off, data } = o {
+ let (o0, o1) = (*off as usize, *off as usize + data.len());
+ let (s, e) = (at.max(o0), end.min(o1));
+ if s < e {
+ v[s - at..e - at].copy_from_slice(&data[s - o0..e - o0]);
+ }
+ }
+ }
+ v
+}
+
+// --- review of PR #103 ----------------------------------------------------------------
+
+/// Reviewer's scenario (B2): 10 acknowledged changes across two slots, then one damaged
+/// byte in the newest superblock copy (the rotation commit that raised the segment
+/// count). Recovery may refuse loudly; it must never open with fewer changes.
+#[test]
+fn r1_lost_newest_superblock_never_drops_acknowledged_changes() {
+ let io = MemIo::new(vec![0u8; 4 << 20]);
+ let cfg = mem_cfg(FormatPolicy::FormatIfBlank, 256 * 1024);
+ let dev = BlockDevice::open(Box::new(io.clone()), &cfg, SEG).unwrap();
+ let mut s = SynapseStore::open_on_device(dev, cfg.path.clone(), TRUNCATE, limits()).unwrap();
+ for i in 0..10 {
+ commit(&mut s, &key(8), &format!("lost-sb-{i}")).unwrap();
+ }
+ drop(s);
+ let reopen_dev = |io: &MemIo| {
+ BlockDevice::open(
+ Box::new(MemIo::new(io.rec().image.clone())),
+ &mem_cfg(FormatPolicy::OpenExisting, 256 * 1024),
+ SEG,
+ )
+ };
+ let dev = reopen_dev(&io).unwrap();
+ assert_eq!(
+ dev.segment_count(),
+ 2,
+ "8 batches per slot: 10 changes use 2 slots"
+ );
+ let newest = (dev.generation() % 2 * BLOCK) as usize;
+ drop(dev);
+ io.rec().image[newest + 40] ^= 0xFF;
+ for policy in [TRUNCATE, STRICT] {
+ let opened = reopen_dev(&io)
+ .and_then(|dev| SynapseStore::open_on_device(dev, cfg.path.clone(), policy, limits()));
+ match opened {
+ Ok(s) => {
+ assert_eq!(
+ s.committed_seq(),
+ WalSeq(10),
+ "{policy:?}: acknowledged changes lost"
+ );
+ assert_eq!(check_readable(&s).unwrap(), 10, "{policy:?}");
+ }
+ Err(e) => assert_eq!(e.code, RefusalCode::CheckpointCorrupt, "{policy:?}: {e:?}"),
+ }
+ }
+}
+
+/// N4: a second opener of the same device (here a device file) is refused while the
+/// first holds it.
+#[test]
+fn r1_a_second_opener_of_the_device_is_refused() {
+ let dir = temp_dir("lock");
+ let path = dir.join("dev.img");
+ make_device_file(&path, TEST_DEVICE_BYTES);
+ let first = DirectFile::open(&path).unwrap();
+ let err = DirectFile::open(&path).unwrap_err();
+ assert!(err.message.contains("in use"), "{}", err.message);
+ drop(first);
+ DirectFile::open(&path).unwrap();
+ let _ = fs::remove_dir_all(&dir);
+}
+
+/// N1: a device whose label area is zero but that carries a signature near its end
+/// (backup GPT header, MD RAID 0.90 or 1.0 superblock, ZFS label L2 or L3) is refused
+/// and left unchanged, even with `FormatIfBlank`.
+#[test]
+fn r1_refuses_a_device_whose_signature_is_only_at_its_end() {
+ let dir = temp_dir("endsig");
+ let len = TEST_DEVICE_BYTES;
+ let md = [0xFC, 0x4E, 0x2B, 0xA9];
+ let zfs_le = 0x00ba_b10c_u64.to_le_bytes();
+ let zfs_end = len & !(256 * 1024 - 1);
+ let cases: [(&str, u64, &[u8]); 5] = [
+ ("gpt-backup", len - 512, b"EFI PART"),
+ ("md-0.90", (len & !0xFFFF) - 0x10000, &md),
+ ("md-1.0", (len - 8192) & !4095, &md),
+ ("zfs-l2", zfs_end - 512 * 1024 + 128 * 1024, &zfs_le),
+ (
+ "zfs-l3",
+ zfs_end - 256 * 1024 + 128 * 1024 + 3 * 1024,
+ &zfs_le,
+ ),
+ ];
+ for (name, off, sig) in cases {
+ let path = dir.join(format!("{name}.img"));
+ make_device_file(&path, len);
+ {
+ use std::os::unix::fs::FileExt;
+ let f = OpenOptions::new().write(true).open(&path).unwrap();
+ f.write_all_at(sig, off).unwrap();
+ f.write_all_at(b"user data that must survive", 2 << 20)
+ .unwrap();
+ }
+ let before = fs::read(&path).unwrap();
+ let cfg = BlockDeviceConfig {
+ format: FormatPolicy::FormatIfBlank,
+ meta_region_bytes: TEST_META_BYTES,
+ ..BlockDeviceConfig::new(&path)
+ };
+ let opened = SynapseStore::open_block_device(
+ &cfg,
+ FsyncPolicy::GROUP_COMMIT_DEFAULT,
+ STRICT,
+ limits(),
+ );
+ assert!(
+ opened.is_err(),
+ "{name}: a device with an end signature was formatted"
+ );
+ assert_eq!(
+ fs::read(&path).unwrap(),
+ before,
+ "{name}: refused device changed"
+ );
+ }
+ let _ = fs::remove_dir_all(&dir);
+}
+
+// --- repair tool, non-destructive path (issue #105) -------------------------------
+
+mod repair_tests {
+ use super::*;
+ use crate::blockdev::repair::*;
+
+ /// 10 acknowledged changes over two slots (8 batches per slot), then the newest
+ /// superblock copy (the rotation commit that raised the count to 2) damaged.
+ fn damaged_fixture() -> (MemIo, Vec) {
+ let io = MemIo::new(vec![0u8; 4 << 20]);
+ let cfg = mem_cfg(FormatPolicy::FormatIfBlank, 256 * 1024);
+ let dev = BlockDevice::open(Box::new(io.clone()), &cfg, SEG).unwrap();
+ let mut s =
+ SynapseStore::open_on_device(dev, cfg.path.clone(), TRUNCATE, limits()).unwrap();
+ for i in 0..10 {
+ commit(&mut s, &key(9), &format!("repair-{i}")).unwrap();
+ }
+ drop(s);
+ let g = {
+ let d = BlockDevice::open(
+ Box::new(MemIo::new(io.rec().image.clone())),
+ &mem_cfg(FormatPolicy::OpenExisting, 256 * 1024),
+ SEG,
+ )
+ .unwrap();
+ assert_eq!(d.segment_count(), 2);
+ d.generation()
+ };
+ io.rec().image[(g % 2 * BLOCK) as usize + 40] ^= 0xFF;
+ let original = io.rec().image.clone();
+ (io, original)
+ }
+
+ fn open_seq(image: Vec) -> Result {
+ BlockDevice::open(
+ Box::new(MemIo::new(image)),
+ &mem_cfg(FormatPolicy::OpenExisting, 256 * 1024),
+ SEG,
+ )
+ .and_then(|dev| {
+ SynapseStore::open_on_device(
+ dev,
+ PathBuf::from("/r1-test/in-memory"),
+ TRUNCATE,
+ limits(),
+ )
+ })
+ .map(|s| s.committed_seq().0)
+ .map_err(|e| e.code)
+ }
+
+ fn writes(io: &MemIo) -> usize {
+ io.rec()
+ .ops
+ .iter()
+ .filter(|o| matches!(o, Op::Write { .. }))
+ .count()
+ }
+
+ #[test]
+ fn r1_repair_diagnosis_names_the_corrupt_copy_and_the_range_lost() {
+ let (io, original) = damaged_fixture();
+ assert_eq!(
+ open_seq(original.clone()),
+ Err(RefusalCode::CheckpointCorrupt)
+ );
+ let before = writes(&io);
+ let r = diagnose(&io).unwrap();
+ assert_eq!(writes(&io), before, "diagnose must not write");
+ assert_eq!(io.rec().image, original);
+ assert_eq!(r.verdict, Verdict::OlderCheckpointLosesRange);
+ assert_eq!(r.segment_count, 1);
+ assert_eq!(r.lost.len(), 1);
+ assert_eq!(r.lost[0].slot, 2);
+ let text = r.to_string();
+ assert!(
+ text.contains("CRC-32C mismatch") || text.contains("CORRUPT"),
+ "{text}"
+ );
+ assert!(text.contains("CORRUPT, CRC-32C mismatch"), "{text}");
+ assert!(text.contains("1 committed segments"), "{text}");
+ assert!(
+ text.contains(&format!(
+ "segment slot 2: device bytes {}..{}",
+ r.lost[0].start, r.lost[0].end
+ )),
+ "{text}"
+ );
+ assert!(text.contains("DROP acknowledged data"), "{text}");
+ assert!(text.contains("nothing was written"), "{text}");
+ }
+
+ #[test]
+ fn r1_repair_refuses_without_the_flag_and_writes_nothing() {
+ let (io, original) = damaged_fixture();
+ let dir = temp_dir("repair-refuse");
+ let backup = dir.join("backup.bin");
+ let before = writes(&io);
+ let err = repair_dropping_acknowledged_range(&io, &backup, false).unwrap_err();
+ assert!(err.message.contains("--drop-acknowledged-range"), "{err:?}");
+ assert_eq!(writes(&io), before);
+ assert_eq!(io.rec().image, original);
+ assert!(!backup.exists(), "no backup before consent either");
+ }
+
+ #[test]
+ fn r1_repair_with_the_flag_backs_up_then_drops_only_the_reported_range() {
+ let (io, original) = damaged_fixture();
+ let dir = temp_dir("repair-drop");
+ let backup = dir.join("backup.bin");
+ let report = repair_dropping_acknowledged_range(&io, &backup, true).unwrap();
+ // Backup content equals the original device bytes of what was touched.
+ let b = read_backup(&backup).unwrap();
+ assert_eq!(b.sections.len(), 1 + report.lost.len());
+ assert_eq!(b.sections[0].offset, 0);
+ assert_eq!(b.sections[0].bytes, original[..2 * BLOCK as usize]);
+ let l = &report.lost[0];
+ let (a, e) = (l.start / BLOCK * BLOCK, l.end.div_ceil(BLOCK) * BLOCK);
+ assert_eq!(b.sections[1].offset, a);
+ assert_eq!(b.sections[1].bytes, original[a as usize..e as usize]);
+ assert!(b.sections[1].bytes.iter().any(|x| *x != 0));
+ // Only the reported blocks changed, and they are now zero.
+ let after = io.rec().image.clone();
+ for (i, (x, y)) in original.iter().zip(&after).enumerate() {
+ if x != y {
+ assert!(
+ (a..e).contains(&(i as u64)),
+ "byte {i} changed outside the range"
+ );
+ }
+ }
+ assert!(after[a as usize..e as usize].iter().all(|x| *x == 0));
+ assert_eq!(after[..2 * BLOCK as usize], original[..2 * BLOCK as usize]);
+ // The store opens again with the older checkpoint: slot 1's 8 changes.
+ assert_eq!(open_seq(after).unwrap(), 8);
+ // The backup is never overwritten by a second repair.
+ let r2 = repair_dropping_acknowledged_range(&io, &backup, true).unwrap();
+ assert_eq!(r2.verdict, Verdict::OneCopyDamagedNothingLost);
+ }
+
+ #[test]
+ fn r1_repair_intact_image_has_nothing_to_do_and_never_writes() {
+ let io = MemIo::new(vec![0u8; 4 << 20]);
+ let cfg = mem_cfg(FormatPolicy::FormatIfBlank, 256 * 1024);
+ let dev = BlockDevice::open(Box::new(io.clone()), &cfg, SEG).unwrap();
+ let mut s =
+ SynapseStore::open_on_device(dev, cfg.path.clone(), TRUNCATE, limits()).unwrap();
+ commit(&mut s, &key(9), "intact").unwrap();
+ drop(s);
+ // Two statements: the guard from io.rec() would otherwise live to the end of the
+ // tuple expression while writes(&io) takes the same lock on this thread.
+ let img = io.rec().image.clone();
+ let w = writes(&io);
+ let dir = temp_dir("repair-intact");
+ let backup = dir.join("b.bin");
+ assert_eq!(diagnose(&io).unwrap().verdict, Verdict::Healthy);
+ let r = repair_dropping_acknowledged_range(&io, &backup, true).unwrap();
+ assert_eq!(r.verdict, Verdict::Healthy);
+ let now_img = io.rec().image.clone();
+ assert_eq!((now_img, writes(&io)), (img, w));
+ assert!(!backup.exists());
+ }
+
+ #[test]
+ fn r1_repair_refuses_a_foreign_device() {
+ let mut img = vec![0u8; 4 << 20];
+ img[510] = 0x55;
+ img[511] = 0xAA; // MBR
+ let io = MemIo::new(img);
+ assert!(diagnose(&io).is_err());
+ assert!(
+ repair_dropping_acknowledged_range(&io, Path::new("/nonexistent/b"), true).is_err()
+ );
+ }
+}
diff --git a/crates/synapse-store/src/lib.rs b/crates/synapse-store/src/lib.rs
index 144657d..63cc265 100644
--- a/crates/synapse-store/src/lib.rs
+++ b/crates/synapse-store/src/lib.rs
@@ -27,6 +27,11 @@ use synapse_core::{
#[cfg(test)]
mod a1_tests;
+pub mod blockdev;
+#[cfg(test)]
+mod blockdev_a2_suite;
+#[cfg(test)]
+mod blockdev_tests;
pub mod codec;
#[cfg(test)]
mod group_tests;
@@ -37,6 +42,8 @@ mod segment_tests;
mod shared;
pub mod wal2;
+use blockdev::Medium;
+pub use blockdev::{BlockDeviceConfig, FormatPolicy};
pub use codec::{CheckpointChain, CheckpointState, CodecRefusal, RecordCodec};
pub use revision::{
AdmissionAuthority, ChangeStatus, RecordedMarker, RevisionOutcome, StoredRevision,
@@ -428,7 +435,6 @@ pub struct SynapseStore {
root_dir: PathBuf,
blobs_dir: PathBuf,
wal_path: PathBuf,
- checkpoint_path: PathBuf,
fsync_policy: FsyncPolicy,
limits: StoreLimits,
committed_seq: WalSeq,
@@ -449,7 +455,10 @@ pub struct SynapseStore {
/// Segment writer (taken out by the group-commit leader while it writes a batch).
wal_v2: Option,
/// Read handles on the segment files, by segment id, for inline blob reads.
- segment_readers: BTreeMap,
+ segment_readers: BTreeMap,
+ /// Where the segments and the small metadata objects live: the store directory (A2)
+ /// or a raw block device (R1).
+ medium: Medium,
/// End of the valid log found by recovery: (segment, byte offset).
wal_v2_recovered_end: (u64, u64),
/// The blob index: digest to its location inside a segment.
@@ -573,17 +582,78 @@ impl SynapseStore {
limits: StoreLimits,
) -> SynapseResult {
let root_dir = root_dir.as_ref().to_path_buf();
+ #[cfg(test)]
+ if let Some(cfg) = blockdev_tests::redirect(&root_dir) {
+ // Test hook: a directory holding `raw.device` is a raw block store (the A2
+ // crash suite runs unchanged against R1; crash children reopen through here).
+ return Self::open_block_device(&cfg, fsync_policy, recovery_policy, limits);
+ }
+ fs::create_dir_all(root_dir.join("blobs")).map_err(io_err)?;
+ let medium = Medium::Dir(root_dir.clone());
+ Self::open_on(root_dir, medium, fsync_policy, recovery_policy, limits)
+ }
+
+ /// Open or initialize a store on a raw block device with no filesystem (ADR 0003
+ /// R1, `docs/R1_RAW_BLOCK_STORE.md`). Opens exactly `cfg.path` with `O_DIRECT`;
+ /// refuses a device carrying a filesystem or partition signature unless
+ /// `cfg.allow_foreign_signature` is set. Requires `FsyncPolicy::GroupCommit` (the
+ /// segment layout is the only layout on a device).
+ pub fn open_block_device(
+ cfg: &BlockDeviceConfig,
+ fsync_policy: FsyncPolicy,
+ recovery_policy: RecoveryPolicy,
+ limits: StoreLimits,
+ ) -> SynapseResult {
+ if !fsync_policy.is_group_commit() {
+ return Err(SynapseError::new(
+ RefusalCode::IoFailure,
+ "a raw block store needs FsyncPolicy::GroupCommit",
+ ));
+ }
+ let dev = blockdev::BlockDevice::open_path(cfg, limits.segment_bytes)?;
+ // `root_dir` is the device path: any filesystem path derived from it (blob files
+ // of the v1 layout) fails with ENOTDIR instead of landing somewhere else.
+ Self::open_on(
+ cfg.path.clone(),
+ Medium::Block(dev),
+ fsync_policy,
+ recovery_policy,
+ limits,
+ )
+ }
+
+ /// Open a store on an already opened device (tests: in-memory power-cut images).
+ #[cfg(test)]
+ pub(crate) fn open_on_device(
+ dev: std::sync::Arc,
+ label: PathBuf,
+ recovery_policy: RecoveryPolicy,
+ limits: StoreLimits,
+ ) -> SynapseResult {
+ Self::open_on(
+ label,
+ Medium::Block(dev),
+ FsyncPolicy::GROUP_COMMIT_DEFAULT,
+ recovery_policy,
+ limits,
+ )
+ }
+
+ fn open_on(
+ root_dir: PathBuf,
+ medium: Medium,
+ fsync_policy: FsyncPolicy,
+ recovery_policy: RecoveryPolicy,
+ limits: StoreLimits,
+ ) -> SynapseResult {
let blobs_dir = root_dir.join("blobs");
let wal_path = root_dir.join("wal.log");
- let checkpoint_path = root_dir.join("checkpoint.v1");
-
- fs::create_dir_all(&blobs_dir).map_err(io_err)?;
let mut store = Self {
+ medium,
root_dir,
blobs_dir,
wal_path,
- checkpoint_path,
fsync_policy,
limits,
committed_seq: WalSeq::ZERO,
@@ -622,7 +692,7 @@ impl SynapseStore {
}
let (active, end) = store.wal_v2_recovered_end;
let writer = segment::SegmentLog::open(
- &store.root_dir,
+ &store.medium,
active,
end,
store.limits.segment_bytes,
@@ -1178,9 +1248,9 @@ impl SynapseStore {
if !self.segment_readers.contains_key(&active) {
// A new segment (its directory entry is already flushed). Without a read
// handle its blobs could not be served, so a failure here poisons the store.
- match File::open(self.root_dir.join(segment::segment_file_name(active))) {
- Ok(f) => {
- self.segment_readers.insert(active, f);
+ match self.medium.open_reader(active) {
+ Ok(r) => {
+ self.segment_readers.insert(active, r);
}
Err(e) => {
let msg = format!("open segment {active} for reads: {e}");
@@ -1235,7 +1305,7 @@ impl SynapseStore {
format!("segment {} is not open for reads", loc.segment),
)
})?;
- let bytes = segment::read_at(f, loc.offset, loc.len).map_err(|e| {
+ let bytes = f.read_at(loc.offset, loc.len).map_err(|e| {
SynapseError::new(
RefusalCode::BlobNotFound,
format!("read blob {digest} from segment {}: {e}", loc.segment),
@@ -1263,7 +1333,7 @@ impl SynapseStore {
/// it, the complete marker is in place. An in-place append could leave a torn
/// 88-byte tail that strict recovery refuses.
fn upgrade_to_segments(&mut self) -> SynapseResult<()> {
- for id in segment::list_segments(&self.root_dir)? {
+ for id in self.medium.list_segments()? {
if id >= 2 && self.segment_has_data(id)? {
return Err(SynapseError::new(
RefusalCode::WalVersionUnsupported,
@@ -1272,12 +1342,32 @@ impl SynapseStore {
}
}
let index = segment::SegmentIndex {
- binding: segment::checkpoint_binding(&self.root_dir)?,
+ binding: segment::checkpoint_binding_on(&self.medium)?,
replay_segment: 1,
replay_offset: 0,
entries: BTreeMap::new(),
};
- let keep = index.write(&self.root_dir)?;
+ let keep = index.write(&self.medium)?;
+ if let Medium::Block(_) = &self.medium {
+ // A raw block store is created with the segment layout: `wal.log` is absent
+ // (new store, or a crash before this commit) and gets only the marker.
+ if self.medium.exists("wal.log") || self.log_layout != LogLayout::V1 {
+ return Err(SynapseError::new(
+ RefusalCode::WalVersionUnsupported,
+ "raw block store holds a wal.log without the segment marker",
+ ));
+ }
+ let header = marker_header(
+ segment::WAL_SEGMENT_MARKER_VERSION,
+ self.committed_seq,
+ self.last_frame_sha256,
+ );
+ self.medium.write_atomic("wal.log", &header)?;
+ segment::remove_other_indexes(&self.medium, &keep)?;
+ self.v2_mode = true;
+ self.log_layout = LogLayout::Segments;
+ return Ok(());
+ }
let (keep_len, seq, prev) = match self.log_layout {
LogLayout::SingleFileV2 => {
// Replace the WAL v2 marker (the last 88 bytes) with the segment marker
@@ -1309,7 +1399,7 @@ impl SynapseStore {
}
fs::rename(&tmp, &self.wal_path).map_err(io_err)?;
sync_dir(&self.root_dir)?;
- segment::remove_other_indexes(&self.root_dir, &keep)?;
+ segment::remove_other_indexes(&self.medium, &keep)?;
self.v2_mode = true;
self.log_layout = LogLayout::Segments;
Ok(())
@@ -1317,12 +1407,7 @@ impl SynapseStore {
/// True when segment `id` exists and holds a non-zero byte.
fn segment_has_data(&self, id: u64) -> SynapseResult {
- let path = self.root_dir.join(segment::segment_file_name(id));
- match fs::read(&path) {
- Ok(b) => Ok(b.iter().any(|x| *x != 0)),
- Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(false),
- Err(e) => Err(io_err(e)),
- }
+ self.medium.segment_has_data(id)
}
/// Open a read handle on every segment file up to the active one.
@@ -1332,10 +1417,9 @@ impl SynapseStore {
if self.segment_readers.contains_key(&id) {
continue;
}
- let path = self.root_dir.join(segment::segment_file_name(id));
- match File::open(&path) {
- Ok(f) => {
- self.segment_readers.insert(id, f);
+ match self.medium.open_reader(id) {
+ Ok(r) => {
+ self.segment_readers.insert(id, r);
}
// Segments before the replay start may hold no retained blob; a missing
// one only fails the reads that need it (BlobNotFound).
@@ -1353,14 +1437,7 @@ impl SynapseStore {
self.committed_seq,
self.last_frame_sha256,
);
- let tmp = self.root_dir.join("wal.log.tmp");
- {
- let mut f = File::create(&tmp).map_err(io_err)?;
- f.write_all(&header).map_err(io_err)?;
- f.sync_all().map_err(io_err)?;
- }
- fs::rename(&tmp, &self.wal_path).map_err(io_err)?;
- sync_dir(&self.root_dir)
+ self.medium.write_atomic("wal.log", &header)
}
/// Attach a machine evaluation receipt to an existing changeset.
@@ -1717,7 +1794,7 @@ impl SynapseStore {
.map(|(d, l)| (*d, *l))
.collect(),
};
- let name = index.write(&self.root_dir)?;
+ let name = index.write(&self.medium)?;
if self.fault_injection == FaultInjection::CrashAfterSegmentIndexBeforeCheckpoint {
std::process::exit(FAULT_CRASH_EXIT_CODE);
}
@@ -1725,12 +1802,8 @@ impl SynapseStore {
} else {
None
};
- write_file_atomic(
- &self.root_dir,
- &self.root_dir.join("checkpoint.v2.tmp"),
- &self.root_dir.join(codec::CHECKPOINT_V2_FILE),
- &bytes,
- )?;
+ self.medium
+ .write_atomic(codec::CHECKPOINT_V2_FILE, &bytes)?;
self.checkpoint_chain = Some(chain);
self.codec = RecordCodec::BinaryV2;
self.binary_seen = true;
@@ -1743,7 +1816,7 @@ impl SynapseStore {
// still refuse the store); the segments are kept whole, replay starts at the
// index's position, and older index files are removed.
self.replace_wal_log_with_segment_marker()?;
- segment::remove_other_indexes(&self.root_dir, &name)?;
+ segment::remove_other_indexes(&self.medium, &name)?;
self.blob_locations = index.entries;
} else {
let f = OpenOptions::new()
@@ -1754,7 +1827,7 @@ impl SynapseStore {
.map_err(io_err)?;
f.sync_all().map_err(io_err)?;
}
- sync_dir(&self.root_dir)?;
+ self.medium.sync_namespace()?;
self.unflushed_frames = 0;
// 5. Sweep unreferenced blobs on disk (including orphan blobs from pre-WAL crashes)
@@ -2139,12 +2212,14 @@ impl SynapseStore {
// 1. Load the checkpoint: checkpoint.v2 (binary, chained) when present, else
// checkpoint.v1 (JSON). Once checkpoint.v2 exists, checkpoint.v1 is the
// tombstone that makes binaries knowing only v1 refuse the store.
- let v2_path = self.root_dir.join(codec::CHECKPOINT_V2_FILE);
- if v2_path.exists() {
- let raw = fs::read(&v2_path).map_err(io_err)?;
+ if self.medium.exists(codec::CHECKPOINT_V2_FILE) {
+ let raw = self
+ .medium
+ .read(codec::CHECKPOINT_V2_FILE)
+ .map_err(io_err)?;
let (state, chain) = codec::decode_checkpoint_v2(&raw)?;
- if self.checkpoint_path.exists() {
- let v1 = fs::read(&self.checkpoint_path).map_err(io_err)?;
+ if self.medium.exists("checkpoint.v1") {
+ let v1 = self.medium.read("checkpoint.v1").map_err(io_err)?;
if v1 != codec::v1_tombstone_bytes() {
// A crash between writing checkpoint.v2 and the tombstone leaves the
// older v1 checkpoint; it must not be ahead of checkpoint.v2.
@@ -2168,8 +2243,8 @@ impl SynapseStore {
self.load_checkpoint_state(state);
self.checkpoint_chain = Some(chain);
self.binary_seen = true;
- } else if self.checkpoint_path.exists() {
- let raw = fs::read(&self.checkpoint_path).map_err(io_err)?;
+ } else if self.medium.exists("checkpoint.v1") {
+ let raw = self.medium.read("checkpoint.v1").map_err(io_err)?;
if raw == codec::v1_tombstone_bytes() {
return Err(SynapseError::new(
RefusalCode::CheckpointCorrupt,
@@ -2191,7 +2266,7 @@ impl SynapseStore {
// before the logs were emptied) are verified and skipped. In the segment layout
// (ADR 0003 A2) replay of the segments starts at the segment index position.
let mut overlap = CheckpointOverlap::default();
- if self.wal_path.exists() {
+ if self.medium.exists("wal.log") {
self.recover_v1(recovery_policy, &mut overlap)?;
}
self.recover_v2(recovery_policy, &mut overlap)?;
@@ -2247,12 +2322,8 @@ impl SynapseStore {
/// Replace `checkpoint.v1` with the tombstone (atomic: temp file, sync, rename, sync).
fn write_v1_tombstone(&mut self) -> SynapseResult<()> {
- write_file_atomic(
- &self.root_dir,
- &self.root_dir.join("checkpoint.v1.tmp"),
- &self.checkpoint_path,
- &codec::v1_tombstone_bytes(),
- )?;
+ self.medium
+ .write_atomic("checkpoint.v1", &codec::v1_tombstone_bytes())?;
self.tombstone_pending = false;
Ok(())
}
@@ -2262,12 +2333,22 @@ impl SynapseStore {
recovery_policy: RecoveryPolicy,
overlap: &mut CheckpointOverlap,
) -> SynapseResult<()> {
- let mut f = OpenOptions::new()
- .read(true)
- .write(true)
- .open(&self.wal_path)
- .map_err(io_err)?;
- let file_len = f.metadata().map_err(io_err)?.len();
+ let (mut f, file_len) = match &self.medium {
+ Medium::Dir(_) => {
+ let f = OpenOptions::new()
+ .read(true)
+ .write(true)
+ .open(&self.wal_path)
+ .map_err(io_err)?;
+ let len = f.metadata().map_err(io_err)?.len();
+ (WalLogSource::File(f), len)
+ }
+ Medium::Block(_) => {
+ let bytes = self.medium.read("wal.log").map_err(io_err)?;
+ let len = bytes.len() as u64;
+ (WalLogSource::Object(std::io::Cursor::new(bytes)), len)
+ }
+ };
let mut offset = 0u64;
while offset < file_len {
@@ -2492,7 +2573,7 @@ impl SynapseStore {
recovery_policy: RecoveryPolicy,
overlap: &mut CheckpointOverlap,
) -> SynapseResult<()> {
- let ids = segment::list_segments(&self.root_dir)?;
+ let ids = self.medium.list_segments()?;
if !self.v2_mode {
for &id in &ids {
if self.segment_has_data(id)? {
@@ -2508,8 +2589,8 @@ impl SynapseStore {
return Ok(());
}
let (start_seg, start_off) = if self.log_layout == LogLayout::Segments {
- let binding = segment::checkpoint_binding(&self.root_dir)?;
- let index = segment::SegmentIndex::load(&self.root_dir, &binding)?;
+ let binding = segment::checkpoint_binding_on(&self.medium)?;
+ let index = segment::SegmentIndex::load_from(&self.medium, &binding)?;
self.blob_locations = index.entries.clone();
if (index.replay_segment, index.replay_offset) != (1, 0) {
// The index vouches for every segment byte before its replay position:
@@ -2555,20 +2636,12 @@ impl SynapseStore {
};
self.wal_v2_recovered_end = (start_seg, start_off);
for id in start_seg..=max {
- let path = self.root_dir.join(segment::segment_file_name(id));
- if !path.exists() {
- break;
- }
let base = if id == start_seg { start_off } else { 0 };
- let buf = {
- let mut f = File::open(&path).map_err(io_err)?;
- f.seek(SeekFrom::Start(base)).map_err(io_err)?;
- let mut b = Vec::new();
- f.read_to_end(&mut b).map_err(io_err)?;
- b
+ let Some(buf) = self.medium.read_segment_from(id, base)? else {
+ break;
};
let (end, holds_data, truncated) =
- self.replay_segment(id, &path, base, &buf, max, recovery_policy, overlap)?;
+ self.replay_segment(id, base, &buf, max, recovery_policy, overlap)?;
if holds_data || id == start_seg {
self.wal_v2_recovered_end = (id, end);
}
@@ -2596,7 +2669,6 @@ impl SynapseStore {
fn replay_segment(
&mut self,
id: u64,
- path: &Path,
base: u64,
buf: &[u8],
max: u64,
@@ -2728,13 +2800,13 @@ impl SynapseStore {
))
}
RecoveryPolicy::TruncateTornTail => {
- use std::os::unix::fs::FileExt;
let last_nonzero = buf.iter().rposition(|b| *b != 0).unwrap_or(off);
let end = wal2::align_up(last_nonzero as u64 + 1) as usize;
- let f = OpenOptions::new().write(true).open(path).map_err(io_err)?;
- f.write_all_at(&vec![0u8; end - off], base + off as u64)
- .map_err(io_err)?;
- f.sync_data().map_err(io_err)?;
+ self.medium.zero_segment_range(
+ id,
+ base + off as u64,
+ base + end as u64,
+ )?;
self.torn_frames_truncated_on_open += 1;
return Ok((base + off as u64, true, true));
}
@@ -2747,7 +2819,7 @@ impl SynapseStore {
fn handle_torn_tail(
&mut self,
- f: &mut File,
+ f: &mut WalLogSource,
valid_offset: u64,
recovery_policy: RecoveryPolicy,
reason: &str,
@@ -2758,8 +2830,16 @@ impl SynapseStore {
format!("{reason} at byte offset {valid_offset}"),
)),
RecoveryPolicy::TruncateTornTail => {
- f.set_len(valid_offset).map_err(io_err)?;
- f.sync_all().map_err(io_err)?;
+ match f {
+ WalLogSource::File(f) => {
+ f.set_len(valid_offset).map_err(io_err)?;
+ f.sync_all().map_err(io_err)?;
+ }
+ WalLogSource::Object(c) => {
+ let keep = c.get_ref()[..valid_offset as usize].to_vec();
+ self.medium.write_atomic("wal.log", &keep)?;
+ }
+ }
self.torn_frames_truncated_on_open += 1;
Ok(())
}
@@ -2767,6 +2847,30 @@ impl SynapseStore {
}
}
+/// `wal.log` as recovery reads it: the file (A2) or the bytes of the metadata object (R1).
+enum WalLogSource {
+ File(File),
+ Object(std::io::Cursor>),
+}
+
+impl Read for WalLogSource {
+ fn read(&mut self, buf: &mut [u8]) -> std::io::Result {
+ match self {
+ WalLogSource::File(f) => f.read(buf),
+ WalLogSource::Object(c) => c.read(buf),
+ }
+ }
+}
+
+impl Seek for WalLogSource {
+ fn seek(&mut self, pos: SeekFrom) -> std::io::Result {
+ match self {
+ WalLogSource::File(f) => f.seek(pos),
+ WalLogSource::Object(c) => c.seek(pos),
+ }
+ }
+}
+
/// Log frames that `checkpoint.v1` already covers, met at the start of replay.
///
/// A crash after the checkpoint is renamed into place but before `wal.log` (and, in the
diff --git a/crates/synapse-store/src/segment.rs b/crates/synapse-store/src/segment.rs
index f46c0d1..9d14765 100644
--- a/crates/synapse-store/src/segment.rs
+++ b/crates/synapse-store/src/segment.rs
@@ -28,6 +28,7 @@
use super::*;
use std::os::unix::fs::FileExt;
+use std::sync::Arc;
/// Marker frame version in `wal.log` for the segment layout (version 2 is the WAL v2
/// marker of the single-file layout). Binaries that predate A2 refuse version 3
@@ -106,17 +107,21 @@ pub(crate) fn binding_of(checkpoint: Option<(&str, &[u8])>) -> [u8; 32] {
h.finalize().into()
}
-/// Binding of the checkpoint on disk: `checkpoint.v2` when present, else a
-/// `checkpoint.v1` that is not the tombstone, else none.
+/// Binding of the checkpoint in a store directory (see [`checkpoint_binding_on`]).
+#[cfg(test)]
pub(crate) fn checkpoint_binding(root: &Path) -> SynapseResult<[u8; 32]> {
- let v2 = root.join(codec::CHECKPOINT_V2_FILE);
- if v2.exists() {
- let bytes = fs::read(&v2).map_err(io_err)?;
+ checkpoint_binding_on(&Medium::Dir(root.to_path_buf()))
+}
+
+/// Binding of the checkpoint on the medium: `checkpoint.v2` when present, else a
+/// `checkpoint.v1` that is not the tombstone, else none.
+pub(crate) fn checkpoint_binding_on(m: &Medium) -> SynapseResult<[u8; 32]> {
+ if m.exists(codec::CHECKPOINT_V2_FILE) {
+ let bytes = m.read(codec::CHECKPOINT_V2_FILE).map_err(io_err)?;
return Ok(binding_of(Some((codec::CHECKPOINT_V2_FILE, &bytes))));
}
- let v1 = root.join("checkpoint.v1");
- if v1.exists() {
- let bytes = fs::read(&v1).map_err(io_err)?;
+ if m.exists("checkpoint.v1") {
+ let bytes = m.read("checkpoint.v1").map_err(io_err)?;
if bytes != codec::v1_tombstone_bytes() {
return Ok(binding_of(Some(("checkpoint.v1", &bytes))));
}
@@ -235,22 +240,24 @@ impl SegmentIndex {
})
}
- /// Write atomically (temp file, sync, rename, directory sync); returns the file name.
- pub fn write(&self, root: &Path) -> SynapseResult {
+ /// Write atomically (A2: temp file, sync, rename, directory sync; R1: one metadata
+ /// commit); returns the file name.
+ pub fn write(&self, m: &Medium) -> SynapseResult {
let name = Self::file_name(&self.binding);
- write_file_atomic(
- root,
- &root.join(format!("{name}.tmp")),
- &root.join(&name),
- &self.encode(),
- )?;
+ m.write_atomic(&name, &self.encode())?;
Ok(name)
}
- /// Load the index bound to `binding` (`CheckpointCorrupt` when missing or invalid).
+ /// Load the index bound to `binding` from a store directory.
+ #[cfg(test)]
pub fn load(root: &Path, binding: &[u8; 32]) -> SynapseResult {
+ Self::load_from(&Medium::Dir(root.to_path_buf()), binding)
+ }
+
+ /// Load the index bound to `binding` (`CheckpointCorrupt` when missing or invalid).
+ pub fn load_from(m: &Medium, binding: &[u8; 32]) -> SynapseResult {
let name = Self::file_name(binding);
- let bytes = fs::read(root.join(&name)).map_err(|e| {
+ let bytes = m.read(&name).map_err(|e| {
index_corrupt(&format!(
"{name} for the checkpoint on disk cannot be read: {e}"
))
@@ -267,7 +274,15 @@ impl SegmentIndex {
/// Remove every segment index file (and leftover temp file) except `keep`. Index files
/// are metadata: this never touches segment data.
-pub(crate) fn remove_other_indexes(root: &Path, keep: &str) -> SynapseResult<()> {
+pub(crate) fn remove_other_indexes(m: &Medium, keep: &str) -> SynapseResult<()> {
+ let root = match m {
+ Medium::Dir(root) => root,
+ Medium::Block(dev) => {
+ dev.remove_named_where(|n| n.starts_with(SEGMENT_INDEX_PREFIX) && n != keep)
+ .map_err(io_err)?;
+ return Ok(());
+ }
+ };
let mut removed = false;
for entry in fs::read_dir(root).map_err(io_err)? {
let entry = entry.map_err(io_err)?;
@@ -313,10 +328,11 @@ pub(crate) enum SegEvent {
BatchDurable(u64),
}
-/// Writer of the active segment, rotating to new segment files.
+/// Writer of the active segment, rotating to new segments (files in A2, device slots in
+/// R1).
#[derive(Debug)]
pub(crate) struct SegmentLog {
- root: PathBuf,
+ medium: Medium,
active: u64,
writer: wal2::WalV2Writer,
segment_bytes: u64,
@@ -327,14 +343,19 @@ pub(crate) struct SegmentLog {
impl SegmentLog {
/// Open the active segment `active` with the log ending at `write_offset`. The file
- /// is synced and the directory flushed before anything is written into it.
+ /// is synced and the directory flushed before anything is written into it (R1: the
+ /// device is flushed, and a slot past the committed count is created first).
pub fn open(
- root: &Path,
+ medium: &Medium,
active: u64,
write_offset: u64,
segment_bytes: u64,
chunk: u64,
) -> SynapseResult {
+ let root = match medium {
+ Medium::Dir(root) => root,
+ Medium::Block(dev) => return Self::open_block(medium, dev, active, write_offset),
+ };
let segment_bytes = segment_bytes.max(wal2::WAL_V2_ALIGN);
let chunk = chunk.min(segment_bytes);
let path = root.join(segment_file_name(active));
@@ -345,7 +366,7 @@ impl SegmentLog {
writer.sync_all()?;
sync_dir(root)?;
Ok(Self {
- root: root.to_path_buf(),
+ medium: medium.clone(),
active,
writer,
segment_bytes,
@@ -355,6 +376,68 @@ impl SegmentLog {
})
}
+ fn open_block(
+ medium: &Medium,
+ dev: &Arc,
+ active: u64,
+ write_offset: u64,
+ ) -> SynapseResult {
+ let segment_bytes = dev.geometry().segment_bytes;
+ let mut log = Self {
+ medium: medium.clone(),
+ active,
+ writer: wal2::WalV2Writer::on_block(dev.clone(), active, write_offset, segment_bytes),
+ segment_bytes,
+ chunk: segment_bytes,
+ #[cfg(test)]
+ trace: Vec::new(),
+ };
+ if active > dev.segment_count() {
+ // A new store, or a slot a rotation created but never committed.
+ log.create_block_slot(dev, active, RotationFault::None)
+ .map_err(io_err)?;
+ } else {
+ dev.flush().map_err(io_err)?;
+ #[cfg(test)]
+ log.trace
+ .extend([SegEvent::FileSynced(active), SegEvent::DirSynced(active)]);
+ }
+ Ok(log)
+ }
+
+ /// R1 rotation: header, zero the slot and `fdatasync`, then commit the segment count
+ /// in the superblock (`fdatasync`).
+ fn create_block_slot(
+ &mut self,
+ dev: &blockdev::BlockDevice,
+ id: u64,
+ fault: RotationFault,
+ ) -> std::io::Result<()> {
+ // Zero and flush before the header goes in: a valid header then always sits on a
+ // zeroed slot, so data under a valid header past the committed count can only
+ // be acknowledged batches (`BlockDevice::refuse_data_past_segment_count`).
+ dev.zero_segment(id)?;
+ dev.write_segment_header(id)?;
+ #[cfg(test)]
+ self.trace.push(SegEvent::Created(id));
+ dev.flush()?;
+ #[cfg(test)]
+ self.trace.push(SegEvent::FileSynced(id));
+ match fault {
+ RotationFault::None => {}
+ RotationFault::CrashBeforeDirSync { code } => std::process::exit(code),
+ RotationFault::FailDirSync => {
+ return Err(std::io::Error::other(
+ "injected fault: directory flush failed",
+ ))
+ }
+ }
+ dev.commit_segment(id)?;
+ #[cfg(test)]
+ self.trace.push(SegEvent::DirSynced(id));
+ Ok(())
+ }
+
pub fn active(&self) -> u64 {
self.active
}
@@ -384,6 +467,18 @@ impl SegmentLog {
format!("create segment {id}: {e}"),
))
};
+ let root = match &self.medium {
+ Medium::Dir(root) => root.clone(),
+ Medium::Block(dev) => {
+ let dev = dev.clone();
+ // A slot with this id past the committed count was never data: it is
+ // given a header and zeroed again.
+ self.create_block_slot(&dev, id, fault).map_err(fail)?;
+ self.writer = wal2::WalV2Writer::on_block(dev, id, 0, self.segment_bytes);
+ self.active = id;
+ return Ok((id, 0));
+ }
+ };
// A file with this id can only be one an earlier failed rotation of this
// process created (or an all-zero one recovery verified): never acknowledged
// data, so it is truncated and pre-written again.
@@ -392,7 +487,7 @@ impl SegmentLog {
.truncate(true)
.read(true)
.write(true)
- .open(self.root.join(segment_file_name(id)))
+ .open(root.join(segment_file_name(id)))
.map_err(fail)?;
#[cfg(test)]
self.trace.push(SegEvent::Created(id));
@@ -409,9 +504,7 @@ impl SegmentLog {
)))
}
}
- File::open(&self.root)
- .and_then(|d| d.sync_all())
- .map_err(fail)?;
+ File::open(&root).and_then(|d| d.sync_all()).map_err(fail)?;
#[cfg(test)]
self.trace.push(SegEvent::DirSynced(id));
self.writer = writer;
@@ -438,9 +531,23 @@ impl SegmentLog {
}
}
-/// Read `len` bytes at `offset` of an open segment file.
-pub(crate) fn read_at(f: &File, offset: u64, len: u32) -> std::io::Result> {
- let mut bytes = vec![0u8; len as usize];
- f.read_exact_at(&mut bytes, offset)?;
- Ok(bytes)
+/// A read handle on one segment, for inline blob reads.
+#[derive(Debug)]
+pub(crate) enum SegReader {
+ File(File),
+ Block(Arc, u64),
+}
+
+impl SegReader {
+ /// Read `len` bytes at `offset` of the segment.
+ pub fn read_at(&self, offset: u64, len: u32) -> std::io::Result> {
+ match self {
+ SegReader::File(f) => {
+ let mut bytes = vec![0u8; len as usize];
+ f.read_exact_at(&mut bytes, offset)?;
+ Ok(bytes)
+ }
+ SegReader::Block(dev, id) => dev.read_segment_at(*id, offset, len),
+ }
+ }
}
diff --git a/crates/synapse-store/src/shared.rs b/crates/synapse-store/src/shared.rs
index e121385..923ff53 100644
--- a/crates/synapse-store/src/shared.rs
+++ b/crates/synapse-store/src/shared.rs
@@ -150,6 +150,16 @@ impl SharedStore {
SynapseStore::open(root_dir, fsync_policy, recovery_policy, limits).map(Self::new)
}
+ /// Open a store on a raw block device ([`SynapseStore::open_block_device`]).
+ pub fn open_block_device(
+ cfg: &crate::BlockDeviceConfig,
+ fsync_policy: FsyncPolicy,
+ recovery_policy: RecoveryPolicy,
+ limits: StoreLimits,
+ ) -> SynapseResult {
+ SynapseStore::open_block_device(cfg, fsync_policy, recovery_policy, limits).map(Self::new)
+ }
+
/// Read committed state. Not blocked by a batch write in progress.
pub fn read(&self) -> RwLockReadGuard<'_, SynapseStore> {
self.state.read().unwrap_or_else(|e| e.into_inner())
diff --git a/crates/synapse-store/src/wal2.rs b/crates/synapse-store/src/wal2.rs
index 0b590c2..b163102 100644
--- a/crates/synapse-store/src/wal2.rs
+++ b/crates/synapse-store/src/wal2.rs
@@ -453,10 +453,46 @@ pub(crate) enum BatchFailure {
Poisoned(SynapseError),
}
+/// The file a [`WalV2Writer`] writes: a segment file (A2) or a segment slot of a raw
+/// block device (R1).
+#[derive(Debug)]
+pub(crate) enum SegFile {
+ Fs(File),
+ Block {
+ dev: std::sync::Arc,
+ id: u64,
+ },
+}
+
+impl SegFile {
+ fn write_all_at(&self, buf: &[u8], at: u64) -> std::io::Result<()> {
+ match self {
+ SegFile::Fs(f) => f.write_all_at(buf, at),
+ SegFile::Block { dev, id } => dev.write_segment(*id, at, buf),
+ }
+ }
+
+ /// `fdatasync` (R1: of the whole device).
+ fn sync_data(&self) -> std::io::Result<()> {
+ match self {
+ SegFile::Fs(f) => f.sync_data(),
+ SegFile::Block { dev, .. } => dev.flush(),
+ }
+ }
+
+ /// `fsync` data and size (R1: `fdatasync` of the device; a slot has a fixed size).
+ fn sync_all(&self) -> std::io::Result<()> {
+ match self {
+ SegFile::Fs(f) => f.sync_all(),
+ SegFile::Block { dev, .. } => dev.flush(),
+ }
+ }
+}
+
/// Writer for `wal.v2.log`.
#[derive(Debug)]
pub(crate) struct WalV2Writer {
- file: File,
+ file: SegFile,
pub write_offset: u64,
pub prewritten_end: u64,
chunk: u64,
@@ -488,7 +524,7 @@ impl WalV2Writer {
}
let len = file.metadata().map_err(io_err)?.len();
let mut w = Self {
- file,
+ file: SegFile::Fs(file),
write_offset,
prewritten_end: len.max(write_offset),
chunk: chunk.max(WAL_V2_ALIGN),
@@ -501,7 +537,7 @@ impl WalV2Writer {
/// A writer over a newly created, empty segment file (nothing pre-written yet).
pub fn new_empty(file: File, chunk: u64, prewrite_cap: u64) -> Self {
Self {
- file,
+ file: SegFile::Fs(file),
write_offset: 0,
prewritten_end: 0,
chunk: chunk.max(WAL_V2_ALIGN),
@@ -509,6 +545,24 @@ impl WalV2Writer {
}
}
+ /// A writer over segment slot `id` of a raw block device (R1) with the log ending at
+ /// `write_offset`. The slot was zeroed and flushed when it was created, so the whole
+ /// slot counts as pre-written; a batch past its end is refused.
+ pub fn on_block(
+ dev: std::sync::Arc,
+ id: u64,
+ write_offset: u64,
+ segment_bytes: u64,
+ ) -> Self {
+ Self {
+ file: SegFile::Block { dev, id },
+ write_offset,
+ prewritten_end: segment_bytes,
+ chunk: segment_bytes.max(WAL_V2_ALIGN),
+ prewrite_cap: segment_bytes,
+ }
+ }
+
/// Stop pre-writing ahead past `cap` bytes (a batch that needs more still gets it).
pub fn set_prewrite_cap(&mut self, cap: u64) {
self.prewrite_cap = cap.max(WAL_V2_ALIGN);
@@ -519,6 +573,12 @@ impl WalV2Writer {
if self.write_offset + need <= self.prewritten_end {
return Ok(());
}
+ if let SegFile::Block { id, .. } = &self.file {
+ return Err(std::io::Error::other(format!(
+ "a batch of {need} bytes at offset {} does not fit segment slot {id} of {} bytes",
+ self.write_offset, self.prewritten_end
+ )));
+ }
let ahead = (self.prewritten_end + self.chunk).min(self.prewrite_cap);
let target = align_up((self.write_offset + need).max(ahead));
let zeros = vec![0u8; 1 << 20];
diff --git a/docs/R1_RAW_BLOCK_STORE.md b/docs/R1_RAW_BLOCK_STORE.md
new file mode 100644
index 0000000..b0ada3a
--- /dev/null
+++ b/docs/R1_RAW_BLOCK_STORE.md
@@ -0,0 +1,327 @@
+# R1: Segment Store on a Raw Block Device (AIENOS Block-Store Specification)
+
+ADR 0003 section 9 step 27 (issue #47). R1 runs the A2 segment store (`docs/A2_SEGMENT_STORE.md`) on one
+byte range of a block device with no filesystem under it. The store above the device is unchanged: the
+same WAL v2 batches, the same segment index, the same checkpoint, the same recovery rules. What changes
+is where the bytes live and what replaces the filesystem's guarantees (file creation, atomic rename,
+directory flush). This document is the on-device format AIENOS implements; the code is
+`crates/synapse-store/src/blockdev.rs`.
+
+Status: implemented and tested on a preallocated regular file opened with `O_DIRECT`. Not yet run on a
+real raw partition (section 7).
+
+## 1. The Device
+
+- **One path, named by the caller.** `BlockDeviceConfig::path` must be absolute. The store opens that
+ path and nothing else: no `/dev` scan, no globbing, no derived or temporary paths, never creates it.
+ Symlinks are refused (`O_NOFOLLOW`, plus a `symlink_metadata` check). The path must be a regular file
+ or a block device; a block device is opened `O_EXCL` (the kernel refuses it while it is mounted or held
+ by another exclusive user). After opening, the device and inode numbers are compared with the checked
+ path, so a swap between check and open is refused.
+- **One opener.** The open takes an exclusive `flock` on the descriptor (non-blocking); a second opener,
+ in this process or another, is refused with "in use" while the first holds it. This covers regular
+ files, where `O_EXCL` means nothing.
+- **Formatting is never the default.** `BlockDeviceConfig::new` uses `FormatPolicy::OpenExisting`; the
+ caller must ask for `FormatIfBlank`.
+- **`O_DIRECT`.** Every read and write bypasses the page cache. Transfers are 4 KiB aligned in offset,
+ length, and buffer address (an aligned bounce buffer in safe Rust). A write that is not block aligned
+ is done as read, modify, write of the covering blocks.
+- **Length.** The device length must be a multiple of 4 KiB and hold the label area, two metadata
+ regions, and at least two segment slots.
+
+### 1.1 Refusing a disk that is not ours
+
+Before anything is written, the device is classified (`classify_device`) from its label area (the first
+128 KiB) and from fixed offsets near its end:
+
+| Label | Meaning | Action |
+| :--- | :--- | :--- |
+| Synapse | The R1 superblock magic at byte 0 or 4096 | Mount (section 4 validates the copies) |
+| Blank | Every byte of the label area is zero | Format only with `FormatPolicy::FormatIfBlank`, else refuse |
+| Foreign | A signature from the table below, at the start or the end of the device | Refuse (`CapacityRefused`, names the signature) |
+| Unknown | Any other non-zero byte | Refuse |
+
+The Synapse magic is checked first, then `SIGNATURES` in order (MBR last, so a GPT disk is named GPT).
+`L` is the device length:
+
+| Signature | Where |
+| :--- | :--- |
+| GPT header / backup header | `EFI PART` at 512 and 4096; backup at `L - 512` and `L - 4096` |
+| ext2/3/4 | `53 EF` at 1080 |
+| XFS, LUKS, squashfs | `XFSB`, `LUKS BA BE`, `hsqs` at 0 |
+| btrfs | `_BHRfS_M` at 0x10040 and its mirrors at 64 MiB + 0x40 and 256 GiB + 0x40 |
+| NTFS, exFAT | OEM id at 3 |
+| FAT12/16, FAT32 | `FAT1` at 54, `FAT32` at 82 |
+| LVM2 | `LABELONE` in any of sectors 0 to 3 |
+| Linux swap | `SWAPSPACE2` at page end minus 10 for 4, 16, 64 KiB pages; `SWAP-SPACE` for 4 KiB |
+| ISO 9660 | `CD001` at 0x8001 |
+| F2FS | `10 20 F5 F2` at 1024 |
+| MD RAID 1.2, 1.1 | `FC 4E 2B A9` at 4096, at 0 |
+| MD RAID 1.0 | same magic at `(L - 8 KiB)` rounded down to 4 KiB |
+| MD RAID 0.90 | same magic at `L` rounded down to 64 KiB, minus 64 KiB |
+| ZFS labels L0 to L3 | an uberblock magic (either byte order) in a 1 KiB slot of the uberblock array (label + 128 KiB) of the 256 KiB labels at 0, 256 KiB, and at `L'` - 512 KiB, `L'` - 256 KiB, where `L'` is `L` rounded down to 256 KiB |
+| MBR / boot sector | `55 AA` at 510 |
+
+Each entry has its own test that builds a device with only that signature and expects it named, plus a
+test that the table has exactly that many entries, so deleting or changing one turns a test red. A Foreign or Unknown device is formatted only when the caller sets
+`allow_foreign_signature: true` and `FormatPolicy::FormatIfBlank`; the refusal leaves the device
+byte-for-byte unchanged (tested).
+
+## 2. On-Device Layout
+
+All integers little-endian. Block size 4,096 bytes.
+
+| Range | Content |
+| :--- | :--- |
+| `0 .. 4 KiB` | Superblock copy 0 |
+| `4 KiB .. 8 KiB` | Superblock copy 1 |
+| `8 KiB .. 128 KiB` | Zero (part of the label area that the signature check reads) |
+| `1 MiB .. 1 MiB + M` | Metadata region 0 (`M = meta_region_bytes`, default 64 MiB, 4 KiB multiple) |
+| `1 MiB + M .. 1 MiB + 2M` | Metadata region 1 |
+| `data_offset ..` (1 MiB aligned) | Segment slots 1, 2, ... each `slot_stride = 4 KiB + segment_bytes` |
+
+### 2.1 Superblock
+
+The first 164 bytes of its 4 KiB block; the rest of the block is zero.
+
+| Offset | Size | Field |
+| ---: | ---: | :--- |
+| 0 | 8 | magic `SYNBLKS1` |
+| 8 | 4 | format version (1) |
+| 12 | 4 | block size (4096) |
+| 16 | 16 | device uuid (random at format) |
+| 32 | 8 | generation |
+| 40 | 8 | device_bytes |
+| 48 | 8 | meta_offset0 |
+| 56 | 8 | meta_offset1 |
+| 64 | 8 | meta_region_bytes |
+| 72 | 8 | data_offset |
+| 80 | 8 | slot_stride |
+| 88 | 8 | segment_bytes |
+| 96 | 8 | slot_count |
+| 104 | 8 | segment_count (committed segments) |
+| 112 | 8 | meta_len (bytes of namespace in the active region) |
+| 120 | 1 | meta_slot (active region, 0 or 1) |
+| 121 | 7 | zero |
+| 128 | 32 | meta_sha256 = SHA-256 of `"SYNAPSE_BLOCK_META_V1\0"` followed by the namespace bytes |
+| 160 | 4 | CRC-32C of bytes 0..160 |
+
+Decoding is strict: wrong magic, version, block size, CRC, a geometry that does not fit the device,
+regions that overlap, `segment_count > slot_count`, or non-zero padding make the copy invalid.
+Generation `g` is always written to copy `g % 2`, so the newest copy and the one before it are both on
+the device.
+
+### 2.2 Metadata region (the namespace)
+
+The A2 store keeps a few small files next to its segments: `wal.log` (the segment marker),
+`checkpoint.v2`, `checkpoint.v1` (tombstone), and `wal.v2.index.<16-hex>`. On the device these are named
+objects in one namespace, stored whole in a metadata region:
+
+```
+"SBM1" | u32 count | count x ( u16 name_len | name (UTF-8) | u64 len | bytes )
+```
+
+Names are strictly increasing. The active region is the one the newest valid superblock names; its
+digest is in the superblock.
+
+### 2.3 Segment slot
+
+```
+4 KiB header: "SBSG" | u32 version (1) | uuid[16] | u64 segment id | u64 segment_bytes | u32 CRC-32C
+then segment_bytes of WAL v2 batches (crate::wal2), byte-for-byte the A2 segment file contents
+```
+
+Slot `k` holds segment id `k`. A header is valid only with the right magic, version, CRC, this device's
+uuid, id `k`, and the superblock's `segment_bytes`, so a header left over from an earlier format of the
+same disk is not data.
+
+## 3. Durability Ordering
+
+Every step ends with one `fdatasync` of the device descriptor. On a raw block device that is a FLUSH of
+the drive's volatile write cache; on the file-backed test device it is `fdatasync` of the file.
+
+1. **Format.** Write an empty namespace into metadata region 0, then the label area (zeros, with
+ superblock generation 1, `segment_count` 0, naming region 0, in copy 1), flush.
+2. **Metadata commit** (replaces A2's "write temporary file, sync, rename, sync directory"). Write the
+ whole new namespace into the region the current superblock does *not* name; write superblock
+ generation `g + 1` (naming that region, with its digest) into copy `(g + 1) % 2`; flush. A commit
+ that changes only `segment_count` writes only the superblock.
+3. **Segment rotation** (replaces A2's "create file, sync, sync directory"). Zero the whole data area,
+ flush; write the slot header, flush; then a metadata commit raises `segment_count` to the new id,
+ flush. Only then is a batch written into the slot. The order matters: a valid header is only ever
+ written over a data area that is already durably zero, so a valid header past `segment_count` with
+ non-zero data can only mean acknowledged batches whose commit record was lost (section 4, step 3).
+4. **Batch** (unchanged from A2). One aligned positioned write of the batch into the active slot, one
+ flush. A change is acknowledged only after that flush returned success.
+
+Why one flush per commit is enough: if power fails after the region write but before the superblock is
+durable, the old superblock names the old region, which was not touched. If the superblock is durable
+but part of the region is not (the drive reordered the writes inside the flush window), the region's
+SHA-256 does not match the superblock, so recovery skips that copy and takes the older one, whose region
+is intact. A torn superblock fails its CRC and is skipped the same way.
+
+A failed flush acknowledges nothing (tested: the batch and every later ingest return errors).
+
+## 4. Recovery
+
+1. Read both superblock copies. Take the one with the highest generation whose CRC holds and whose
+ active region matches `meta_sha256`. If it fails, take the other. If both fail, or the two copies disagree on the
+ geometry, refuse (`CheckpointCorrupt`).
+2. The namespace in that region supplies `wal.log`, `checkpoint.v2`, `checkpoint.v1`, and the segment
+ index exactly as the A2 files would.
+3. Segments 1..=`segment_count` are data. Slot `segment_count + 1` is listed only if its header is
+ valid (a rotation that crashed before its superblock commit); it is then treated as A2 treats a last
+ segment file that is all zero. If that slot's header is valid and its data area holds any non-zero
+ byte, the superblock in use is older than the data on the device (the newest copy was damaged, so
+ acknowledged batches in that slot would be dropped): mount refuses with `CheckpointCorrupt` and
+ names the slot, under strict and truncating recovery alike. Slots beyond are ignored; their bytes may
+ be stale and the next rotation zeroes them.
+4. From there the A2 rules apply unchanged: index bound to the checkpoint by SHA-256, torn tail accepted
+ only in the last segment holding data (strict recovery refuses it as `WalTornFrame`, truncating
+ recovery zeroes it on the device and flushes), any damage elsewhere fails closed.
+
+A device that is full refuses the batch that would need a new slot ("device full") and keeps every
+acknowledged change.
+
+## 5. Acceptance and Tests
+
+| Test | What it proves |
+| :--- | :--- |
+| A2 crash suite, `segment_tests.rs`, compiled a second time unchanged in `blockdev_a2_suite.rs` (11 tests, 9 of which touch the device; see section 7) | Every A2 crash, damage, and recovery case passes on the device. The suite's file operations get a device meaning (a segment file is a slot's data area, deleting it erases the slot header, small files are named objects); crash children reopen through the same device. |
+| `r1_suite_stores_are_raw_block_stores` | Control: the stores that suite opens hold only the device file; segments and metadata are on the device. |
+| `r1_power_cut_at_every_write_boundary_keeps_every_ack` | Power-cut simulation, below. |
+| `r1_refuses_a_device_carrying_a_filesystem_or_partition_signature` | ext4, GPT, XFS, LUKS images are refused and left unchanged; the explicit override formats. |
+| `r1_refuses_a_device_whose_signature_is_only_at_its_end` | GPT backup, MD 0.90, MD 1.0, ZFS L2 and L3 placed only at the end of a zeroed device are refused and the device is left unchanged. |
+| `r1_sig_*` (38) and `r1_every_signature_has_a_pin_test` | One test per `SIGNATURES` entry (a sparse 300 GiB device carrying only that magic at its offset), and the table length pinned. |
+| `r1_lost_newest_superblock_never_drops_acknowledged_changes` | 10 acknowledged changes over two slots, newest superblock copy damaged: reopen either refuses with `CheckpointCorrupt` or returns all 10, under both recovery modes; never fewer. |
+| `r1_a_second_opener_of_the_device_is_refused` | A second open while the store holds the device is refused ("in use"). |
+| `r1_refuses_unknown_label_bytes_and_blank_devices_without_format` | Unknown bytes refused; a blank device is not formatted without `FormatIfBlank`. |
+| `r1_opens_only_the_configured_path` | Relative path, directory, symlink, missing path (not created), odd length refused; unaligned writes round-trip through `O_DIRECT`. |
+| `r1_classifies_known_signatures` | Blank, Unknown, Synapse (magic in copy 1 only), and GPT named before MBR on a protective-MBR disk. |
+| `r1_superblock_falls_back_to_the_older_copy_when_the_newest_is_damaged` | Damaged newest superblock or region: mount uses the older copy. |
+| `r1_full_device_refuses_the_batch_and_keeps_every_ack` | Two slots: "device full" refusal, all 16 acknowledged changes kept. |
+| `r1_failed_device_flush_acknowledges_nothing` | A flush error acknowledges nothing. |
+| bench `block_device_bench_never_writes_to_a_file_it_did_not_create` | `--block-device` on an existing file carrying an ext4 magic, or on a symlink to it, is refused and the file is unchanged. |
+| bench `block_device_bench_creates_formats_and_removes_its_own_device` | The bench creates its device file, formats it, runs, and removes it. |
+
+### 5.1 Power-cut simulation
+
+An in-memory device records every write and flush of a workload: format, 20 commits across three
+segments, a checkpoint, 6 more commits, reopen, 2 more commits (56 device writes, 50 flushes, 28
+acknowledgements). The bytes outside the label area start as pseudo-random garbage (a disk used before).
+For every write the device image is cut while that write is in flight, four ways, at every 512-byte
+sector boundary:
+
+- **prefix**: the first k sectors of the write landed;
+- **suffix**: the last k sectors landed;
+- **lost write**: one write issued since the last completed flush never landed (the drive reordered);
+- **hole**: the write landed except one middle sector, which keeps its old bytes.
+
+Each image is recovered with truncating and with strict recovery. Required: every change acknowledged
+before the cut is present and readable, nothing beyond what was written appears, and the recovered store
+keeps working (every 23rd image commits again and reopens).
+
+Result: prefix 1,465 images, 1,448 opened; suffix 1,464, 1,208 opened; lost write 64, 61 opened; every
+image that did not open was cut before the first acknowledgement (the format had not completed, nothing
+promised). No acknowledged change was lost in any image. Strict recovery refused 336 + 336 images as
+`WalTornFrame` (a torn tail), never any other way. Hole images: 1,352, 1,037 opened, 297 failed closed
+with an error and 0 lost an acknowledged change silently; a hole in the middle of a batch is damage the
+A2 format cannot tell from corruption, so failing closed is the A2 behaviour, and it is never silent.
+
+### 5.2 Red before green
+
+`evidence/r1-raw-block-store/red-green/`: on main the new tests do not compile (no device store); each
+recorded mutation of the R1 code (`mutation-M*.txt`, each with its diff and the failing test) turns a named test red; the branch is green.
+
+## 6. Seconds and Joules per Accepted Change
+
+This section is a performance report. It is not acceptance (section 5 is).
+
+**Method.** The A2 harness (`synapse-bench segments`, `docs/A2_SEGMENT_STORE.md` section 4) unchanged,
+plus `--block-device `: the same workload (N agent threads, 4,000 changesets of one 11,949-byte
+blob each, a checkpoint every 1,000, 16 MiB segments) on the R1 store. Both arms on the same NVMe
+partition (`/dev/nvme0n1p2`, ext4): A2 as files in a directory; R1 on a 512 MiB regular file that the
+bench creates for each cell (`O_CREAT | O_EXCL | O_NOFOLLOW`, written with zeros and synced), the store
+opens with `O_DIRECT` and formats, and the bench removes after the cell. The two arms ran interleaved
+(R1, A2, R1, A2, R1, A2), one repetition per invocation, so both saw the same host conditions; the
+figures are the median and range of the three. Agents 1, 4, 8, 32. The bounds are those of A2 (ADR
+section 6): the flush bound is the cheapest `overwrite_*_fdatasync` p50 measured by `synapse-bench
+floor` in the same session, 0.802 ms (64 KiB); fraction of bound = bound / measured, so 1.0 is at the
+bound.
+
+**Results** (run 2026-10-17T05:45:44Z to 05:50:31Z, branch commit `222c24d`; raw samples
+`evidence/r1-raw-block-store/measurement/raw-{r1,a2}-{0,1,2}.json`, per-invocation reports
+`report-*.json`, aggregate `summary.json`):
+
+| Agents | R1 interval per change (ms) median [range] | A2 on ext4 (ms) median [range] | Interval bound (ms) | R1 fraction | A2 fraction | R1 / A2 median |
+| ---: | :--- | :--- | ---: | ---: | ---: | ---: |
+| 1 | 1.2945 [1.2396, 1.4545] | 1.3858 [1.3796, 1.4494] | 0.8020 | 0.620 | 0.579 | 0.934 (calc:acce0c48) |
+| 4 | 0.5817 [0.5696, 0.6484] | 0.6058 [0.5701, 0.6584] | 0.2005 | 0.345 | 0.331 | 0.960 (calc:aa16356c) |
+| 8 | 0.3271 [0.3170, 0.3271] | 0.3468 [0.3416, 0.3833] | 0.1003 | 0.307 | 0.289 | 0.943 (calc:7358d145) |
+| 32 | 0.1068 [0.1059, 0.1139] | 0.1264 [0.1242, 0.1710] | 0.0251 | 0.235 | 0.198 | 0.845 (calc:c585502f) |
+
+| Agents | R1 latency p50 / p99 (ms) | A2 latency p50 / p99 (ms) | R1 package energy per change (mJ) median [range] | A2 package energy per change (mJ) median [range] | Changes per flush R1 / A2 |
+| ---: | :--- | :--- | :--- | :--- | :--- |
+| 1 | 1.198 / 1.929 | 1.204 / 2.299 | 34.397 [27.943, 37.420] | 37.937 [33.608, 45.635] | 1.00 / 1.00 |
+| 4 | 2.220 / 4.900 | 2.112 / 3.712 | 14.639 [12.228, 17.533] | 16.597 [15.289, 19.674] | 2.31 / 2.19 |
+| 8 | 2.296 / 9.524 | 2.392 / 12.194 | 8.049 [7.626, 11.075] | 9.432 [8.813, 10.506] | 4.02 / 4.09 |
+| 32 | 2.570 / 18.504 | 2.638 / 40.349 | 3.384 [2.774, 3.992] | 4.568 [3.310, 4.648] | 15.94 / 15.81 |
+
+Latency fraction (p50, 1 agent): R1 0.669, A2 0.666. Every cell accepted 4,000 changes, wrote 4
+segments and no blob files. Checkpoints (48 per arm): R1 median 29.3 ms [12.1, 131.1], A2 median
+41.7 ms [30.6, 82.9].
+
+**Is R1 lower?** The R1 median is lower than A2's at every agent count (0.85 to 0.96 of A2). At 8 and
+32 agents all three R1 samples are below all three A2 samples; at 1 and 4 agents the ranges overlap,
+so there the difference is inside the spread. Three samples per arm is a small count; this is the
+file-backed R1 format, not R1 on a raw partition. Package energy per change is also lower for R1 at
+every agent count, but the ranges overlap at 1, 4 and 8 agents, the idle window read 22.6 to 34.4 W
+from other sessions' load, and the meter covers the SoC package only (NVMe unmeasured).
+
+**Did R1 get slower after the review changes?** Not measurably. The rotation order change adds one
+flush per new segment (4 per 4,000-change cell). Against the previous run at `57d1135`, R1's median
+interval is 0.950 of it at 1 agent (calc:54ddff70), 0.978 at 4 (calc:cda8bb34), 1.053 at 8
+(calc:7bfbaa0f) and 0.950 at 32 (calc:64f82441). The two sessions ran under different host load (load
+average 2.4 now, 6 to 8.5 then) and a different flush floor (0.802 vs 0.894 ms), and A2, whose code did
+not change, moved the same way at 8 agents (1.060 of its previous median, calc:b2b6a60a), so the
+cross-session differences are host conditions, not the store. The previous run is kept in
+`evidence/r1-raw-block-store/measurement-57d1135/`.
+
+**This does not decide adoption.** Issue #47 keeps the layer only if it is lower. The R1 arm here is
+the R1 format on a regular file: its `fdatasync` still goes through ext4's block mapping and journal
+path for the file. The deciding measurement, R1 on a dedicated raw partition beside A2 on ext4 on the
+same drive, is owed (section 7).
+
+**Reproduce.**
+
+```sh
+cargo build --release -p synapse-bench
+target/release/synapse-bench floor --dir --out floor.json --iterations 300
+target/release/synapse-bench segments --dir --out raw-r1.json --reps 1 --block-device
+target/release/synapse-bench segments --dir --out raw-a2.json --reps 1
+target/release/synapse-bench segments-report --raw raw-.json --floor floor.json > report-.json
+```
+
+`--block-device` names an absolute path that must not exist; the bench creates the device file there
+for each cell (`--block-device-mib`, `--block-meta-mib` set its size) and removes it afterwards. It
+refuses an existing path or a symlink. `measurement/run.sh` is the exact sequence; `manifest.json`
+records the binary's SHA-256, the host, and the run window; `SHA256SUMS` seals the files.
+
+
+## 7. Limits
+
+- **Not yet measured on a raw partition.** Every R1 figure here is the R1 store on a preallocated
+ regular file on ext4, opened with `O_DIRECT`. The file's blocks still pass through ext4's block mapping
+ and its `fdatasync` path. The true raw-partition measurement is owed (it needs a dedicated partition,
+ which this host does not have spare), so this report cannot by itself decide whether R1 is adopted.
+- **Drive cache power loss is UNVERIFIED.** The ordering assumes a FLUSH makes earlier completed
+ writes durable. No physical power cut was run; the simulation models torn, lost, and holed writes.
+- The lost-write model drops one unflushed write at a time, not every subset.
+- NVMe energy is UNMEASURED; the meter is the SoC package (`aien_spbm`), uncalibrated.
+- 9 of the 11 A2 suite tests touch the device. The other two do not: `a2_segment_index_round_trips_and_refuses_damage`
+ is a pure codec test, and the pre-A2 upgrade test copies directory fixtures (there are no pre-A2 raw
+ block stores), so in the R1 run it exercises the directory store again.
+- A crash during format may leave a device that refuses to open; nothing was acknowledged by then, and
+ the device is reformatted only through an explicit `FormatIfBlank` (and override, if the label area is
+ no longer zero).
+- The device store requires group commit (WAL v2); the v1 per-change WAL is not supported on it.
diff --git a/evidence/r1-raw-block-store/measurement-57d1135/SHA256SUMS b/evidence/r1-raw-block-store/measurement-57d1135/SHA256SUMS
new file mode 100644
index 0000000..abe6fd0
--- /dev/null
+++ b/evidence/r1-raw-block-store/measurement-57d1135/SHA256SUMS
@@ -0,0 +1,25 @@
+e266586f6286fa940da88ebc349d529fa142db209112a933bb0bf6dd56469ce7 a2-0.log
+f95a1f4c6e32cc9a1dd6e23db10505bf3dac2af3765c5be72bba376570db3df7 a2-1.log
+57ab2036f1607e71916819dbafda12afcdd313311dba6aa40a55602d41af0672 a2-2.log
+2658038db04398bf26f416e41146fe3d9102d7bbc9845b755a667a524d87e389 aggregate.sh
+0d62a91b68f156cc5648a0c5d681d862ba46df69385a280586ed0ebfbecc4c73 end.txt
+d177c78c96c40ed37d0c768509d10142a8ccddafb3e312374ac0cd916b7fc457 floor.json
+f3e9389ee33906a041398392caeb098ddb8cd8744fa782225ad3eb9c0039708f manifest.json
+3e09410a9ba6141f5ec4a1593e60d8d967676026c08c686c12dd57fa58bda2c5 r1-0.log
+2e7cb503e4d88c351142625142e4b7acf9fcc6a10a41190cef78afcc4c3dbf87 r1-1.log
+dfb8799e61ed980f3b9ece4b5f300e7468a30dfc877bf8649b7593fb2e3b46a4 r1-2.log
+eed4384ff6e787d33988b3da29bf867035ad7420f4f8e4193983742618660f35 raw-a2-0.json
+a6b3ba276e0c5d65b5f02be2fed5b170454e752170be8c288dc1284b26ce92a9 raw-a2-1.json
+50c3e588f71b583623fa75e3e512b3c4d2f5a5ba40abbf9d4bafe15ac176fe1d raw-a2-2.json
+511f746865c4457378760944222c3e5be00950764dae52d266bd23f1a5063144 raw-r1-0.json
+4fef70e27491bbfe6aa47c0836e133573ffe6c63873989c34fc80b5d58ee2ea7 raw-r1-1.json
+d31597e6434806227b9f3ae1d24d4b2b17f8b3885ebb624c8d8cdfe93b7e9c1a raw-r1-2.json
+f28202c3066cb4bd47ddb01fb6936de9b6ef157e2e5c8a6b45ec82f50e13d85f report-a2-0.json
+d3700aa756dc5b598bfb3a94e7633bf8f31ec99f2e98d6c47658381d2a98f6c6 report-a2-1.json
+8aabf92af0559d127c95ba431db1b6541984c38f065236abcdcfa07f9052072c report-a2-2.json
+baf41f832a73d592737483ab79264fce21df47f457f43344c2ef214e5a15a665 report-r1-0.json
+6f9b3d38ea1c455f4c50a279b537615abff3d586c934fe21675b1e24eb959ac8 report-r1-1.json
+b1a820daa370719d34adfc59648e80b0569a051316cbe810016200a64103b8c8 report-r1-2.json
+40e68495d159a1a342f551d62e4878dcc8fe62e1b16dec939f624efc7bd0b0f9 run.sh
+76a0e038a0de0ed6b6c8f3378eff5a54451d57286bb30d5449e2d28b5371fee8 start.txt
+eeaa16b3824ec54dd5197db35c325c0c1af66f8a8e4091be6520393ab53e0bfc summary.json
diff --git a/evidence/r1-raw-block-store/measurement-57d1135/a2-0.log b/evidence/r1-raw-block-store/measurement-57d1135/a2-0.log
new file mode 100644
index 0000000..2f3d26b
--- /dev/null
+++ b/evidence/r1-raw-block-store/measurement-57d1135/a2-0.log
@@ -0,0 +1,4 @@
+agents 1 rep 0: 4000 accepted in 6.023 s, 4000 batches, 4 segment files
+agents 4 rep 0: 4000 accepted in 2.636 s, 1891 batches, 4 segment files
+agents 8 rep 0: 4000 accepted in 1.362 s, 989 batches, 4 segment files
+agents 32 rep 0: 4000 accepted in 0.522 s, 251 batches, 4 segment files
diff --git a/evidence/r1-raw-block-store/measurement-57d1135/a2-1.log b/evidence/r1-raw-block-store/measurement-57d1135/a2-1.log
new file mode 100644
index 0000000..54de71f
--- /dev/null
+++ b/evidence/r1-raw-block-store/measurement-57d1135/a2-1.log
@@ -0,0 +1,4 @@
+agents 1 rep 0: 4000 accepted in 5.523 s, 4000 batches, 4 segment files
+agents 4 rep 0: 4000 accepted in 2.377 s, 1692 batches, 4 segment files
+agents 8 rep 0: 4000 accepted in 1.309 s, 987 batches, 4 segment files
+agents 32 rep 0: 4000 accepted in 0.483 s, 251 batches, 4 segment files
diff --git a/evidence/r1-raw-block-store/measurement-57d1135/a2-2.log b/evidence/r1-raw-block-store/measurement-57d1135/a2-2.log
new file mode 100644
index 0000000..e3b79ba
--- /dev/null
+++ b/evidence/r1-raw-block-store/measurement-57d1135/a2-2.log
@@ -0,0 +1,4 @@
+agents 1 rep 0: 4000 accepted in 5.559 s, 4000 batches, 4 segment files
+agents 4 rep 0: 4000 accepted in 2.397 s, 1826 batches, 4 segment files
+agents 8 rep 0: 4000 accepted in 1.285 s, 997 batches, 4 segment files
+agents 32 rep 0: 4000 accepted in 0.488 s, 251 batches, 4 segment files
diff --git a/evidence/r1-raw-block-store/measurement-57d1135/aggregate.sh b/evidence/r1-raw-block-store/measurement-57d1135/aggregate.sh
new file mode 100755
index 0000000..11fd6b4
--- /dev/null
+++ b/evidence/r1-raw-block-store/measurement-57d1135/aggregate.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+# Median and range over the three interleaved invocations per arm and agent count.
+set -eu
+O=${1:-$HOME/workspace/r1-bench/out}
+jq -n --slurpfile r1 <(jq -c '.cells[] + {arm:"r1"}' $O/report-r1-*.json) \
+ --slurpfile a2 <(jq -c '.cells[] + {arm:"a2"}' $O/report-a2-*.json) '
+ def med: sort | .[(length/2|floor)];
+ def stat(f): [ .[] | f ] | {median: med, min: min, max: max, samples: .};
+ ($r1 + $a2) | group_by(.arm, .agents) | map({
+ arm: .[0].arm, agents: .[0].agents,
+ interval_ms: stat(.interval_s*1000),
+ interval_bound_ms: (.[0].interval_bound_s*1000),
+ interval_fraction: stat(.interval_fraction),
+ latency_p50_ms: stat(.latency.p50_ms), latency_p99_ms: stat(.latency.p99_ms),
+ latency_fraction_p50: stat(.latency_fraction),
+ pkg_mj_per_change: stat(.pkg_j_per_change*1000),
+ energy_bound_mj: stat(.energy_bound_j*1000),
+ energy_fraction: stat(.energy_fraction),
+ mean_batch: stat(.mean_batch)
+ })'
diff --git a/evidence/r1-raw-block-store/measurement-57d1135/end.txt b/evidence/r1-raw-block-store/measurement-57d1135/end.txt
new file mode 100644
index 0000000..9c28552
--- /dev/null
+++ b/evidence/r1-raw-block-store/measurement-57d1135/end.txt
@@ -0,0 +1,2 @@
+2026-10-17T05:00:32Z
+8.35 8.44 7.54 3/3496 1681385
diff --git a/evidence/r1-raw-block-store/measurement-57d1135/floor.json b/evidence/r1-raw-block-store/measurement-57d1135/floor.json
new file mode 100644
index 0000000..ed9966b
--- /dev/null
+++ b/evidence/r1-raw-block-store/measurement-57d1135/floor.json
@@ -0,0 +1,1071 @@
+{
+ "dir": "/home/drakestapleton/workspace/r1-bench/floor/synapse-floor-1544005",
+ "iterations": 300,
+ "idle": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 5.000342554,
+ "valid": true,
+ "refusal": null,
+ "samples": 52,
+ "largest_gap_ms": 102.894,
+ "pkg_j": 232.136,
+ "cpu_p_j": 109.236,
+ "cpu_e_j": 9.091,
+ "rest_j": 113.809,
+ "pkg_mean_w": 46.42401945328803,
+ "pkg_edge_sd_j": 3.790505315653192,
+ "sys_total_mean_w": 52.98240384615385,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 6.27,
+ 7.16,
+ 6.81
+ ],
+ "loadavg_end": [
+ 6.01,
+ 7.09,
+ 6.79
+ ],
+ "machine_busy_cpu_s": 27.640000000130385
+ },
+ "counter_cadence": {
+ "reads": 116028,
+ "changes": 10,
+ "median_gap_ms": 100.535,
+ "min_gap_ms": 100.518,
+ "max_gap_ms": 100.553
+ },
+ "storage": [
+ {
+ "name": "append_4k_fsync",
+ "description": "append 4 KiB to a growing file, then fsync (today's WAL pattern per frame)",
+ "n": 300,
+ "latency": {
+ "n": 300,
+ "min_ms": 2.586,
+ "p50_ms": 3.698,
+ "p95_ms": 5.049,
+ "p99_ms": 11.584,
+ "max_ms": 11.811,
+ "mean_ms": 3.995
+ },
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 1.198839335,
+ "valid": true,
+ "refusal": null,
+ "samples": 13,
+ "largest_gap_ms": 100.504,
+ "pkg_j": 55.576,
+ "cpu_p_j": 30.844,
+ "cpu_e_j": 2.252,
+ "rest_j": 22.48,
+ "pkg_mean_w": 46.35817192301252,
+ "pkg_edge_sd_j": 3.785128887319943,
+ "sys_total_mean_w": 53.71861538461538,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 6.01,
+ 7.09,
+ 6.79
+ ],
+ "loadavg_end": [
+ 6.01,
+ 7.09,
+ 6.79
+ ],
+ "machine_busy_cpu_s": 7.459999999962747
+ },
+ "pkg_j_per_op": 0.18525333333333333,
+ "pkg_j_per_op_above_idle": -0.00026313536468961727,
+ "error": null
+ },
+ {
+ "name": "append_4k_fdatasync",
+ "description": "append 4 KiB to a growing file, then fdatasync (size change needs a journal commit)",
+ "n": 300,
+ "latency": {
+ "n": 300,
+ "min_ms": 2.573,
+ "p50_ms": 3.491,
+ "p95_ms": 4.204,
+ "p99_ms": 4.508,
+ "max_ms": 6.215,
+ "mean_ms": 3.499
+ },
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 1.050108853,
+ "valid": true,
+ "refusal": null,
+ "samples": 12,
+ "largest_gap_ms": 100.232,
+ "pkg_j": 51.1,
+ "cpu_p_j": 29.207,
+ "cpu_e_j": 1.762,
+ "rest_j": 20.131,
+ "pkg_mean_w": 48.6616219394924,
+ "pkg_edge_sd_j": 3.9732047935993164,
+ "sys_total_mean_w": 53.61333333333334,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 6.01,
+ 7.09,
+ 6.79
+ ],
+ "loadavg_end": [
+ 6.01,
+ 7.09,
+ 6.79
+ ],
+ "machine_busy_cpu_s": 6.580000000074506
+ },
+ "pkg_j_per_op": 0.17033333333333334,
+ "pkg_j_per_op_above_idle": 0.007832420600860056,
+ "error": null
+ },
+ {
+ "name": "overwrite_4k_fdatasync",
+ "description": "overwrite 4 KiB inside an already written, synced file, then fdatasync (no metadata change)",
+ "n": 300,
+ "latency": {
+ "n": 300,
+ "min_ms": 0.883,
+ "p50_ms": 1.099,
+ "p95_ms": 1.784,
+ "p99_ms": 1.875,
+ "max_ms": 1.939,
+ "mean_ms": 1.178
+ },
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 0.353652759,
+ "valid": true,
+ "refusal": null,
+ "samples": 5,
+ "largest_gap_ms": 100.602,
+ "pkg_j": 14.456,
+ "cpu_p_j": 8.3,
+ "cpu_e_j": 0.702,
+ "rest_j": 5.453999999999999,
+ "pkg_mean_w": 40.87625398675315,
+ "pkg_edge_sd_j": 3.337532162131728,
+ "sys_total_mean_w": 55.6362,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 6.01,
+ 7.09,
+ 6.79
+ ],
+ "loadavg_end": [
+ 6.01,
+ 7.09,
+ 6.79
+ ],
+ "machine_busy_cpu_s": 2.489999999757856
+ },
+ "pkg_j_per_op": 0.04818666666666666,
+ "pkg_j_per_op_above_idle": -0.006539941878416613,
+ "error": null
+ },
+ {
+ "name": "odirect_dsync_4k_overwrite",
+ "description": "O_DIRECT | O_DSYNC 4 KiB overwrite inside an already written file (device write with FUA or flush)",
+ "n": 300,
+ "latency": {
+ "n": 300,
+ "min_ms": 0.498,
+ "p50_ms": 1.584,
+ "p95_ms": 2.194,
+ "p99_ms": 2.294,
+ "max_ms": 2.307,
+ "mean_ms": 1.69
+ },
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 0.507343961,
+ "valid": true,
+ "refusal": null,
+ "samples": 7,
+ "largest_gap_ms": 100.699,
+ "pkg_j": 24.894,
+ "cpu_p_j": 14.579,
+ "cpu_e_j": 1.194,
+ "rest_j": 9.120999999999999,
+ "pkg_mean_w": 49.06730327672117,
+ "pkg_edge_sd_j": 4.006328536078665,
+ "sys_total_mean_w": 57.153571428571425,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 6.01,
+ 7.09,
+ 6.79
+ ],
+ "loadavg_end": [
+ 6.49,
+ 7.17,
+ 6.82
+ ],
+ "machine_busy_cpu_s": 3.8999999999068677
+ },
+ "pkg_j_per_op": 0.08298,
+ "pkg_j_per_op_above_idle": 0.004470180283425975,
+ "error": null
+ },
+ {
+ "name": "overwrite_64k_fdatasync",
+ "description": "overwrite 64 KiB inside an already written, synced file, then fdatasync",
+ "n": 100,
+ "latency": {
+ "n": 100,
+ "min_ms": 0.782,
+ "p50_ms": 0.894,
+ "p95_ms": 1.518,
+ "p99_ms": 1.804,
+ "max_ms": 1.807,
+ "mean_ms": 1.022
+ },
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 0.102389153,
+ "valid": true,
+ "refusal": null,
+ "samples": 3,
+ "largest_gap_ms": 100.196,
+ "pkg_j": 10.035,
+ "cpu_p_j": 5.752,
+ "cpu_e_j": 0.584,
+ "rest_j": 3.6990000000000003,
+ "pkg_mean_w": 98.00842868580034,
+ "pkg_edge_sd_j": 8.002354692405484,
+ "sys_total_mean_w": 58.53366666666666,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 6.49,
+ 7.17,
+ 6.82
+ ],
+ "loadavg_end": [
+ 6.49,
+ 7.17,
+ 6.82
+ ],
+ "machine_busy_cpu_s": 0.8500000000931323
+ },
+ "pkg_j_per_op": 0.10035,
+ "pkg_j_per_op_above_idle": 0.05281683969322316,
+ "error": null
+ },
+ {
+ "name": "overwrite_1m_fdatasync",
+ "description": "overwrite 1024 KiB inside an already written, synced file, then fdatasync",
+ "n": 100,
+ "latency": {
+ "n": 100,
+ "min_ms": 0.795,
+ "p50_ms": 0.899,
+ "p95_ms": 1.599,
+ "p99_ms": 2.499,
+ "max_ms": 2.81,
+ "mean_ms": 1.08
+ },
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 0.108205796,
+ "valid": true,
+ "refusal": null,
+ "samples": 3,
+ "largest_gap_ms": 100.188,
+ "pkg_j": 5.636,
+ "cpu_p_j": 3.449,
+ "cpu_e_j": 0.353,
+ "rest_j": 1.8340000000000003,
+ "pkg_mean_w": 52.085934472493506,
+ "pkg_edge_sd_j": 4.252798741121653,
+ "sys_total_mean_w": 64.35833333333333,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 6.49,
+ 7.17,
+ 6.82
+ ],
+ "loadavg_end": [
+ 6.49,
+ 7.17,
+ 6.82
+ ],
+ "machine_busy_cpu_s": 1.0800000000745058
+ },
+ "pkg_j_per_op": 0.05636,
+ "pkg_j_per_op_above_idle": 0.006126520215374836,
+ "error": null
+ },
+ {
+ "name": "fallocate_4k_overwrite_fdatasync",
+ "description": "write 4 KiB into fallocate()d (unwritten) space, then fdatasync",
+ "n": 300,
+ "latency": {
+ "n": 300,
+ "min_ms": 2.579,
+ "p50_ms": 3.588,
+ "p95_ms": 4.503,
+ "p99_ms": 5.207,
+ "max_ms": 8.364,
+ "mean_ms": 3.615
+ },
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 1.084920487,
+ "valid": true,
+ "refusal": null,
+ "samples": 12,
+ "largest_gap_ms": 100.924,
+ "pkg_j": 54.934,
+ "cpu_p_j": 33.521,
+ "cpu_e_j": 1.487,
+ "rest_j": 19.925999999999995,
+ "pkg_mean_w": 50.63412541125698,
+ "pkg_edge_sd_j": 4.134259027655702,
+ "sys_total_mean_w": 58.28125,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 6.49,
+ 7.17,
+ 6.82
+ ],
+ "loadavg_end": [
+ 6.49,
+ 7.17,
+ 6.82
+ ],
+ "machine_busy_cpu_s": 6.890000000130385
+ },
+ "pkg_j_per_op": 0.18311333333333332,
+ "pkg_j_per_op_above_idle": 0.01522543402080423,
+ "error": null
+ },
+ {
+ "name": "prewrite_64m_zeros_fsync",
+ "description": "extend a file by 64 MiB of zeros, then fsync (WAL segment pre-writing, amortized)",
+ "n": 5,
+ "latency": {
+ "n": 5,
+ "min_ms": 18.4,
+ "p50_ms": 19.262,
+ "p95_ms": null,
+ "p99_ms": null,
+ "max_ms": 19.587,
+ "mean_ms": 19.109
+ },
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 0.095701801,
+ "valid": true,
+ "refusal": null,
+ "samples": 2,
+ "largest_gap_ms": 95.689,
+ "pkg_j": 5.241,
+ "cpu_p_j": 3.291,
+ "cpu_e_j": 0.113,
+ "rest_j": 1.8369999999999997,
+ "pkg_mean_w": 54.76385966863883,
+ "pkg_edge_sd_j": 4.47145041778494,
+ "sys_total_mean_w": 58.4135,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 6.49,
+ 7.17,
+ 6.82
+ ],
+ "loadavg_end": [
+ 6.49,
+ 7.17,
+ 6.82
+ ],
+ "machine_busy_cpu_s": 0.6599999996833503
+ },
+ "pkg_j_per_op": 1.0482,
+ "pkg_j_per_op_above_idle": 0.15962754573225996,
+ "error": null
+ },
+ {
+ "name": "append_64k_fdatasync",
+ "description": "append 64 KiB, then fdatasync",
+ "n": 100,
+ "latency": {
+ "n": 100,
+ "min_ms": 2.597,
+ "p50_ms": 3.806,
+ "p95_ms": 4.435,
+ "p99_ms": 5.219,
+ "max_ms": 5.399,
+ "mean_ms": 3.749
+ },
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 0.375082488,
+ "valid": true,
+ "refusal": null,
+ "samples": 5,
+ "largest_gap_ms": 100.355,
+ "pkg_j": 14.969,
+ "cpu_p_j": 9.296,
+ "cpu_e_j": 0.298,
+ "rest_j": 5.375,
+ "pkg_mean_w": 39.908554728366845,
+ "pkg_edge_sd_j": 3.2585198485478566,
+ "sys_total_mean_w": 59.0812,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 6.49,
+ 7.17,
+ 6.82
+ ],
+ "loadavg_end": [
+ 6.49,
+ 7.17,
+ 6.82
+ ],
+ "machine_busy_cpu_s": 2.349999999627471
+ },
+ "pkg_j_per_op": 0.14969,
+ "pkg_j_per_op_above_idle": -0.024438367194996768,
+ "error": null
+ },
+ {
+ "name": "append_1m_fdatasync",
+ "description": "append 1024 KiB, then fdatasync",
+ "n": 100,
+ "latency": {
+ "n": 100,
+ "min_ms": 2.92,
+ "p50_ms": 4.02,
+ "p95_ms": 5.087,
+ "p99_ms": 5.89,
+ "max_ms": 6.449,
+ "mean_ms": 4.07
+ },
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 0.40719812,
+ "valid": true,
+ "refusal": null,
+ "samples": 6,
+ "largest_gap_ms": 100.209,
+ "pkg_j": 24.109,
+ "cpu_p_j": 14.358,
+ "cpu_e_j": 0.654,
+ "rest_j": 9.097000000000001,
+ "pkg_mean_w": 59.20705134886183,
+ "pkg_edge_sd_j": 4.8342354993158,
+ "sys_total_mean_w": 56.49216666666666,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 6.49,
+ 7.17,
+ 6.82
+ ],
+ "loadavg_end": [
+ 6.49,
+ 7.17,
+ 6.82
+ ],
+ "machine_busy_cpu_s": 2.5700000002980232
+ },
+ "pkg_j_per_op": 0.24109000000000003,
+ "pkg_j_per_op_above_idle": 0.05205226555777689,
+ "error": null
+ },
+ {
+ "name": "blob_file_create_fsync_rename_dirfsync_12k",
+ "description": "new 12 KB blob file: create tmp, write, fsync, rename, fsync shard directory (today's write_blob_file)",
+ "n": 300,
+ "latency": {
+ "n": 300,
+ "min_ms": 5.676,
+ "p50_ms": 6.291,
+ "p95_ms": 7.205,
+ "p99_ms": 7.831,
+ "max_ms": 9.292,
+ "mean_ms": 6.309
+ },
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 1.893009063,
+ "valid": true,
+ "refusal": null,
+ "samples": 20,
+ "largest_gap_ms": 100.243,
+ "pkg_j": 77.619,
+ "cpu_p_j": 42.997,
+ "cpu_e_j": 2.174,
+ "rest_j": 32.448,
+ "pkg_mean_w": 41.00297326468743,
+ "pkg_edge_sd_j": 3.3478787478488248,
+ "sys_total_mean_w": 49.07745,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 6.49,
+ 7.17,
+ 6.82
+ ],
+ "loadavg_end": [
+ 6.49,
+ 7.17,
+ 6.82
+ ],
+ "machine_busy_cpu_s": 9.5
+ },
+ "pkg_j_per_op": 0.25873,
+ "pkg_j_per_op_above_idle": -0.03420696521987518,
+ "error": null
+ },
+ {
+ "name": "concurrent_32_append_4k_fdatasync_round",
+ "description": "32 threads each append 4 KiB to their own file and fdatasync; time per round (all 32 done)",
+ "n": 30,
+ "latency": {
+ "n": 30,
+ "min_ms": 5.953,
+ "p50_ms": 6.764,
+ "p95_ms": 9.917,
+ "p99_ms": null,
+ "max_ms": 10.344,
+ "mean_ms": 7.129
+ },
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 0.231481027,
+ "valid": true,
+ "refusal": null,
+ "samples": 4,
+ "largest_gap_ms": 100.291,
+ "pkg_j": 8.381,
+ "cpu_p_j": 4.447,
+ "cpu_e_j": 0.22,
+ "rest_j": 3.714,
+ "pkg_mean_w": 36.20599108539466,
+ "pkg_edge_sd_j": 2.9562067930324467,
+ "sys_total_mean_w": 48.243,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 6.49,
+ 7.17,
+ 6.82
+ ],
+ "loadavg_end": [
+ 6.49,
+ 7.17,
+ 6.82
+ ],
+ "machine_busy_cpu_s": 0.8900000001303852
+ },
+ "pkg_j_per_op": 0.27936666666666665,
+ "pkg_j_per_op_above_idle": -0.07884265668383642,
+ "error": null
+ },
+ {
+ "name": "concurrent_32_blob_file_create_round",
+ "description": "32 threads each create one 12 KB blob file with fsync, rename, directory fsync; time per round (all 32 done)",
+ "n": 30,
+ "latency": {
+ "n": 30,
+ "min_ms": 11.056,
+ "p50_ms": 12.033,
+ "p95_ms": 16.667,
+ "p99_ms": null,
+ "max_ms": 19.703,
+ "mean_ms": 13.009
+ },
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 0.397875602,
+ "valid": true,
+ "refusal": null,
+ "samples": 5,
+ "largest_gap_ms": 100.201,
+ "pkg_j": 16.785,
+ "cpu_p_j": 8.874,
+ "cpu_e_j": 0.596,
+ "rest_j": 7.3149999999999995,
+ "pkg_mean_w": 42.18655256976526,
+ "pkg_edge_sd_j": 3.444517593434111,
+ "sys_total_mean_w": 47.5682,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 6.49,
+ 7.17,
+ 6.82
+ ],
+ "loadavg_end": [
+ 8.37,
+ 7.55,
+ 6.95
+ ],
+ "machine_busy_cpu_s": 1.8900000001303852
+ },
+ "pkg_j_per_op": 0.5595,
+ "pkg_j_per_op_above_idle": -0.05619948957455622,
+ "error": null
+ }
+ ],
+ "bandwidth": [
+ {
+ "name": "sequential_buffered_1m_writes_then_fsync",
+ "bytes": 268435456,
+ "seconds": 0.062433,
+ "seconds_per_gib": 0.249733328,
+ "error": null
+ },
+ {
+ "name": "sequential_odirect_1m_writes_then_fsync",
+ "bytes": 268435456,
+ "seconds": 0.038177,
+ "seconds_per_gib": 0.152707472,
+ "error": null
+ }
+ ],
+ "cpu": [
+ {
+ "name": "sha256_request_sized",
+ "description": "SHA-256 over a buffer the size of a typical JSON submit request",
+ "n": 134865,
+ "latency": {
+ "n": 134865,
+ "min_ms": 0.02,
+ "p50_ms": 0.02,
+ "p95_ms": 0.02,
+ "p99_ms": 0.022,
+ "max_ms": 0.057,
+ "mean_ms": 0.02
+ },
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 2.817642006,
+ "valid": true,
+ "refusal": null,
+ "samples": 30,
+ "largest_gap_ms": 101.939,
+ "pkg_j": 149.202,
+ "cpu_p_j": 84.309,
+ "cpu_e_j": 3.9,
+ "rest_j": 60.993,
+ "pkg_mean_w": 52.95278806969916,
+ "pkg_edge_sd_j": 4.323577040949985,
+ "sys_total_mean_w": 60.7138,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 8.37,
+ 7.55,
+ 6.95
+ ],
+ "loadavg_end": [
+ 8.37,
+ 7.55,
+ 6.95
+ ],
+ "machine_busy_cpu_s": 19.979999999981374
+ },
+ "pkg_j_per_op": 0.0011063063063063063,
+ "pkg_j_per_op_above_idle": 0.00013640108776224002,
+ "error": null
+ },
+ {
+ "name": "sha256_content_12k",
+ "description": "SHA-256 over 12 KB (typical content per proposal)",
+ "n": 533493,
+ "latency": {
+ "n": 533493,
+ "min_ms": 0.005,
+ "p50_ms": 0.005,
+ "p95_ms": 0.005,
+ "p99_ms": 0.005,
+ "max_ms": 0.267,
+ "mean_ms": 0.005
+ },
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 3.021454707,
+ "valid": true,
+ "refusal": null,
+ "samples": 32,
+ "largest_gap_ms": 101.383,
+ "pkg_j": 156.388,
+ "cpu_p_j": 81.622,
+ "cpu_e_j": 6.945,
+ "rest_j": 67.821,
+ "pkg_mean_w": 51.75917402888277,
+ "pkg_edge_sd_j": 4.226118862622594,
+ "sys_total_mean_w": 59.26821875,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 8.37,
+ 7.55,
+ 6.95
+ ],
+ "loadavg_end": [
+ 8.66,
+ 7.62,
+ 6.97
+ ],
+ "machine_busy_cpu_s": 22.25
+ },
+ "pkg_j_per_op": 0.00029313974128995134,
+ "pkg_j_per_op_above_idle": 0.000030215818961079705,
+ "error": null
+ },
+ {
+ "name": "ed25519_verify",
+ "description": "one Ed25519 signature verification (256-byte message)",
+ "n": 125459,
+ "latency": {
+ "n": 125459,
+ "min_ms": 0.023,
+ "p50_ms": 0.023,
+ "p95_ms": 0.023,
+ "p99_ms": 0.025,
+ "max_ms": 0.831,
+ "mean_ms": 0.023
+ },
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 2.995199909,
+ "valid": true,
+ "refusal": null,
+ "samples": 31,
+ "largest_gap_ms": 100.793,
+ "pkg_j": 137.643,
+ "cpu_p_j": 81.353,
+ "cpu_e_j": 3.483,
+ "rest_j": 52.80700000000001,
+ "pkg_mean_w": 45.95452863977768,
+ "pkg_edge_sd_j": 3.752171551252374,
+ "sys_total_mean_w": 53.46883870967742,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 8.66,
+ 7.62,
+ 6.97
+ ],
+ "loadavg_end": [
+ 8.66,
+ 7.62,
+ 6.97
+ ],
+ "machine_busy_cpu_s": 17.770000000018626
+ },
+ "pkg_j_per_op": 0.0010971153922795494,
+ "pkg_j_per_op_above_idle": -0.000011208592782523034,
+ "error": null
+ },
+ {
+ "name": "ed25519_sign",
+ "description": "one Ed25519 signature (256-byte message)",
+ "n": 301896,
+ "latency": {
+ "n": 301896,
+ "min_ms": 0.009,
+ "p50_ms": 0.009,
+ "p95_ms": 0.009,
+ "p99_ms": 0.01,
+ "max_ms": 1.045,
+ "mean_ms": 0.009
+ },
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 2.994044796,
+ "valid": true,
+ "refusal": null,
+ "samples": 31,
+ "largest_gap_ms": 101.033,
+ "pkg_j": 136.057,
+ "cpu_p_j": 76.241,
+ "cpu_e_j": 5.064,
+ "rest_j": 54.75199999999999,
+ "pkg_mean_w": 45.44253986505818,
+ "pkg_edge_sd_j": 3.7103678428491893,
+ "sys_total_mean_w": 51.944741935483876,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 8.66,
+ 7.62,
+ 6.97
+ ],
+ "loadavg_end": [
+ 8.45,
+ 7.6,
+ 6.97
+ ],
+ "machine_busy_cpu_s": 18.610000000335276
+ },
+ "pkg_j_per_op": 0.0004506750669104592,
+ "pkg_j_per_op_above_idle": -9.733795259028907e-6,
+ "error": null
+ },
+ {
+ "name": "json_encode_submit_request",
+ "description": "serde_json encode of a typical signed submit request",
+ "n": 80421,
+ "latency": {
+ "n": 80421,
+ "min_ms": 0.036,
+ "p50_ms": 0.037,
+ "p95_ms": 0.037,
+ "p99_ms": 0.039,
+ "max_ms": 0.087,
+ "mean_ms": 0.037
+ },
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 2.997359423,
+ "valid": true,
+ "refusal": null,
+ "samples": 31,
+ "largest_gap_ms": 103.75,
+ "pkg_j": 164.29,
+ "cpu_p_j": 102.716,
+ "cpu_e_j": 6.923,
+ "rest_j": 54.650999999999996,
+ "pkg_mean_w": 54.811578064123275,
+ "pkg_edge_sd_j": 4.47534660846098,
+ "sys_total_mean_w": 62.773967741935486,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 8.45,
+ 7.6,
+ 6.97
+ ],
+ "loadavg_end": [
+ 8.66,
+ 7.65,
+ 6.99
+ ],
+ "machine_busy_cpu_s": 25.33999999985099
+ },
+ "pkg_j_per_op": 0.002042874373608883,
+ "pkg_j_per_op_above_idle": 0.0003126114800630656,
+ "error": null
+ },
+ {
+ "name": "json_decode_submit_request",
+ "description": "serde_json decode of a typical signed submit request",
+ "n": 38208,
+ "latency": {
+ "n": 38208,
+ "min_ms": 0.077,
+ "p50_ms": 0.078,
+ "p95_ms": 0.079,
+ "p99_ms": 0.08,
+ "max_ms": 0.132,
+ "mean_ms": 0.078
+ },
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 2.989021067,
+ "valid": true,
+ "refusal": null,
+ "samples": 31,
+ "largest_gap_ms": 102.691,
+ "pkg_j": 217.729,
+ "cpu_p_j": 105.65,
+ "cpu_e_j": 7.296,
+ "rest_j": 104.783,
+ "pkg_mean_w": 72.84291248523343,
+ "pkg_edge_sd_j": 5.947598898901066,
+ "sys_total_mean_w": 83.49651612903226,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 8.66,
+ 7.65,
+ 6.99
+ ],
+ "loadavg_end": [
+ 8.66,
+ 7.65,
+ 6.99
+ ],
+ "machine_busy_cpu_s": 26.709999999962747
+ },
+ "pkg_j_per_op": 0.005698518634840871,
+ "pkg_j_per_op_above_idle": 0.0020667563818913388,
+ "error": null
+ },
+ {
+ "name": "auth_payload_digest",
+ "description": "synapse-auth payload digest: serde_json encode of the payload plus SHA-256",
+ "n": 56334,
+ "latency": {
+ "n": 56334,
+ "min_ms": 0.052,
+ "p50_ms": 0.053,
+ "p95_ms": 0.054,
+ "p99_ms": 0.055,
+ "max_ms": 0.065,
+ "mean_ms": 0.053
+ },
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 3.002737482,
+ "valid": true,
+ "refusal": null,
+ "samples": 32,
+ "largest_gap_ms": 100.988,
+ "pkg_j": 217.465,
+ "cpu_p_j": 101.722,
+ "cpu_e_j": 9.369,
+ "rest_j": 106.37400000000001,
+ "pkg_mean_w": 72.42224846614147,
+ "pkg_edge_sd_j": 5.913251825570276,
+ "sys_total_mean_w": 84.10471875,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 8.66,
+ 7.65,
+ 6.99
+ ],
+ "loadavg_end": [
+ 8.84,
+ 7.71,
+ 7.01
+ ],
+ "machine_busy_cpu_s": 30.31000000005588
+ },
+ "pkg_j_per_op": 0.00386027976000284,
+ "pkg_j_per_op_above_idle": 0.0013857680392394445,
+ "error": null
+ },
+ {
+ "name": "envelope_validate",
+ "description": "ChangesetEnvelope::validate (canonical bytes, path rules, Ed25519 verify, id digest)",
+ "n": 107409,
+ "latency": {
+ "n": 107409,
+ "min_ms": 0.027,
+ "p50_ms": 0.027,
+ "p95_ms": 0.027,
+ "p99_ms": 0.029,
+ "max_ms": 0.046,
+ "mean_ms": 0.027
+ },
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 2.998208702,
+ "valid": true,
+ "refusal": null,
+ "samples": 31,
+ "largest_gap_ms": 101.985,
+ "pkg_j": 226.607,
+ "cpu_p_j": 117.559,
+ "cpu_e_j": 9.201,
+ "rest_j": 99.84700000000001,
+ "pkg_mean_w": 75.58079590951705,
+ "pkg_edge_sd_j": 6.1711461443916935,
+ "sys_total_mean_w": 88.37251612903225,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 8.84,
+ 7.71,
+ 7.01
+ ],
+ "loadavg_end": [
+ 8.84,
+ 7.71,
+ 7.01
+ ],
+ "machine_busy_cpu_s": 32.99000000022352
+ },
+ "pkg_j_per_op": 0.002109758027725796,
+ "pkg_j_per_op_above_idle": 0.0008138805956049731,
+ "error": null
+ },
+ {
+ "name": "blob_digest_12k",
+ "description": "BlobDigest::compute over 12 KB of content",
+ "n": 522215,
+ "latency": {
+ "n": 522215,
+ "min_ms": 0.005,
+ "p50_ms": 0.005,
+ "p95_ms": 0.005,
+ "p99_ms": 0.005,
+ "max_ms": 0.034,
+ "mean_ms": 0.005
+ },
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 2.977073533,
+ "valid": true,
+ "refusal": null,
+ "samples": 31,
+ "largest_gap_ms": 102.653,
+ "pkg_j": 231.906,
+ "cpu_p_j": 113.389,
+ "cpu_e_j": 10.775,
+ "rest_j": 107.742,
+ "pkg_mean_w": 77.89730331796947,
+ "pkg_edge_sd_j": 6.3602881822612085,
+ "sys_total_mean_w": 91.09870967741935,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 8.84,
+ 7.71,
+ 7.01
+ ],
+ "loadavg_end": [
+ 9.02,
+ 7.76,
+ 7.03
+ ],
+ "machine_busy_cpu_s": 35.15999999968335
+ },
+ "pkg_j_per_op": 0.00044408146070105226,
+ "pkg_j_per_op_above_idle": 0.00017942472045065554,
+ "error": null
+ },
+ {
+ "name": "crc32c_request_sized",
+ "description": "synapse_store::crc32c over a request-sized buffer",
+ "n": 2054219,
+ "latency": {
+ "n": 2054219,
+ "min_ms": 0.001,
+ "p50_ms": 0.001,
+ "p95_ms": 0.001,
+ "p99_ms": 0.001,
+ "max_ms": 0.016,
+ "mean_ms": 0.001
+ },
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 3.070605693,
+ "valid": true,
+ "refusal": null,
+ "samples": 32,
+ "largest_gap_ms": 102.091,
+ "pkg_j": 230.352,
+ "cpu_p_j": 115.899,
+ "cpu_e_j": 10.511,
+ "rest_j": 103.94200000000001,
+ "pkg_mean_w": 75.01842406048063,
+ "pkg_edge_sd_j": 6.125228675196869,
+ "sys_total_mean_w": 90.6725625,
+ "nvme_temp_k": 317.0,
+ "loadavg_start": [
+ 9.02,
+ 7.76,
+ 7.03
+ ],
+ "loadavg_end": [
+ 9.18,
+ 7.82,
+ 7.05
+ ],
+ "machine_busy_cpu_s": 35.77000000001863
+ },
+ "pkg_j_per_op": 0.0001121360478118448,
+ "pkg_j_per_op_above_idle": 0.00004274234712793087,
+ "error": null
+ }
+ ],
+ "typical_request_json_bytes": 44668
+}
\ No newline at end of file
diff --git a/evidence/r1-raw-block-store/measurement-57d1135/manifest.json b/evidence/r1-raw-block-store/measurement-57d1135/manifest.json
new file mode 100644
index 0000000..72e997a
--- /dev/null
+++ b/evidence/r1-raw-block-store/measurement-57d1135/manifest.json
@@ -0,0 +1,16 @@
+{
+ "step": "ADR 0003 section 9 step 27, R1 (issue #47): seconds and joules per accepted change, R1 raw block store (file-backed O_DIRECT) beside A2 on ext4, against the flush bound",
+ "host": "spark-b87b, 20 CPUs, kernel 7.0.0-1019-nvidia; both arms on /dev/nvme0n1p2 ext4: A2 as files in a directory, R1 on a 512 MiB preallocated regular file (written with zeros, synced) opened with O_DIRECT",
+ "binary": {"commit": "57d1135", "sha256": "7581c17d9083578d80854fad930aeedd925f802cd8da94cb3e266ed41aa842d2", "build": "nice -n 19 cargo build --release -p synapse-bench -j 4"},
+ "commands": [
+ "synapse-bench floor --dir --out floor.json --iterations 300",
+ "3 x interleaved: synapse-bench segments --dir --out raw-r1-.json --reps 1 --block-device ; synapse-bench segments --dir --out raw-a2-.json --reps 1 (defaults otherwise: --agents 1,4,8,32 --changes 4000 --blob-bytes 11949 --segment-mib 16 --checkpoint-every 1000 --idle-window-s 30)",
+ "synapse-bench segments-report --raw raw--.json --floor floor.json > report--.json",
+ "aggregate.sh > summary.json (median and range of the three invocations per arm and agent count)"
+ ],
+ "run_start_utc": "2026-10-17T04:55:45Z", "loadavg_start": "6.27 7.16 6.81",
+ "run_end_utc": "2026-10-17T05:00:32Z", "loadavg_end": "8.35 8.44 7.54",
+ "clock": "std::time::Instant (CLOCK_MONOTONIC), ns",
+ "energy": "aien_spbm hwmon, SoC package only, 1 mJ step, 10 Hz sampling, uncalibrated; NVMe UNMEASURED. Idle window per invocation read 36.0 to 72.7 W (other sessions' workloads, including a GPU test, were running), so package energy per change is dominated by other load and does not separate the arms.",
+ "note": "Shared, loaded host (load average 6 to 8.5). Each R1 cell starts on a device whose first MiB was zeroed and synced, then formatted by the store."
+}
diff --git a/evidence/r1-raw-block-store/measurement-57d1135/r1-0.log b/evidence/r1-raw-block-store/measurement-57d1135/r1-0.log
new file mode 100644
index 0000000..3cb9e2c
--- /dev/null
+++ b/evidence/r1-raw-block-store/measurement-57d1135/r1-0.log
@@ -0,0 +1,4 @@
+agents 1 rep 0: 4000 accepted in 5.144 s, 4000 batches, 4 segment files
+agents 4 rep 0: 4000 accepted in 2.348 s, 1779 batches, 4 segment files
+agents 8 rep 0: 4000 accepted in 1.243 s, 996 batches, 4 segment files
+agents 32 rep 0: 4000 accepted in 0.449 s, 253 batches, 4 segment files
diff --git a/evidence/r1-raw-block-store/measurement-57d1135/r1-1.log b/evidence/r1-raw-block-store/measurement-57d1135/r1-1.log
new file mode 100644
index 0000000..9c9d9dd
--- /dev/null
+++ b/evidence/r1-raw-block-store/measurement-57d1135/r1-1.log
@@ -0,0 +1,4 @@
+agents 1 rep 0: 4000 accepted in 5.453 s, 4000 batches, 4 segment files
+agents 4 rep 0: 4000 accepted in 2.380 s, 1801 batches, 4 segment files
+agents 8 rep 0: 4000 accepted in 1.351 s, 988 batches, 4 segment files
+agents 32 rep 0: 4000 accepted in 0.559 s, 286 batches, 4 segment files
diff --git a/evidence/r1-raw-block-store/measurement-57d1135/r1-2.log b/evidence/r1-raw-block-store/measurement-57d1135/r1-2.log
new file mode 100644
index 0000000..d7e91af
--- /dev/null
+++ b/evidence/r1-raw-block-store/measurement-57d1135/r1-2.log
@@ -0,0 +1,4 @@
+agents 1 rep 0: 4000 accepted in 5.726 s, 4000 batches, 4 segment files
+agents 4 rep 0: 4000 accepted in 2.522 s, 1745 batches, 4 segment files
+agents 8 rep 0: 4000 accepted in 1.228 s, 1006 batches, 4 segment files
+agents 32 rep 0: 4000 accepted in 0.437 s, 253 batches, 4 segment files
diff --git a/evidence/r1-raw-block-store/measurement-57d1135/raw-a2-0.json b/evidence/r1-raw-block-store/measurement-57d1135/raw-a2-0.json
new file mode 100644
index 0000000..6cb48a7
--- /dev/null
+++ b/evidence/r1-raw-block-store/measurement-57d1135/raw-a2-0.json
@@ -0,0 +1,16223 @@
+{
+ "config": {
+ "agents": [
+ 1,
+ 4,
+ 8,
+ 32
+ ],
+ "changes": 4000,
+ "reps": 1,
+ "blob_bytes": 11949,
+ "segment_bytes": 16777216,
+ "checkpoint_every": 1000,
+ "idle_window_s": 30,
+ "block_device": null
+ },
+ "store_dir": "/home/drakestapleton/workspace/r1-bench/a2",
+ "idle": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 30.001573979,
+ "valid": true,
+ "refusal": null,
+ "samples": 302,
+ "largest_gap_ms": 102.82,
+ "pkg_j": 2181.17,
+ "cpu_p_j": 1108.243,
+ "cpu_e_j": 109.115,
+ "rest_j": 963.8120000000001,
+ "pkg_mean_w": 72.70185229370762,
+ "pkg_edge_sd_j": 5.936081382492483,
+ "sys_total_mean_w": 88.05932119205298,
+ "nvme_temp_k": 320.0,
+ "loadavg_start": [
+ 9.33,
+ 8.04,
+ 7.16
+ ],
+ "loadavg_end": [
+ 12.18,
+ 8.81,
+ 7.44
+ ],
+ "machine_busy_cpu_s": 320.5200000000186
+ },
+ "cells": [
+ {
+ "agents": 1,
+ "rep": 0,
+ "accepted": 4000,
+ "elapsed_ns": 6023434054,
+ "latency_ns": [
+ 3040146,
+ 2995138,
+ 2019165,
+ 3974040,
+ 1010342,
+ 1497609,
+ 899126,
+ 899445,
+ 923606,
+ 1597434,
+ 992502,
+ 983702,
+ 1212055,
+ 2196702,
+ 1603833,
+ 1185448,
+ 1799083,
+ 1905307,
+ 3283956,
+ 928710,
+ 1585770,
+ 893669,
+ 3593702,
+ 908070,
+ 1500777,
+ 898597,
+ 899302,
+ 901237,
+ 1499433,
+ 899766,
+ 899157,
+ 931110,
+ 1785131,
+ 1196215,
+ 1112647,
+ 1080903,
+ 2502127,
+ 1012598,
+ 986198,
+ 991206,
+ 1503177,
+ 919702,
+ 996358,
+ 3301972,
+ 1597434,
+ 994870,
+ 997702,
+ 999286,
+ 1603370,
+ 989446,
+ 1123959,
+ 1081847,
+ 1492937,
+ 897173,
+ 902438,
+ 896501,
+ 1512425,
+ 1698987,
+ 994294,
+ 999942,
+ 1600954,
+ 997894,
+ 999782,
+ 999654,
+ 1701946,
+ 998326,
+ 1002455,
+ 997478,
+ 1595833,
+ 1112615,
+ 1102711,
+ 987142,
+ 1595882,
+ 998614,
+ 999638,
+ 1004022,
+ 1597482,
+ 993526,
+ 997798,
+ 899350,
+ 1611625,
+ 1197784,
+ 1208183,
+ 1096551,
+ 1592921,
+ 998231,
+ 1000054,
+ 1003062,
+ 1715482,
+ 1295192,
+ 1200631,
+ 1094007,
+ 1591322,
+ 998582,
+ 1000486,
+ 1002278,
+ 1603082,
+ 996726,
+ 1314072,
+ 1297336,
+ 1586202,
+ 1200263,
+ 1107047,
+ 1300856,
+ 1898651,
+ 1199752,
+ 1198407,
+ 1301048,
+ 1898235,
+ 1301704,
+ 1099655,
+ 1096615,
+ 1696282,
+ 1208584,
+ 1212103,
+ 1082503,
+ 1795243,
+ 1004262,
+ 1003126,
+ 3309188,
+ 3999160,
+ 1207512,
+ 1237927,
+ 1532170,
+ 1723034,
+ 1105975,
+ 1104631,
+ 1393720,
+ 1797819,
+ 1278536,
+ 1286024,
+ 1011462,
+ 1497321,
+ 897990,
+ 898837,
+ 899654,
+ 1500105,
+ 898373,
+ 899702,
+ 913189,
+ 2487552,
+ 3477701,
+ 1344056,
+ 988678,
+ 1603386,
+ 993062,
+ 1001862,
+ 1005462,
+ 1603162,
+ 1100183,
+ 988694,
+ 999606,
+ 1641098,
+ 1065750,
+ 2873618,
+ 1027510,
+ 1693803,
+ 1197223,
+ 3829671,
+ 1178375,
+ 1603082,
+ 1104071,
+ 1105591,
+ 1196983,
+ 1781499,
+ 1213287,
+ 1096919,
+ 1090935,
+ 1601817,
+ 1017255,
+ 1087446,
+ 990342,
+ 1600858,
+ 999510,
+ 1010470,
+ 1197032,
+ 1693930,
+ 999926,
+ 1203015,
+ 1196712,
+ 1698538,
+ 1092167,
+ 1105223,
+ 1191975,
+ 1590938,
+ 898197,
+ 899238,
+ 906485,
+ 1606906,
+ 4697453,
+ 988406,
+ 898309,
+ 1498953,
+ 899254,
+ 899701,
+ 1530122,
+ 1801627,
+ 986838,
+ 1108438,
+ 902422,
+ 5122591,
+ 2585920,
+ 1109319,
+ 1188759,
+ 1698282,
+ 1194056,
+ 1197591,
+ 1204567,
+ 1693339,
+ 1207127,
+ 1199543,
+ 1197704,
+ 1697642,
+ 1197463,
+ 1100039,
+ 1104727,
+ 1789675,
+ 1109799,
+ 1100630,
+ 1188679,
+ 1614826,
+ 1080103,
+ 1118983,
+ 1178727,
+ 1616842,
+ 1084662,
+ 995911,
+ 1376952,
+ 1838843,
+ 1083495,
+ 996022,
+ 1014390,
+ 1591242,
+ 1102999,
+ 1006214,
+ 1090006,
+ 1708571,
+ 1199671,
+ 1101543,
+ 1080887,
+ 1601833,
+ 995158,
+ 999078,
+ 1010759,
+ 1587593,
+ 993382,
+ 991046,
+ 896022,
+ 1498089,
+ 3411605,
+ 1012438,
+ 1089079,
+ 1601945,
+ 995527,
+ 1027974,
+ 1071430,
+ 1720811,
+ 1188567,
+ 995254,
+ 1001078,
+ 1597274,
+ 998182,
+ 1001190,
+ 999046,
+ 1601690,
+ 1002262,
+ 3075523,
+ 1014726,
+ 1492169,
+ 898998,
+ 897701,
+ 1002326,
+ 1500570,
+ 901717,
+ 896406,
+ 898085,
+ 1499977,
+ 898614,
+ 898837,
+ 902198,
+ 1499225,
+ 898949,
+ 900086,
+ 899541,
+ 1499802,
+ 899285,
+ 900421,
+ 899622,
+ 1500265,
+ 898886,
+ 901493,
+ 897990,
+ 1500329,
+ 899925,
+ 899814,
+ 900261,
+ 1501097,
+ 898022,
+ 899749,
+ 899638,
+ 1500073,
+ 900742,
+ 899701,
+ 899302,
+ 1499593,
+ 899605,
+ 902646,
+ 897013,
+ 1500073,
+ 900150,
+ 899253,
+ 900022,
+ 1499833,
+ 900550,
+ 898933,
+ 900149,
+ 1499898,
+ 900389,
+ 898918,
+ 900037,
+ 1503721,
+ 1217448,
+ 1102294,
+ 1289864,
+ 1714923,
+ 1002310,
+ 1084263,
+ 993286,
+ 1608233,
+ 992566,
+ 1011719,
+ 1804715,
+ 1699066,
+ 1083015,
+ 997142,
+ 2145965,
+ 1656954,
+ 1016086,
+ 1082391,
+ 1504105,
+ 1666890,
+ 1018150,
+ 1014855,
+ 1098502,
+ 1595434,
+ 989574,
+ 1002006,
+ 3405157,
+ 1708602,
+ 1093527,
+ 1011894,
+ 988870,
+ 1705179,
+ 995062,
+ 997574,
+ 995622,
+ 1603914,
+ 994422,
+ 3882392,
+ 1003238,
+ 1499385,
+ 896277,
+ 1005670,
+ 3615783,
+ 2984210,
+ 1998492,
+ 1999356,
+ 1996908,
+ 2325199,
+ 1089654,
+ 996678,
+ 1001062,
+ 1596186,
+ 986566,
+ 1045943,
+ 952069,
+ 1505786,
+ 892821,
+ 899206,
+ 900677,
+ 1499961,
+ 900038,
+ 899029,
+ 899526,
+ 1501049,
+ 899461,
+ 899366,
+ 903797,
+ 1497242,
+ 900821,
+ 897845,
+ 1241336,
+ 1783259,
+ 1207767,
+ 968726,
+ 898694,
+ 1500313,
+ 899413,
+ 901494,
+ 898613,
+ 1501626,
+ 897925,
+ 900773,
+ 900006,
+ 1715082,
+ 1303640,
+ 1095431,
+ 985334,
+ 1498409,
+ 900022,
+ 899845,
+ 900230,
+ 1629226,
+ 1193111,
+ 977638,
+ 899749,
+ 1500330,
+ 898933,
+ 901302,
+ 1134999,
+ 1896427,
+ 1177207,
+ 988822,
+ 899222,
+ 1500009,
+ 900421,
+ 899478,
+ 902341,
+ 1608218,
+ 990150,
+ 1063879,
+ 4048697,
+ 1591113,
+ 898374,
+ 899045,
+ 899638,
+ 1499465,
+ 906373,
+ 894118,
+ 899829,
+ 1500490,
+ 898309,
+ 900582,
+ 898325,
+ 1608410,
+ 1220903,
+ 1281784,
+ 4510332,
+ 1808603,
+ 1090038,
+ 996310,
+ 999991,
+ 1604425,
+ 994950,
+ 998967,
+ 998966,
+ 1712522,
+ 1089607,
+ 997494,
+ 1001318,
+ 1607450,
+ 999702,
+ 1092935,
+ 996246,
+ 1602777,
+ 996422,
+ 999494,
+ 1001814,
+ 1609017,
+ 1091318,
+ 998838,
+ 997478,
+ 1606378,
+ 1093463,
+ 999766,
+ 997446,
+ 1705562,
+ 992662,
+ 1001591,
+ 1001830,
+ 1602490,
+ 992582,
+ 1000710,
+ 1098902,
+ 1601498,
+ 996982,
+ 998758,
+ 1039479,
+ 1673978,
+ 998934,
+ 992198,
+ 1097895,
+ 1602394,
+ 997078,
+ 996214,
+ 998534,
+ 1602986,
+ 1005750,
+ 991014,
+ 998502,
+ 1605018,
+ 997926,
+ 997158,
+ 1000022,
+ 1602858,
+ 998006,
+ 998294,
+ 997542,
+ 1606442,
+ 998550,
+ 996806,
+ 1115367,
+ 1883211,
+ 1302280,
+ 1281464,
+ 1005366,
+ 1712411,
+ 1198407,
+ 3696487,
+ 1206631,
+ 1696650,
+ 1101559,
+ 992454,
+ 1004182,
+ 1599962,
+ 995862,
+ 998534,
+ 997766,
+ 1606586,
+ 993398,
+ 998054,
+ 1001846,
+ 1603386,
+ 996342,
+ 1010215,
+ 993206,
+ 5217103,
+ 3973177,
+ 1107862,
+ 989911,
+ 1705914,
+ 995318,
+ 998486,
+ 996790,
+ 1610042,
+ 990406,
+ 999558,
+ 1100791,
+ 1604986,
+ 993030,
+ 997638,
+ 1005030,
+ 2595392,
+ 3296708,
+ 997478,
+ 896790,
+ 1799835,
+ 2198269,
+ 3101475,
+ 3298932,
+ 1399497,
+ 1299544,
+ 2600479,
+ 2501504,
+ 1499161,
+ 898901,
+ 898470,
+ 1001206,
+ 1513353,
+ 996566,
+ 1010198,
+ 1088087,
+ 1621946,
+ 1082086,
+ 996231,
+ 1004614,
+ 1706058,
+ 986150,
+ 1017174,
+ 993719,
+ 1592265,
+ 1013558,
+ 3708615,
+ 1085671,
+ 1701306,
+ 1092823,
+ 1001718,
+ 996758,
+ 3475141,
+ 1232264,
+ 978822,
+ 895557,
+ 1499705,
+ 898310,
+ 899061,
+ 899798,
+ 1501817,
+ 898373,
+ 898486,
+ 900837,
+ 1500650,
+ 899205,
+ 898918,
+ 903381,
+ 1496473,
+ 900006,
+ 900949,
+ 899398,
+ 5502833,
+ 896182,
+ 899749,
+ 900470,
+ 1500137,
+ 919030,
+ 982486,
+ 897061,
+ 1546617,
+ 954566,
+ 899174,
+ 898021,
+ 1501593,
+ 898486,
+ 899381,
+ 900662,
+ 1499337,
+ 899285,
+ 902262,
+ 898390,
+ 1721114,
+ 878037,
+ 898678,
+ 900821,
+ 1499962,
+ 900789,
+ 899093,
+ 900054,
+ 1501609,
+ 898438,
+ 899909,
+ 899910,
+ 1499625,
+ 899925,
+ 999606,
+ 1311496,
+ 1607882,
+ 990934,
+ 1091783,
+ 3616598,
+ 2996274,
+ 1989788,
+ 2001389,
+ 1997004,
+ 3001442,
+ 2002428,
+ 1768347,
+ 1800171,
+ 1754779,
+ 1184775,
+ 997190,
+ 1001254,
+ 1602186,
+ 994166,
+ 998118,
+ 997958,
+ 1684411,
+ 3938728,
+ 1083782,
+ 999926,
+ 1603338,
+ 1082519,
+ 1207639,
+ 4321931,
+ 1794299,
+ 1186775,
+ 994694,
+ 1002630,
+ 1608154,
+ 1193063,
+ 992758,
+ 1003254,
+ 1604090,
+ 994982,
+ 1004902,
+ 986278,
+ 1605514,
+ 1004726,
+ 1177159,
+ 1241688,
+ 2059629,
+ 1515449,
+ 1378216,
+ 1319288,
+ 1890844,
+ 1401560,
+ 1290488,
+ 1395225,
+ 2002172,
+ 1399225,
+ 1322888,
+ 1189847,
+ 1801083,
+ 1183751,
+ 1202936,
+ 1202295,
+ 1788827,
+ 1303080,
+ 1199767,
+ 1102839,
+ 1802155,
+ 1200679,
+ 1130311,
+ 1080567,
+ 1808555,
+ 1191975,
+ 1208039,
+ 1197848,
+ 1806795,
+ 1313048,
+ 1075158,
+ 1205032,
+ 1801451,
+ 1192311,
+ 1309912,
+ 1206279,
+ 1890508,
+ 1192951,
+ 1201863,
+ 1097287,
+ 1905596,
+ 1195847,
+ 1198615,
+ 1196648,
+ 1806635,
+ 3013778,
+ 1294952,
+ 1224936,
+ 1867035,
+ 1227863,
+ 2766529,
+ 994246,
+ 1600874,
+ 995414,
+ 998070,
+ 902726,
+ 1600938,
+ 1017302,
+ 985718,
+ 1000342,
+ 2711681,
+ 996950,
+ 996486,
+ 1000374,
+ 1599354,
+ 997318,
+ 999062,
+ 1100919,
+ 1600185,
+ 995478,
+ 999462,
+ 1002807,
+ 1598441,
+ 998935,
+ 1003558,
+ 994614,
+ 1602681,
+ 1403449,
+ 6290134,
+ 1107303,
+ 1598186,
+ 1000486,
+ 1000150,
+ 995414,
+ 1605082,
+ 997526,
+ 997062,
+ 1002982,
+ 1601050,
+ 2802641,
+ 992518,
+ 1001542,
+ 1599946,
+ 996198,
+ 997974,
+ 1002439,
+ 1603385,
+ 997238,
+ 999959,
+ 998054,
+ 1600329,
+ 997574,
+ 1000935,
+ 997302,
+ 1603209,
+ 995719,
+ 1001158,
+ 998678,
+ 1607850,
+ 995014,
+ 996902,
+ 1001574,
+ 1596442,
+ 1000534,
+ 1001558,
+ 996950,
+ 1608810,
+ 1194551,
+ 1098391,
+ 1000838,
+ 1690922,
+ 1000998,
+ 998630,
+ 1007239,
+ 1589913,
+ 994054,
+ 1010551,
+ 1096246,
+ 1610714,
+ 983318,
+ 1830651,
+ 1273640,
+ 1721579,
+ 3983544,
+ 1100663,
+ 993670,
+ 1714154,
+ 996166,
+ 1096631,
+ 1093383,
+ 1602377,
+ 993495,
+ 996870,
+ 1105990,
+ 1607930,
+ 997078,
+ 1091431,
+ 998198,
+ 1604170,
+ 993846,
+ 1001878,
+ 1000518,
+ 1620666,
+ 1084439,
+ 999174,
+ 997718,
+ 1703962,
+ 989574,
+ 999910,
+ 998806,
+ 1602826,
+ 998150,
+ 999622,
+ 1258872,
+ 1648410,
+ 1091975,
+ 995238,
+ 994934,
+ 1602698,
+ 995334,
+ 1002502,
+ 3408277,
+ 1597946,
+ 986310,
+ 1112791,
+ 4307210,
+ 1696042,
+ 1192199,
+ 999815,
+ 997654,
+ 1606425,
+ 1001015,
+ 3484773,
+ 1018598,
+ 3691639,
+ 1196151,
+ 997286,
+ 986678,
+ 1522233,
+ 971718,
+ 898790,
+ 901429,
+ 1500793,
+ 898966,
+ 898405,
+ 901046,
+ 1614730,
+ 988870,
+ 1218119,
+ 1219400,
+ 1982284,
+ 1101239,
+ 1217383,
+ 1082887,
+ 1804459,
+ 1096966,
+ 1202648,
+ 1199367,
+ 1697354,
+ 1201736,
+ 1106886,
+ 1193368,
+ 1798827,
+ 1203399,
+ 1197207,
+ 1096759,
+ 1796667,
+ 1204727,
+ 1243816,
+ 1060278,
+ 1693754,
+ 1199623,
+ 1198200,
+ 1200951,
+ 1799579,
+ 1102694,
+ 1186808,
+ 978198,
+ 3700134,
+ 898374,
+ 898389,
+ 900742,
+ 1499641,
+ 899509,
+ 901030,
+ 898357,
+ 1499466,
+ 900261,
+ 899174,
+ 900437,
+ 1500057,
+ 899062,
+ 903461,
+ 896502,
+ 1502169,
+ 898293,
+ 899062,
+ 900293,
+ 1500233,
+ 898870,
+ 899734,
+ 899989,
+ 1500313,
+ 900998,
+ 899269,
+ 899142,
+ 1501081,
+ 899845,
+ 898630,
+ 899973,
+ 1715563,
+ 1204375,
+ 1121095,
+ 1290664,
+ 1786779,
+ 1108759,
+ 1185511,
+ 1114695,
+ 3158627,
+ 1015398,
+ 1043798,
+ 1481626,
+ 1699146,
+ 1818891,
+ 1084487,
+ 1192727,
+ 1578010,
+ 891509,
+ 4124713,
+ 1988268,
+ 1593066,
+ 897622,
+ 3504101,
+ 894645,
+ 1504506,
+ 895845,
+ 899638,
+ 898949,
+ 1500057,
+ 899798,
+ 899493,
+ 898790,
+ 1500969,
+ 899109,
+ 911110,
+ 1675770,
+ 2015069,
+ 1104246,
+ 2609696,
+ 991094,
+ 1603194,
+ 992982,
+ 999846,
+ 1000086,
+ 1606826,
+ 1194311,
+ 999927,
+ 998214,
+ 1603993,
+ 2201886,
+ 2803185,
+ 1899916,
+ 1204919,
+ 2803250,
+ 2597215,
+ 1801771,
+ 2283614,
+ 3784199,
+ 3628055,
+ 3023810,
+ 1676538,
+ 3611350,
+ 1107511,
+ 1210440,
+ 1795771,
+ 1497689,
+ 1302568,
+ 2098396,
+ 1799019,
+ 3101523,
+ 1890044,
+ 1206935,
+ 1069175,
+ 1191527,
+ 1700554,
+ 1208424,
+ 10910258,
+ 1313176,
+ 5867188,
+ 8997511,
+ 11999674,
+ 4996494,
+ 11001091,
+ 996390,
+ 2996899,
+ 8011904,
+ 3993449,
+ 918629,
+ 1592714,
+ 1002198,
+ 993254,
+ 1001479,
+ 1601849,
+ 1007110,
+ 3406229,
+ 992022,
+ 1606378,
+ 998902,
+ 1881004,
+ 897093,
+ 1501945,
+ 1805611,
+ 893862,
+ 897285,
+ 1502298,
+ 907669,
+ 890229,
+ 898646,
+ 1500569,
+ 900214,
+ 899301,
+ 900038,
+ 1502361,
+ 896709,
+ 900918,
+ 900229,
+ 1499401,
+ 898598,
+ 901237,
+ 900166,
+ 1500377,
+ 898806,
+ 899221,
+ 899318,
+ 1501273,
+ 898853,
+ 898438,
+ 899861,
+ 1501225,
+ 900022,
+ 899621,
+ 898790,
+ 1501273,
+ 899637,
+ 3209028,
+ 1001910,
+ 1595914,
+ 895845,
+ 999287,
+ 899461,
+ 1600554,
+ 898165,
+ 899174,
+ 901109,
+ 1499481,
+ 899510,
+ 899717,
+ 902742,
+ 1497209,
+ 900822,
+ 898533,
+ 899254,
+ 1501513,
+ 899413,
+ 899366,
+ 899909,
+ 1500729,
+ 898838,
+ 899173,
+ 901638,
+ 1533929,
+ 1193671,
+ 1095191,
+ 989334,
+ 1887548,
+ 1305896,
+ 1198311,
+ 1201271,
+ 1708699,
+ 1297288,
+ 1412120,
+ 1374089,
+ 1818619,
+ 1204103,
+ 985270,
+ 1123959,
+ 1697146,
+ 1269256,
+ 2247790,
+ 5067903,
+ 9905420,
+ 1706347,
+ 5029231,
+ 1607705,
+ 3066803,
+ 1189543,
+ 1089271,
+ 994726,
+ 1615178,
+ 1187623,
+ 1104759,
+ 1101383,
+ 1698218,
+ 1095751,
+ 1107142,
+ 1203352,
+ 1697402,
+ 1091287,
+ 1100343,
+ 1099302,
+ 1602346,
+ 1091655,
+ 1110615,
+ 1195143,
+ 1694810,
+ 1106967,
+ 1101799,
+ 1194855,
+ 1812491,
+ 1318456,
+ 1208536,
+ 1194391,
+ 1770267,
+ 1184567,
+ 1602714,
+ 982902,
+ 1503225,
+ 995990,
+ 897205,
+ 900214,
+ 2404271,
+ 896213,
+ 900822,
+ 897973,
+ 1501401,
+ 898598,
+ 900261,
+ 899446,
+ 1499593,
+ 900341,
+ 901174,
+ 898309,
+ 1501465,
+ 898294,
+ 899813,
+ 901798,
+ 1579786,
+ 918533,
+ 1525434,
+ 1202471,
+ 4107449,
+ 999606,
+ 996086,
+ 1017990,
+ 1566634,
+ 992806,
+ 1007814,
+ 992854,
+ 1630522,
+ 988870,
+ 981526,
+ 990390,
+ 1496025,
+ 938534,
+ 7084011,
+ 1998973,
+ 2999810,
+ 1945484,
+ 1166183,
+ 1878923,
+ 2409487,
+ 992118,
+ 994358,
+ 1005462,
+ 1594714,
+ 994982,
+ 1000438,
+ 1102903,
+ 1602586,
+ 993974,
+ 1000774,
+ 1100967,
+ 1607146,
+ 989014,
+ 995862,
+ 1000998,
+ 1601962,
+ 1005078,
+ 1003846,
+ 998390,
+ 1597642,
+ 995942,
+ 999078,
+ 997574,
+ 1601946,
+ 995030,
+ 1001062,
+ 1098647,
+ 1601881,
+ 1000807,
+ 1114486,
+ 988022,
+ 1596906,
+ 996582,
+ 1315224,
+ 1404169,
+ 1695978,
+ 991014,
+ 995270,
+ 1011511,
+ 1586585,
+ 1005862,
+ 1107831,
+ 1094455,
+ 1596378,
+ 994854,
+ 1097574,
+ 998262,
+ 1600922,
+ 1005510,
+ 1005447,
+ 990758,
+ 1619065,
+ 993910,
+ 1087351,
+ 995654,
+ 1893196,
+ 4138361,
+ 1254568,
+ 8199522,
+ 1939292,
+ 1196647,
+ 1097495,
+ 1001942,
+ 1596410,
+ 1096742,
+ 995286,
+ 1000486,
+ 1602970,
+ 1096935,
+ 997382,
+ 999926,
+ 1604698,
+ 995590,
+ 999446,
+ 999030,
+ 2506655,
+ 3009683,
+ 1049990,
+ 3659879,
+ 2703280,
+ 3384133,
+ 2713488,
+ 3415909,
+ 2778785,
+ 3309988,
+ 2704305,
+ 3308068,
+ 2716625,
+ 3439765,
+ 2800273,
+ 3645766,
+ 2891026,
+ 3469237,
+ 3985640,
+ 1584762,
+ 994054,
+ 1798651,
+ 3100995,
+ 1014854,
+ 4197514,
+ 3306996,
+ 1712954,
+ 1081735,
+ 997622,
+ 998278,
+ 1604362,
+ 997766,
+ 1001558,
+ 997766,
+ 1605418,
+ 1001542,
+ 998518,
+ 1000006,
+ 1597642,
+ 993366,
+ 1000758,
+ 1101895,
+ 1604714,
+ 997750,
+ 996502,
+ 998006,
+ 1602250,
+ 1000918,
+ 997718,
+ 1000486,
+ 1605034,
+ 996086,
+ 997350,
+ 1100167,
+ 1602170,
+ 995942,
+ 1000870,
+ 998214,
+ 1602810,
+ 997942,
+ 998214,
+ 999238,
+ 1604666,
+ 995798,
+ 998134,
+ 999014,
+ 1605338,
+ 998486,
+ 1001206,
+ 1031959,
+ 1674666,
+ 992342,
+ 994678,
+ 1103367,
+ 1599273,
+ 996150,
+ 997735,
+ 999894,
+ 1609385,
+ 997159,
+ 1003094,
+ 990086,
+ 1596522,
+ 1008342,
+ 1086294,
+ 1003847,
+ 1590217,
+ 1095847,
+ 1009622,
+ 995558,
+ 1593482,
+ 998790,
+ 1042822,
+ 973286,
+ 4315883,
+ 1417384,
+ 1069207,
+ 1000294,
+ 1604890,
+ 1089975,
+ 1003558,
+ 991846,
+ 1616586,
+ 1089238,
+ 1195879,
+ 1094759,
+ 1611146,
+ 988070,
+ 1000566,
+ 998630,
+ 1603690,
+ 994438,
+ 1000998,
+ 1004934,
+ 4335355,
+ 964918,
+ 984166,
+ 893877,
+ 1501129,
+ 898310,
+ 900373,
+ 900374,
+ 1499129,
+ 900614,
+ 901397,
+ 897894,
+ 1500201,
+ 900645,
+ 898118,
+ 900869,
+ 1511193,
+ 887110,
+ 900501,
+ 899526,
+ 1501641,
+ 898518,
+ 902133,
+ 896949,
+ 1500794,
+ 900149,
+ 899862,
+ 900261,
+ 1498745,
+ 899846,
+ 900341,
+ 900230,
+ 1500457,
+ 898485,
+ 899990,
+ 900037,
+ 1502778,
+ 897877,
+ 900470,
+ 898757,
+ 1499673,
+ 924406,
+ 1195815,
+ 980822,
+ 1496617,
+ 920518,
+ 992198,
+ 1003686,
+ 1608730,
+ 1191687,
+ 1204712,
+ 987718,
+ 1609705,
+ 994631,
+ 2811089,
+ 994950,
+ 1578217,
+ 897814,
+ 899941,
+ 900870,
+ 1514009,
+ 1002262,
+ 1117959,
+ 1082743,
+ 1685770,
+ 4224074,
+ 1009558,
+ 1016070,
+ 1571018,
+ 1097479,
+ 998918,
+ 999158,
+ 4348554,
+ 1049655,
+ 982710,
+ 1010678,
+ 1487225,
+ 898629,
+ 898150,
+ 918662,
+ 1598697,
+ 980566,
+ 902086,
+ 3239684,
+ 1560569,
+ 898998,
+ 906165,
+ 897542,
+ 1496425,
+ 903621,
+ 895110,
+ 905205,
+ 1512154,
+ 1102822,
+ 1168167,
+ 1118919,
+ 1593402,
+ 894982,
+ 900853,
+ 898805,
+ 1529466,
+ 1077590,
+ 1204920,
+ 997398,
+ 1703034,
+ 1307208,
+ 1298104,
+ 1292840,
+ 1802539,
+ 1101991,
+ 1797787,
+ 3210419,
+ 985494,
+ 1894140,
+ 1103639,
+ 2408558,
+ 2691617,
+ 3407989,
+ 2506399,
+ 1082663,
+ 2302958,
+ 2503455,
+ 3305268,
+ 2499583,
+ 3306613,
+ 2492671,
+ 979430,
+ 2403919,
+ 896597,
+ 1705210,
+ 892934,
+ 1498569,
+ 6157878,
+ 947765,
+ 7524654,
+ 976870,
+ 1096263,
+ 2718209,
+ 3700182,
+ 1001622,
+ 1694859,
+ 996646,
+ 1604490,
+ 793428,
+ 1805723,
+ 991623,
+ 1707082,
+ 992998,
+ 1000054,
+ 996470,
+ 1606314,
+ 995318,
+ 1099191,
+ 1000966,
+ 1706154,
+ 1695643,
+ 796853,
+ 1803643,
+ 1702170,
+ 1696474,
+ 996230,
+ 3108275,
+ 1093831,
+ 1105767,
+ 1697306,
+ 1600122,
+ 993222,
+ 999398,
+ 3211636,
+ 990182,
+ 1902443,
+ 3107123,
+ 1092231,
+ 1701595,
+ 3203747,
+ 990614,
+ 998678,
+ 1000006,
+ 1602986,
+ 994742,
+ 999174,
+ 998454,
+ 1703979,
+ 997830,
+ 1001254,
+ 1000630,
+ 1601082,
+ 996246,
+ 1109015,
+ 1387288,
+ 2104477,
+ 1196839,
+ 1098231,
+ 993990,
+ 1896652,
+ 1010422,
+ 1005062,
+ 995958,
+ 1605546,
+ 999782,
+ 989782,
+ 999254,
+ 1604938,
+ 990758,
+ 1000838,
+ 998710,
+ 1625322,
+ 1076119,
+ 995382,
+ 1008998,
+ 2517136,
+ 1182375,
+ 1241159,
+ 1156407,
+ 1601514,
+ 1104967,
+ 1395352,
+ 1095223,
+ 1653674,
+ 1052007,
+ 998774,
+ 993654,
+ 1602794,
+ 996406,
+ 997526,
+ 1001686,
+ 1713834,
+ 986902,
+ 997975,
+ 1008374,
+ 1606601,
+ 1085783,
+ 1098519,
+ 996902,
+ 1603082,
+ 1007030,
+ 993526,
+ 997286,
+ 1601082,
+ 995558,
+ 999430,
+ 1000326,
+ 1619834,
+ 1080615,
+ 992470,
+ 998694,
+ 1603210,
+ 998342,
+ 997094,
+ 1002566,
+ 1608522,
+ 996358,
+ 995174,
+ 995238,
+ 1600058,
+ 998470,
+ 996150,
+ 1016518,
+ 1710347,
+ 1068502,
+ 1258968,
+ 1042070,
+ 1495113,
+ 913398,
+ 992198,
+ 997030,
+ 1715707,
+ 1098774,
+ 986566,
+ 1081527,
+ 1612202,
+ 1000662,
+ 1106855,
+ 1095894,
+ 1608490,
+ 1017014,
+ 971894,
+ 1002150,
+ 1693963,
+ 1298552,
+ 3001538,
+ 2998546,
+ 3600774,
+ 2397631,
+ 3002690,
+ 908806,
+ 1589914,
+ 897445,
+ 900309,
+ 895926,
+ 1520857,
+ 985974,
+ 895430,
+ 1098886,
+ 1498698,
+ 899605,
+ 899782,
+ 1005926,
+ 1521737,
+ 4617724,
+ 1099335,
+ 1330200,
+ 1809323,
+ 1164919,
+ 1181528,
+ 1105350,
+ 1631162,
+ 1269576,
+ 1081687,
+ 994342,
+ 1617418,
+ 1087750,
+ 1002486,
+ 1019575,
+ 1692186,
+ 1189431,
+ 1097975,
+ 1105703,
+ 1697674,
+ 1259256,
+ 1240567,
+ 1214792,
+ 1793179,
+ 1292232,
+ 1089926,
+ 1125623,
+ 1720475,
+ 1153815,
+ 1298168,
+ 1307384,
+ 1698810,
+ 1082231,
+ 993622,
+ 1006614,
+ 1596121,
+ 1116487,
+ 1098519,
+ 998118,
+ 7315293,
+ 1196711,
+ 1189351,
+ 993127,
+ 1604505,
+ 1192568,
+ 1002470,
+ 997094,
+ 1598218,
+ 985814,
+ 895525,
+ 3929032,
+ 1697290,
+ 1025079,
+ 964502,
+ 996358,
+ 1606569,
+ 992311,
+ 1001686,
+ 997350,
+ 1603370,
+ 1128966,
+ 1068999,
+ 997574,
+ 1606122,
+ 993190,
+ 1001558,
+ 997238,
+ 1504521,
+ 1699147,
+ 3206195,
+ 4917822,
+ 1573306,
+ 989574,
+ 1614202,
+ 1914780,
+ 1477385,
+ 1607241,
+ 3188052,
+ 2493679,
+ 3102323,
+ 2617760,
+ 3301860,
+ 2796417,
+ 3495606,
+ 2911969,
+ 5292961,
+ 1089254,
+ 999463,
+ 1618601,
+ 2487968,
+ 3198003,
+ 2806321,
+ 3108659,
+ 1038071,
+ 2849905,
+ 3179619,
+ 18240688,
+ 6672329,
+ 1586361,
+ 896582,
+ 898581,
+ 904102,
+ 1495545,
+ 898629,
+ 899798,
+ 899909,
+ 1500058,
+ 899205,
+ 899622,
+ 899509,
+ 1602346,
+ 896613,
+ 901142,
+ 899157,
+ 1501897,
+ 897510,
+ 904949,
+ 895414,
+ 1515273,
+ 2636832,
+ 962854,
+ 884518,
+ 1501417,
+ 897589,
+ 905430,
+ 893477,
+ 1499369,
+ 904614,
+ 894757,
+ 899334,
+ 1500937,
+ 1601482,
+ 909893,
+ 998775,
+ 1618281,
+ 1034103,
+ 1153415,
+ 993286,
+ 1606106,
+ 996262,
+ 2379246,
+ 1030966,
+ 1618985,
+ 1189256,
+ 1193703,
+ 999590,
+ 1609210,
+ 1204183,
+ 1100471,
+ 1081543,
+ 1606761,
+ 1094279,
+ 1000310,
+ 996294,
+ 1707467,
+ 993766,
+ 1105863,
+ 993510,
+ 1606633,
+ 1095447,
+ 3372229,
+ 3327860,
+ 3381109,
+ 989606,
+ 900197,
+ 896406,
+ 1502713,
+ 898405,
+ 898678,
+ 899093,
+ 1500186,
+ 899813,
+ 899878,
+ 899077,
+ 1499977,
+ 902470,
+ 896805,
+ 900422,
+ 1499849,
+ 899589,
+ 894118,
+ 901525,
+ 1498137,
+ 899654,
+ 901525,
+ 900646,
+ 1498569,
+ 899014,
+ 900501,
+ 898582,
+ 1502137,
+ 898853,
+ 900630,
+ 898533,
+ 1501129,
+ 895894,
+ 931190,
+ 1106966,
+ 1784843,
+ 1112871,
+ 1086711,
+ 1009478,
+ 1596586,
+ 1087478,
+ 989110,
+ 1096999,
+ 1606074,
+ 1006742,
+ 997542,
+ 985670,
+ 1494361,
+ 999062,
+ 902134,
+ 896629,
+ 1896476,
+ 1028982,
+ 2437743,
+ 1044790,
+ 1596666,
+ 897686,
+ 899365,
+ 902646,
+ 1508697,
+ 986358,
+ 903461,
+ 895670,
+ 1500905,
+ 1015814,
+ 891910,
+ 907669,
+ 1584346,
+ 899221,
+ 898470,
+ 903718,
+ 1496889,
+ 930805,
+ 978838,
+ 998758,
+ 1491049,
+ 907062,
+ 898166,
+ 902181,
+ 1501289,
+ 902854,
+ 902021,
+ 993318,
+ 1490937,
+ 901382,
+ 898277,
+ 900566,
+ 1522025,
+ 977814,
+ 900806,
+ 903813,
+ 1496297,
+ 902230,
+ 903493,
+ 891766,
+ 1500713,
+ 900053,
+ 909110,
+ 907254,
+ 3516885,
+ 980886,
+ 998614,
+ 1004198,
+ 2710513,
+ 1245943,
+ 1320505,
+ 910117,
+ 2396767,
+ 999254,
+ 906485,
+ 1014775,
+ 1593177,
+ 1008454,
+ 991639,
+ 987958,
+ 4354362,
+ 945670,
+ 894453,
+ 998263,
+ 1726570,
+ 973142,
+ 899173,
+ 898502,
+ 1500697,
+ 898854,
+ 899269,
+ 901478,
+ 1500697,
+ 901925,
+ 897270,
+ 1034582,
+ 4094057,
+ 1191271,
+ 994758,
+ 983270,
+ 1533242,
+ 968790,
+ 898357,
+ 905782,
+ 1503449,
+ 1510649,
+ 2396511,
+ 1104711,
+ 1896203,
+ 3207108,
+ 990086,
+ 1901484,
+ 997094,
+ 2301614,
+ 1084662,
+ 1699259,
+ 897605,
+ 2300526,
+ 999254,
+ 1801340,
+ 818420,
+ 2302959,
+ 2997666,
+ 5619970,
+ 1791099,
+ 992358,
+ 1615018,
+ 2480783,
+ 1116935,
+ 1777259,
+ 1098823,
+ 997334,
+ 1000102,
+ 1677098,
+ 2627040,
+ 4301402,
+ 989094,
+ 997079,
+ 900917,
+ 1519561,
+ 4092009,
+ 4229754,
+ 1288888,
+ 1182647,
+ 1096391,
+ 1704234,
+ 2622832,
+ 1191832,
+ 1752186,
+ 3940808,
+ 1584330,
+ 992854,
+ 1000326,
+ 12216475,
+ 1572602,
+ 4416795,
+ 989942,
+ 999366,
+ 1604505,
+ 2507856,
+ 990934,
+ 1700250,
+ 994070,
+ 1000790,
+ 990423,
+ 1577689,
+ 1714811,
+ 2745744,
+ 972742,
+ 2416687,
+ 1007702,
+ 1088151,
+ 1086855,
+ 1601257,
+ 996518,
+ 990518,
+ 908742,
+ 2102461,
+ 1005494,
+ 993078,
+ 3030083,
+ 1821275,
+ 1306568,
+ 1118471,
+ 1039782,
+ 1718442,
+ 1249528,
+ 1218344,
+ 1107734,
+ 1708411,
+ 1192007,
+ 1847211,
+ 1185271,
+ 1768283,
+ 1314424,
+ 1196376,
+ 1179127,
+ 1606986,
+ 1194967,
+ 1026838,
+ 4644077,
+ 1989004,
+ 1303048,
+ 1302024,
+ 1212519,
+ 1696587,
+ 1299431,
+ 1232456,
+ 1377992,
+ 1970444,
+ 1256440,
+ 1239896,
+ 1303752,
+ 1841675,
+ 1218919,
+ 1221496,
+ 1176967,
+ 1905964,
+ 1316792,
+ 1295128,
+ 1207639,
+ 1898524,
+ 1318552,
+ 1250023,
+ 1176231,
+ 1823228,
+ 1103478,
+ 1214136,
+ 1056214,
+ 1801707,
+ 989990,
+ 1308424,
+ 1194104,
+ 1596585,
+ 990614,
+ 1012567,
+ 1610441,
+ 1583866,
+ 1005878,
+ 988230,
+ 1466425,
+ 1957372,
+ 1086375,
+ 1011190,
+ 983830,
+ 1502921,
+ 993974,
+ 1018806,
+ 990391,
+ 1595497,
+ 1071655,
+ 1032822,
+ 991350,
+ 1605194,
+ 986790,
+ 997302,
+ 1005462,
+ 1607978,
+ 1003094,
+ 997830,
+ 994646,
+ 1618426,
+ 1083671,
+ 996838,
+ 1001830,
+ 2400911,
+ 994998,
+ 1006662,
+ 1415689,
+ 1788987,
+ 1196615,
+ 1070822,
+ 1562650,
+ 1795675,
+ 1231191,
+ 1233528,
+ 1214103,
+ 1683403,
+ 998678,
+ 1153015,
+ 1043574,
+ 1707435,
+ 1091526,
+ 995590,
+ 1106423,
+ 3605062,
+ 1203624,
+ 1202023,
+ 1296184,
+ 1680874,
+ 1407129,
+ 1107335,
+ 1003190,
+ 1762970,
+ 1010407,
+ 1006054,
+ 1207127,
+ 3805783,
+ 999383,
+ 991478,
+ 3503781,
+ 1598506,
+ 994118,
+ 1099015,
+ 999574,
+ 1608393,
+ 996679,
+ 1009110,
+ 1009910,
+ 1694010,
+ 989670,
+ 978822,
+ 915974,
+ 3484117,
+ 1006950,
+ 995990,
+ 910470,
+ 1589978,
+ 896837,
+ 898790,
+ 899589,
+ 1500393,
+ 899254,
+ 901493,
+ 897734,
+ 1501177,
+ 898917,
+ 1009767,
+ 1015910,
+ 1725850,
+ 1163031,
+ 4073849,
+ 1017479,
+ 4506059,
+ 991158,
+ 996934,
+ 899686,
+ 1510025,
+ 989430,
+ 897813,
+ 911526,
+ 1691578,
+ 1222872,
+ 1285448,
+ 1300360,
+ 1907115,
+ 1377561,
+ 1008854,
+ 996246,
+ 1643386,
+ 2860209,
+ 3394773,
+ 1004358,
+ 2008573,
+ 989110,
+ 2396446,
+ 899222,
+ 1709418,
+ 3225428,
+ 2698800,
+ 3572390,
+ 2618144,
+ 3466085,
+ 3094787,
+ 3515846,
+ 3103971,
+ 3687334,
+ 3495126,
+ 3606790,
+ 2987346,
+ 1218215,
+ 1791259,
+ 1883084,
+ 1259496,
+ 1270263,
+ 2474159,
+ 2510160,
+ 1228855,
+ 1798459,
+ 975414,
+ 1210600,
+ 4046216,
+ 1665851,
+ 1055062,
+ 1038278,
+ 1042407,
+ 1660810,
+ 4313786,
+ 1078823,
+ 1256327,
+ 1656667,
+ 1209447,
+ 1077975,
+ 1098118,
+ 1615306,
+ 1194327,
+ 1202488,
+ 987158,
+ 1602730,
+ 995078,
+ 998662,
+ 998358,
+ 1613530,
+ 1205431,
+ 1187015,
+ 1094039,
+ 1619242,
+ 1185623,
+ 995606,
+ 1200968,
+ 1608089,
+ 1089047,
+ 999462,
+ 1014918,
+ 1586634,
+ 977126,
+ 999334,
+ 906134,
+ 1492361,
+ 899269,
+ 899718,
+ 905349,
+ 1494538,
+ 900245,
+ 899029,
+ 901590,
+ 1498761,
+ 998838,
+ 1000454,
+ 898790,
+ 1500633,
+ 899397,
+ 899990,
+ 899670,
+ 1510505,
+ 891333,
+ 897526,
+ 965510,
+ 1535689,
+ 928902,
+ 1039270,
+ 939126,
+ 1603001,
+ 1003463,
+ 1205415,
+ 1296136,
+ 1711690,
+ 1190552,
+ 1110726,
+ 1096983,
+ 1588442,
+ 1338568,
+ 1307288,
+ 1055366,
+ 1886252,
+ 1008886,
+ 1002454,
+ 1019143,
+ 21790677,
+ 1090438,
+ 988694,
+ 995590,
+ 1613370,
+ 1301128,
+ 1015718,
+ 1189432,
+ 1595321,
+ 994663,
+ 998214,
+ 998806,
+ 1633178,
+ 1068710,
+ 994438,
+ 1133863,
+ 1874684,
+ 998662,
+ 1367128,
+ 4942142,
+ 1786411,
+ 1203400,
+ 1096326,
+ 997206,
+ 1772075,
+ 1225608,
+ 985606,
+ 896277,
+ 1501913,
+ 1014887,
+ 1208631,
+ 1307848,
+ 1685066,
+ 991478,
+ 1213336,
+ 1099302,
+ 1687786,
+ 1019942,
+ 1237544,
+ 1032390,
+ 1698538,
+ 1011047,
+ 970229,
+ 904278,
+ 1520777,
+ 7117932,
+ 2132189,
+ 950566,
+ 4359402,
+ 7360925,
+ 35678778,
+ 1330760,
+ 1947196,
+ 1337720,
+ 1340393,
+ 1259239,
+ 1951516,
+ 1270504,
+ 1265224,
+ 1087446,
+ 1704475,
+ 1293256,
+ 1292455,
+ 1106870,
+ 1701099,
+ 993958,
+ 997126,
+ 994278,
+ 1611418,
+ 994758,
+ 985430,
+ 898133,
+ 1498058,
+ 899029,
+ 1028006,
+ 874694,
+ 1499161,
+ 897845,
+ 899622,
+ 900453,
+ 1499657,
+ 999686,
+ 899542,
+ 900166,
+ 1499609,
+ 900981,
+ 931878,
+ 1091671,
+ 5302528,
+ 975878,
+ 896325,
+ 899446,
+ 1500889,
+ 921430,
+ 988182,
+ 998854,
+ 4436907,
+ 953366,
+ 897637,
+ 901302,
+ 4667740,
+ 1158471,
+ 1053559,
+ 1148695,
+ 1945228,
+ 1101094,
+ 1184744,
+ 1166535,
+ 1739882,
+ 1261208,
+ 1295592,
+ 976982,
+ 1517737,
+ 978454,
+ 897654,
+ 1127335,
+ 1885771,
+ 1199031,
+ 1120759,
+ 1085415,
+ 2201373,
+ 1195752,
+ 1190247,
+ 1237320,
+ 1885211,
+ 1190951,
+ 1192040,
+ 1198839,
+ 1710826,
+ 1293384,
+ 1105815,
+ 1099431,
+ 1691754,
+ 1199031,
+ 1196808,
+ 1111223,
+ 1685802,
+ 1197479,
+ 1204568,
+ 1096198,
+ 1908156,
+ 1197431,
+ 1201960,
+ 1096502,
+ 1706203,
+ 1193991,
+ 1302296,
+ 1206903,
+ 1805979,
+ 980278,
+ 995686,
+ 999207,
+ 1600281,
+ 1109207,
+ 1306360,
+ 1093815,
+ 1592057,
+ 998935,
+ 996918,
+ 1002022,
+ 1603834,
+ 1002502,
+ 1001398,
+ 1000358,
+ 1598714,
+ 994646,
+ 1002838,
+ 1003078,
+ 1599930,
+ 984422,
+ 897685,
+ 919174,
+ 1484137,
+ 897525,
+ 900358,
+ 899493,
+ 1499626,
+ 899733,
+ 912582,
+ 909301,
+ 1684571,
+ 895285,
+ 4404139,
+ 1495753,
+ 798869,
+ 1901467,
+ 897798,
+ 1500185,
+ 900022,
+ 900197,
+ 899830,
+ 1500905,
+ 898629,
+ 899510,
+ 899429,
+ 1500601,
+ 898950,
+ 911206,
+ 3110547,
+ 1001142,
+ 987078,
+ 3205555,
+ 988902,
+ 2519328,
+ 1595465,
+ 991799,
+ 999574,
+ 1907291,
+ 1597354,
+ 2503455,
+ 985734,
+ 1608362,
+ 1904332,
+ 2830033,
+ 3471589,
+ 2681873,
+ 1497641,
+ 925637,
+ 2886434,
+ 3286100,
+ 898870,
+ 902757,
+ 1523658,
+ 1976876,
+ 1016710,
+ 1803803,
+ 1713050,
+ 1103063,
+ 2296398,
+ 3995480,
+ 2997043,
+ 1996124,
+ 2000764,
+ 2000572,
+ 1996941,
+ 1999644,
+ 1782091,
+ 1116807,
+ 1694154,
+ 994310,
+ 997574,
+ 1003638,
+ 1601514,
+ 1895740,
+ 997366,
+ 1016982,
+ 2003420,
+ 1082327,
+ 998326,
+ 1098551,
+ 1603081,
+ 994246,
+ 904070,
+ 1802091,
+ 1598458,
+ 994358,
+ 997846,
+ 998070,
+ 1612410,
+ 993862,
+ 3305588,
+ 1898156,
+ 7040555,
+ 4999838,
+ 1997788,
+ 7060140,
+ 1686490,
+ 1394264,
+ 1215160,
+ 3108387,
+ 976742,
+ 1895371,
+ 998791,
+ 1612265,
+ 4125994,
+ 3180467,
+ 1596794,
+ 992502,
+ 996422,
+ 1906332,
+ 3109539,
+ 986246,
+ 1000454,
+ 1599898,
+ 2506431,
+ 3506357,
+ 985222,
+ 996150,
+ 3410181,
+ 1096023,
+ 1896123,
+ 999655,
+ 1599209,
+ 997270,
+ 997463,
+ 1001750,
+ 1703194,
+ 997318,
+ 999222,
+ 998406,
+ 1604954,
+ 993270,
+ 1004102,
+ 1097863,
+ 1603802,
+ 997446,
+ 999734,
+ 999206,
+ 1602954,
+ 995494,
+ 998726,
+ 1000886,
+ 1600826,
+ 998166,
+ 998470,
+ 999910,
+ 1604890,
+ 994614,
+ 999478,
+ 999303,
+ 1603193,
+ 995782,
+ 1001495,
+ 999014,
+ 1606617,
+ 995911,
+ 997878,
+ 1003014,
+ 1684234,
+ 1204871,
+ 1215256,
+ 1288680,
+ 1792715,
+ 990006,
+ 916453,
+ 1201016,
+ 1610601,
+ 1000295,
+ 1080534,
+ 1020454,
+ 1580570,
+ 1021590,
+ 1124583,
+ 1050071,
+ 1761386,
+ 1047431,
+ 1067542,
+ 1034839,
+ 1699866,
+ 992966,
+ 996374,
+ 1121495,
+ 1686826,
+ 998086,
+ 1109223,
+ 4002969,
+ 1689114,
+ 997542,
+ 999574,
+ 995974,
+ 1631162,
+ 1209352,
+ 955030,
+ 992438,
+ 1776011,
+ 1257223,
+ 969302,
+ 1005238,
+ 1594106,
+ 999382,
+ 994854,
+ 1000550,
+ 1601578,
+ 997062,
+ 1004070,
+ 997942,
+ 1598538,
+ 997894,
+ 1000086,
+ 999366,
+ 1603066,
+ 904134,
+ 997190,
+ 996246,
+ 1607946,
+ 998534,
+ 893653,
+ 992278,
+ 1500314,
+ 898949,
+ 913830,
+ 888789,
+ 1496617,
+ 900678,
+ 898965,
+ 908934,
+ 1639210,
+ 951910,
+ 899957,
+ 899990,
+ 1620410,
+ 978677,
+ 1012343,
+ 1201751,
+ 1714619,
+ 970677,
+ 898774,
+ 900165,
+ 1499274,
+ 900053,
+ 900694,
+ 900277,
+ 1501001,
+ 897206,
+ 900501,
+ 899142,
+ 1624970,
+ 1295832,
+ 1195703,
+ 1309736,
+ 1896092,
+ 1197655,
+ 1293336,
+ 999878,
+ 1711498,
+ 1088487,
+ 994230,
+ 3216964,
+ 2388206,
+ 1094807,
+ 2412655,
+ 2390526,
+ 3120323,
+ 3990441,
+ 2294942,
+ 3300324,
+ 2694880,
+ 3400021,
+ 5541426,
+ 1063207,
+ 1598345,
+ 2597696,
+ 3101059,
+ 1618458,
+ 2677600,
+ 3290757,
+ 3008530,
+ 3291940,
+ 915094,
+ 3487173,
+ 2693712,
+ 894950,
+ 3512229,
+ 2715009,
+ 1574409,
+ 897318,
+ 999670,
+ 900214,
+ 1499529,
+ 999398,
+ 899301,
+ 901206,
+ 1499529,
+ 898038,
+ 901109,
+ 899125,
+ 1500809,
+ 899157,
+ 900198,
+ 899685,
+ 1500809,
+ 898646,
+ 900629,
+ 900070,
+ 1499913,
+ 900358,
+ 899957,
+ 899461,
+ 1501242,
+ 898773,
+ 899686,
+ 899637,
+ 1500537,
+ 899862,
+ 918053,
+ 1204280,
+ 1800219,
+ 1287144,
+ 1209863,
+ 1189207,
+ 1602778,
+ 989910,
+ 998582,
+ 1115527,
+ 4500748,
+ 1208631,
+ 994486,
+ 996230,
+ 1602346,
+ 994630,
+ 1001526,
+ 994422,
+ 1604570,
+ 994598,
+ 1000662,
+ 999958,
+ 1601786,
+ 998006,
+ 998934,
+ 998678,
+ 1619834,
+ 984630,
+ 998967,
+ 997926,
+ 1598377,
+ 995398,
+ 1000727,
+ 1002790,
+ 1600585,
+ 1005735,
+ 991222,
+ 999222,
+ 1604778,
+ 996406,
+ 998758,
+ 1001622,
+ 1600394,
+ 996806,
+ 998374,
+ 998934,
+ 1625338,
+ 1073382,
+ 1001607,
+ 998406,
+ 1606153,
+ 996167,
+ 997334,
+ 999862,
+ 1603690,
+ 994774,
+ 1001318,
+ 998390,
+ 1707578,
+ 996454,
+ 997703,
+ 1001638,
+ 1777355,
+ 1138470,
+ 1288327,
+ 990023,
+ 1597177,
+ 996230,
+ 997830,
+ 1000935,
+ 1602297,
+ 1186536,
+ 1107174,
+ 1318888,
+ 1789643,
+ 989958,
+ 986534,
+ 895798,
+ 1500297,
+ 899270,
+ 899701,
+ 4050297,
+ 2998146,
+ 2003180,
+ 1985853,
+ 2012716,
+ 2992946,
+ 2002860,
+ 1990828,
+ 2012637,
+ 2987954,
+ 1994108,
+ 2013660,
+ 1991117,
+ 3017810,
+ 1975852,
+ 2000380,
+ 2001693,
+ 2297678,
+ 1196423,
+ 1086167,
+ 999430,
+ 1603818,
+ 995334,
+ 996326,
+ 2039164,
+ 1675626,
+ 1099991,
+ 990038,
+ 999174,
+ 1602842,
+ 995302,
+ 996438,
+ 999126,
+ 1604922,
+ 995414,
+ 999222,
+ 1006759,
+ 1599065,
+ 991814,
+ 997639,
+ 999222,
+ 1602953,
+ 999446,
+ 986535,
+ 897013,
+ 1498921,
+ 929430,
+ 1094775,
+ 992038,
+ 3538245,
+ 3680471,
+ 1074454,
+ 998726,
+ 1609114,
+ 1003222,
+ 1033223,
+ 1106310,
+ 1756555,
+ 1095911,
+ 1097783,
+ 1064614,
+ 1633482,
+ 996614,
+ 1001030,
+ 994086,
+ 1607210,
+ 1248440,
+ 938038,
+ 899541,
+ 2517919,
+ 3310549,
+ 975014,
+ 898341,
+ 1499465,
+ 921926,
+ 996182,
+ 993718,
+ 1608778,
+ 1392216,
+ 999990,
+ 1011863,
+ 1601257,
+ 996262,
+ 2591439,
+ 3586678,
+ 3295700,
+ 3704663,
+ 3293044,
+ 3708743,
+ 3388629,
+ 5463105,
+ 1175959,
+ 1088327,
+ 1597578,
+ 1000070,
+ 1003622,
+ 992406,
+ 1602122,
+ 2907633,
+ 1091783,
+ 5527906,
+ 2037004,
+ 2961138,
+ 2707473,
+ 1294344,
+ 3284436,
+ 1296552,
+ 1195399,
+ 1237608,
+ 1779355,
+ 2483439,
+ 1056342,
+ 3368293,
+ 2772945,
+ 4546844,
+ 1650458,
+ 3107731,
+ 1218727,
+ 1669450,
+ 3113699,
+ 1109719,
+ 1874060,
+ 3240819,
+ 1157720,
+ 2602047,
+ 3100531,
+ 2799729,
+ 3203860,
+ 1124407,
+ 1083046,
+ 1785275,
+ 1141031,
+ 1057815,
+ 1106167,
+ 1712394,
+ 1289992,
+ 971222,
+ 1010710,
+ 2008476,
+ 1342537,
+ 3466821,
+ 973910,
+ 1597353,
+ 897910,
+ 905861,
+ 900022,
+ 1497769,
+ 921382,
+ 987350,
+ 1362488,
+ 6338871,
+ 1091591,
+ 995110,
+ 1548073,
+ 12679086,
+ 970229,
+ 997927,
+ 900245,
+ 1499929,
+ 1119703,
+ 1086407,
+ 1101110,
+ 1593130,
+ 996806,
+ 900038,
+ 901829,
+ 1497049,
+ 1102247,
+ 897382,
+ 899573,
+ 1499785,
+ 899846,
+ 900485,
+ 901158,
+ 1499785,
+ 901350,
+ 897461,
+ 901925,
+ 1498330,
+ 1880203,
+ 1051351,
+ 1192327,
+ 1594234,
+ 1100358,
+ 987830,
+ 1004983,
+ 1730698,
+ 2080157,
+ 996646,
+ 1399720,
+ 1688827,
+ 994182,
+ 1000518,
+ 997318,
+ 1597722,
+ 999110,
+ 998694,
+ 1108487,
+ 1804843,
+ 3742151,
+ 1981852,
+ 1115207,
+ 1942331,
+ 901014,
+ 900054,
+ 898373,
+ 1500873,
+ 899558,
+ 899125,
+ 899062,
+ 1500681,
+ 899445,
+ 903558,
+ 896693,
+ 1508074,
+ 891637,
+ 899989,
+ 899350,
+ 1500073,
+ 898726,
+ 900853,
+ 1001574,
+ 1498569,
+ 899430,
+ 900805,
+ 897782,
+ 1500953,
+ 901670,
+ 898117,
+ 909638,
+ 1492153,
+ 897877,
+ 901030,
+ 899237,
+ 1500425,
+ 898550,
+ 899461,
+ 900902,
+ 1499673,
+ 898662,
+ 1000870,
+ 905349,
+ 1503273,
+ 894358,
+ 1001078,
+ 901109,
+ 1499130,
+ 911589,
+ 898326,
+ 1118695,
+ 1568025,
+ 897174,
+ 901141,
+ 1143911,
+ 1560522,
+ 895477,
+ 901094,
+ 897829,
+ 1499321,
+ 902902,
+ 895957,
+ 902054,
+ 1502025,
+ 1101463,
+ 895909,
+ 1299560,
+ 1499337,
+ 899910,
+ 949157,
+ 958838,
+ 1497434,
+ 896357,
+ 1004918,
+ 1118967,
+ 1995964,
+ 1188055,
+ 1191720,
+ 3544773,
+ 1674155,
+ 993526,
+ 998742,
+ 989126,
+ 1602106,
+ 892693,
+ 1107911,
+ 2729920,
+ 1565210,
+ 898614,
+ 899141,
+ 1131463,
+ 1585306,
+ 1197287,
+ 992390,
+ 999734,
+ 1610602,
+ 1199095,
+ 1008119,
+ 1103846,
+ 4202506,
+ 1189591,
+ 988342,
+ 1000854,
+ 3434741,
+ 952710,
+ 902662,
+ 1018022,
+ 1707546,
+ 1079559,
+ 987110,
+ 907814,
+ 1513257,
+ 1689402,
+ 995830,
+ 1008022,
+ 1901452,
+ 1088247,
+ 918533,
+ 997190,
+ 1694811,
+ 994998,
+ 1002678,
+ 1286968,
+ 1716074,
+ 990374,
+ 1109399,
+ 989542,
+ 1589754,
+ 898725,
+ 902358,
+ 907381,
+ 1603738,
+ 988342,
+ 900262,
+ 912453,
+ 1699547,
+ 995766,
+ 1006406,
+ 994326,
+ 1598362,
+ 996950,
+ 1002006,
+ 1098615,
+ 1601386,
+ 997302,
+ 998630,
+ 896853,
+ 1506153,
+ 992102,
+ 897766,
+ 900933,
+ 1504842,
+ 896693,
+ 897206,
+ 901429,
+ 1502857,
+ 896038,
+ 900437,
+ 900406,
+ 1498473,
+ 900053,
+ 906886,
+ 995574,
+ 1597978,
+ 902357,
+ 920518,
+ 1092711,
+ 1605113,
+ 995847,
+ 990678,
+ 1006230,
+ 1607514,
+ 998886,
+ 986310,
+ 1005766,
+ 1610666,
+ 983766,
+ 997478,
+ 997142,
+ 1600202,
+ 1001046,
+ 1020950,
+ 1010422,
+ 1681002,
+ 984390,
+ 895542,
+ 899221,
+ 1499818,
+ 900693,
+ 999430,
+ 1002166,
+ 1500793,
+ 999447,
+ 898709,
+ 1000022,
+ 1501113,
+ 898694,
+ 938998,
+ 972742,
+ 1700234,
+ 1095911,
+ 2407822,
+ 983478,
+ 1499594,
+ 898965,
+ 899318,
+ 901045,
+ 1503945,
+ 895142,
+ 1075510,
+ 1169159,
+ 1631530,
+ 923526,
+ 904358,
+ 897509,
+ 1500425,
+ 901366,
+ 1305784,
+ 1092950,
+ 1500266,
+ 897045,
+ 900854,
+ 898053,
+ 1500729,
+ 906390,
+ 892565,
+ 903862,
+ 1507673,
+ 890005,
+ 902118,
+ 903845,
+ 1500554,
+ 896805,
+ 895462,
+ 899349,
+ 1500153,
+ 901958,
+ 900869,
+ 898566,
+ 1499977,
+ 903493,
+ 895574,
+ 899141,
+ 1501962,
+ 898629,
+ 1000278,
+ 904070,
+ 1500041,
+ 897125,
+ 900774,
+ 897045,
+ 1499033,
+ 899125,
+ 899973,
+ 902726,
+ 1504137,
+ 895318,
+ 897317,
+ 900310,
+ 1500681,
+ 898341,
+ 903446,
+ 899589,
+ 1497609,
+ 900198,
+ 899717,
+ 908038,
+ 1492297,
+ 900470,
+ 916229,
+ 2091293,
+ 1615370,
+ 1086679,
+ 1222647,
+ 1080823,
+ 2833121,
+ 2486799,
+ 1497769,
+ 1189912,
+ 1699418,
+ 2676960,
+ 1117703,
+ 992102,
+ 1615450,
+ 1094615,
+ 1101638,
+ 987703,
+ 1604745,
+ 992470,
+ 994439,
+ 998870,
+ 1612249,
+ 1100663,
+ 990086,
+ 995062,
+ 1708379,
+ 987222,
+ 994726,
+ 1005958,
+ 1710619,
+ 1093414,
+ 2121773,
+ 1086471,
+ 1584922,
+ 997862,
+ 1006294,
+ 991622,
+ 3559606,
+ 1262503,
+ 1186568,
+ 1195943,
+ 1707722,
+ 1131687,
+ 1209304,
+ 1201255,
+ 1689754,
+ 1168039,
+ 1345593,
+ 1153927,
+ 1796523,
+ 1003398,
+ 991878,
+ 1441209,
+ 1663082,
+ 1794347,
+ 1288600,
+ 1096055,
+ 1653642,
+ 1957532,
+ 2124957,
+ 972406,
+ 1593225,
+ 1014422,
+ 1098119,
+ 1197255,
+ 1584026,
+ 1013638,
+ 985782,
+ 1104103,
+ 1597642,
+ 994934,
+ 1001574,
+ 4337675,
+ 1799163,
+ 1187527,
+ 1186903,
+ 1104567,
+ 1595530,
+ 993350,
+ 1004646,
+ 999318,
+ 1605946,
+ 1199527,
+ 1090103,
+ 998278,
+ 1879819,
+ 1339097,
+ 1200695,
+ 1183863,
+ 1623658,
+ 1174903,
+ 1105463,
+ 1097575,
+ 1803707,
+ 1097526,
+ 1044967,
+ 1046182,
+ 1602906,
+ 1096599,
+ 999206,
+ 1007542,
+ 1602490,
+ 1198951,
+ 2900978,
+ 1097751,
+ 1797035,
+ 1115702,
+ 1177096,
+ 1001478,
+ 1704234,
+ 1193175,
+ 995223,
+ 1004310,
+ 1600473,
+ 1096663,
+ 999286,
+ 1200152,
+ 1597913,
+ 1098471,
+ 1000390,
+ 998838,
+ 1614922,
+ 1199799,
+ 1085351,
+ 997462,
+ 1613242,
+ 990822,
+ 1101335,
+ 986934,
+ 1609914,
+ 1008486,
+ 1092935,
+ 992070,
+ 1600793,
+ 990214,
+ 1104198,
+ 994326,
+ 1604442,
+ 998726,
+ 1108743,
+ 1090423,
+ 1702458,
+ 1106023,
+ 993542,
+ 1022294,
+ 1683050,
+ 1197000,
+ 3101683,
+ 2100269,
+ 2167901,
+ 1948876,
+ 2005132,
+ 1994172,
+ 3004019,
+ 1999292,
+ 2009148,
+ 1988668,
+ 1681674,
+ 1092359,
+ 985942,
+ 1194567,
+ 4067737,
+ 1154935,
+ 1004167,
+ 3850375,
+ 2392399,
+ 1046054,
+ 995734,
+ 996358,
+ 1758203,
+ 1066055,
+ 971381,
+ 1302888,
+ 1709355,
+ 999462,
+ 986806,
+ 997686,
+ 1606922,
+ 991974,
+ 997958,
+ 999478,
+ 1599146,
+ 1015462,
+ 992102,
+ 1000758,
+ 1698283,
+ 1197831,
+ 1196279,
+ 1099399,
+ 1601946,
+ 998006,
+ 1000070,
+ 4523052,
+ 3568134,
+ 5413233,
+ 4896830,
+ 896261,
+ 2252750,
+ 1184839,
+ 1382569,
+ 1785242,
+ 1613114,
+ 1105479,
+ 1191191,
+ 1095015,
+ 4452427,
+ 2805921,
+ 1535706,
+ 3001842,
+ 3592518,
+ 2191533,
+ 907958,
+ 895542,
+ 1501593,
+ 994758,
+ 1105783,
+ 1101542,
+ 1701915,
+ 1297256,
+ 994406,
+ 897813,
+ 1538362,
+ 1473897,
+ 1294503,
+ 995575,
+ 1497881,
+ 1102790,
+ 1038055,
+ 1084726,
+ 1773947,
+ 1031559,
+ 1189127,
+ 997446,
+ 1618938,
+ 1210295,
+ 1494297,
+ 1361017,
+ 1497977,
+ 1109271,
+ 885573,
+ 901318,
+ 1499881,
+ 896629,
+ 900886,
+ 1096950,
+ 1503674,
+ 898597,
+ 915014,
+ 996246,
+ 1589642,
+ 897493,
+ 1202263,
+ 1094311,
+ 1618954,
+ 1389432,
+ 956134,
+ 1448329,
+ 1615322,
+ 1090903,
+ 1004214,
+ 1111447,
+ 1682938,
+ 997734,
+ 1621210,
+ 3703574,
+ 1574634,
+ 989494,
+ 904518,
+ 897605,
+ 1497385,
+ 902406,
+ 994982,
+ 995398,
+ 1499145,
+ 1048423,
+ 12661181,
+ 1097351,
+ 1718026,
+ 1282136,
+ 1019830,
+ 976070,
+ 3132787,
+ 966582,
+ 898614,
+ 898229,
+ 1501625,
+ 897830,
+ 900197,
+ 898918,
+ 1502441,
+ 897718,
+ 922933,
+ 993974,
+ 1602282,
+ 992502,
+ 1001174,
+ 999046,
+ 1612442,
+ 1089495,
+ 995462,
+ 999174,
+ 1605306,
+ 1102247,
+ 997814,
+ 1099142,
+ 1603834,
+ 993430,
+ 998358,
+ 997239,
+ 1612153,
+ 989142,
+ 1004055,
+ 994246,
+ 2965106,
+ 1032790,
+ 1095543,
+ 1411560,
+ 2512800,
+ 2483263,
+ 5741651,
+ 1236936,
+ 1633018,
+ 1189719,
+ 3303108,
+ 2501007,
+ 1798539,
+ 1694427,
+ 2500767,
+ 1698938,
+ 1801643,
+ 2497856,
+ 1597545,
+ 1902044,
+ 2501167,
+ 1612346,
+ 2499247,
+ 3187412,
+ 2898674,
+ 3286548,
+ 995286,
+ 898613,
+ 909590,
+ 3299172,
+ 2690624,
+ 1509706,
+ 2709792,
+ 3382165,
+ 897493,
+ 900534,
+ 900053,
+ 1500474,
+ 897461,
+ 901830,
+ 917445,
+ 1690555,
+ 1107494,
+ 995494,
+ 984662,
+ 1507642,
+ 992166,
+ 897061,
+ 1141239,
+ 2000220,
+ 1277896,
+ 1297896,
+ 1210744,
+ 4231273,
+ 1986877,
+ 1997916,
+ 1997500,
+ 2435423,
+ 1569337,
+ 1996525,
+ 1999452,
+ 2374686,
+ 1199032,
+ 3436757,
+ 1167479,
+ 1598634,
+ 995590,
+ 1200567,
+ 1096151,
+ 1602874,
+ 997782,
+ 997622,
+ 1000902,
+ 1607098,
+ 994886,
+ 1000198,
+ 1168551,
+ 1907660,
+ 1023510,
+ 3801751,
+ 1033703,
+ 1716058,
+ 1076599,
+ 885045,
+ 892773,
+ 1539658,
+ 1185463,
+ 1061351,
+ 1201415,
+ 1608410,
+ 989446,
+ 1197895,
+ 1094951,
+ 1599082,
+ 994022,
+ 997670,
+ 1002038,
+ 1614666,
+ 1083782,
+ 1002823,
+ 999494,
+ 1597241,
+ 999511,
+ 1002358,
+ 997782,
+ 1599946,
+ 999558,
+ 1005078,
+ 997158,
+ 1600874,
+ 997910,
+ 1296488,
+ 1208231,
+ 1807083,
+ 1295960,
+ 1289752,
+ 1012710,
+ 1689946,
+ 1005015,
+ 985350,
+ 1018438,
+ 1796907,
+ 1298456,
+ 1198439,
+ 1198007,
+ 1799179,
+ 1012839,
+ 974726,
+ 899637,
+ 1500729,
+ 898534,
+ 899253,
+ 901414,
+ 1617690,
+ 1100790,
+ 980646,
+ 1020151,
+ 1680922,
+ 898805,
+ 900086,
+ 899189,
+ 1502953,
+ 896566,
+ 900694,
+ 1259463,
+ 1772763,
+ 1093783,
+ 1756010,
+ 1035335,
+ 1597354,
+ 995062,
+ 896757,
+ 900870,
+ 1498025,
+ 906965,
+ 889798,
+ 901493,
+ 1605418,
+ 1307624,
+ 1205575,
+ 1192168,
+ 1689850,
+ 1117575,
+ 1032054,
+ 1064151,
+ 1552185,
+ 939942,
+ 911413,
+ 890918,
+ 1496121,
+ 895974,
+ 906117,
+ 893094,
+ 1504793,
+ 904309,
+ 906006,
+ 886245,
+ 1511017,
+ 887302,
+ 897781,
+ 898790,
+ 1502793,
+ 898710,
+ 923173,
+ 877462,
+ 1504489,
+ 892933,
+ 899846,
+ 909733,
+ 1497353,
+ 894518,
+ 898005,
+ 900214,
+ 1502441,
+ 896486,
+ 905301,
+ 899206,
+ 1503577,
+ 894021,
+ 900070,
+ 898309,
+ 1503289,
+ 896934,
+ 908517,
+ 889830,
+ 1502425,
+ 897494,
+ 895893,
+ 899510,
+ 1517385,
+ 886549,
+ 897782,
+ 898069,
+ 1503257,
+ 894550,
+ 900133,
+ 907510,
+ 1493241,
+ 898134,
+ 900437,
+ 899733,
+ 1600026,
+ 904870,
+ 898661,
+ 912070,
+ 1702778,
+ 993510,
+ 1004838,
+ 2278558,
+ 1902556,
+ 1128583,
+ 1086343,
+ 995990,
+ 1602345,
+ 4244985,
+ 1664987,
+ 1901451,
+ 990262,
+ 998262,
+ 3631447,
+ 1000998,
+ 3457541,
+ 995030,
+ 899013,
+ 898230,
+ 1516057,
+ 2684913,
+ 916821,
+ 1597978,
+ 44931075,
+ 3560517,
+ 2600880,
+ 1206408,
+ 3209363,
+ 1080599,
+ 994966,
+ 1602730,
+ 1827867,
+ 1105495,
+ 974838,
+ 1704154,
+ 993734,
+ 998694,
+ 998406,
+ 1604410,
+ 998150,
+ 1000006,
+ 998870,
+ 1603114,
+ 997254,
+ 996742,
+ 1000166,
+ 1603818,
+ 1698939,
+ 1008550,
+ 2533423,
+ 1660907,
+ 991078,
+ 997878,
+ 1002518,
+ 1602378,
+ 994294,
+ 1000774,
+ 1198951,
+ 2602848,
+ 994710,
+ 999238,
+ 1001398,
+ 1614458,
+ 987046,
+ 996310,
+ 1099911,
+ 1604202,
+ 997558,
+ 1899788,
+ 997558,
+ 1704042,
+ 998358,
+ 997094,
+ 998550
+ ],
+ "checkpoint_ns": [
+ 41682158,
+ 57196045,
+ 50089011,
+ 55645524
+ ],
+ "batches": 4000,
+ "segment_files": 4,
+ "blob_files": 0,
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 6.023540487,
+ "valid": true,
+ "refusal": null,
+ "samples": 62,
+ "largest_gap_ms": 101.849,
+ "pkg_j": 589.266,
+ "cpu_p_j": 333.707,
+ "cpu_e_j": 37.678,
+ "rest_j": 217.88099999999997,
+ "pkg_mean_w": 97.82718341011459,
+ "pkg_edge_sd_j": 7.987556077614813,
+ "sys_total_mean_w": 119.94230645161291,
+ "nvme_temp_k": 319.0,
+ "loadavg_start": [
+ 13.53,
+ 9.15,
+ 7.56
+ ],
+ "loadavg_end": [
+ 14.85,
+ 9.49,
+ 7.68
+ ],
+ "machine_busy_cpu_s": 102.3699999996461
+ }
+ },
+ {
+ "agents": 4,
+ "rep": 0,
+ "accepted": 4000,
+ "elapsed_ns": 2635634977,
+ "latency_ns": [
+ 1464505,
+ 1624185,
+ 2984930,
+ 3063011,
+ 3063171,
+ 2195518,
+ 3284068,
+ 3395780,
+ 3313060,
+ 2381902,
+ 2774001,
+ 2778977,
+ 2899522,
+ 913366,
+ 2607520,
+ 2009693,
+ 1981436,
+ 1978588,
+ 1983741,
+ 2398446,
+ 2395055,
+ 2513999,
+ 2417950,
+ 1890892,
+ 1896507,
+ 1797003,
+ 1803531,
+ 2408414,
+ 2454559,
+ 997127,
+ 2594880,
+ 2611440,
+ 1000118,
+ 1948204,
+ 993462,
+ 1968364,
+ 2044973,
+ 1603034,
+ 2598352,
+ 2515904,
+ 2557039,
+ 1808587,
+ 1903179,
+ 1801755,
+ 1822651,
+ 2402751,
+ 2503759,
+ 2499423,
+ 2470287,
+ 1897835,
+ 1912428,
+ 996135,
+ 1901612,
+ 1897724,
+ 1586473,
+ 2564512,
+ 2501487,
+ 2558448,
+ 999670,
+ 1913628,
+ 1909116,
+ 995590,
+ 1941564,
+ 2498447,
+ 2414334,
+ 2401231,
+ 2404846,
+ 1789195,
+ 1792299,
+ 1704779,
+ 1806171,
+ 2393135,
+ 2485311,
+ 2496863,
+ 2602928,
+ 1900027,
+ 1903916,
+ 1796699,
+ 1790571,
+ 2400159,
+ 2299582,
+ 2408351,
+ 2410846,
+ 1799643,
+ 1801451,
+ 1894651,
+ 1916092,
+ 2499151,
+ 2599088,
+ 2392671,
+ 2372431,
+ 1812428,
+ 1814747,
+ 1801067,
+ 1798507,
+ 2387902,
+ 2384191,
+ 2404303,
+ 2404478,
+ 1799803,
+ 1795115,
+ 1797803,
+ 1794971,
+ 2403551,
+ 2407326,
+ 2397550,
+ 2399039,
+ 1795499,
+ 1793675,
+ 1814763,
+ 1815707,
+ 2404142,
+ 2408831,
+ 2387999,
+ 2390447,
+ 1918156,
+ 1906876,
+ 2003388,
+ 1996028,
+ 2592544,
+ 2594816,
+ 2492800,
+ 2538703,
+ 1003078,
+ 1997052,
+ 1946683,
+ 1859356,
+ 2505263,
+ 2507840,
+ 2480976,
+ 2395438,
+ 1788027,
+ 1690506,
+ 1673690,
+ 1797115,
+ 2397023,
+ 2394175,
+ 2394111,
+ 898085,
+ 2521952,
+ 1913611,
+ 2007980,
+ 1895788,
+ 1894427,
+ 2602496,
+ 2601504,
+ 2614624,
+ 2586560,
+ 991590,
+ 1882587,
+ 2027981,
+ 894485,
+ 1908812,
+ 1509881,
+ 2405807,
+ 2407022,
+ 890422,
+ 2402703,
+ 1021222,
+ 1901868,
+ 1908844,
+ 1195127,
+ 2187229,
+ 1588042,
+ 2786209,
+ 2786705,
+ 892406,
+ 2512159,
+ 901285,
+ 1799323,
+ 1791147,
+ 897030,
+ 1797291,
+ 1501529,
+ 2398302,
+ 2400271,
+ 898661,
+ 2400191,
+ 902246,
+ 1710491,
+ 1774186,
+ 898405,
+ 1778219,
+ 2410494,
+ 2398383,
+ 2399023,
+ 2399966,
+ 1799099,
+ 1794379,
+ 1800235,
+ 1819884,
+ 2701073,
+ 2600128,
+ 2700672,
+ 2680016,
+ 1939324,
+ 2040044,
+ 1899836,
+ 1903980,
+ 2556719,
+ 2555264,
+ 2603712,
+ 2623056,
+ 895269,
+ 1879052,
+ 1826027,
+ 899238,
+ 1790411,
+ 1504809,
+ 2262926,
+ 2405151,
+ 909942,
+ 2437615,
+ 999750,
+ 2003244,
+ 1930187,
+ 988390,
+ 1846763,
+ 1501065,
+ 2490832,
+ 2540880,
+ 895317,
+ 2515567,
+ 900118,
+ 1772603,
+ 1814443,
+ 898357,
+ 1799803,
+ 1502170,
+ 2399374,
+ 2376127,
+ 897925,
+ 2399023,
+ 903158,
+ 1800651,
+ 1801515,
+ 901429,
+ 1778379,
+ 1501993,
+ 2309438,
+ 2266797,
+ 892006,
+ 2419679,
+ 916485,
+ 1902428,
+ 1956508,
+ 885030,
+ 1797899,
+ 1508393,
+ 2397055,
+ 2379759,
+ 890757,
+ 2379182,
+ 901542,
+ 1792091,
+ 1793595,
+ 897029,
+ 1824619,
+ 1504602,
+ 2304046,
+ 2257374,
+ 893925,
+ 2394367,
+ 902038,
+ 1891163,
+ 1934396,
+ 897301,
+ 1804331,
+ 1610778,
+ 2501072,
+ 2509055,
+ 1218967,
+ 2800449,
+ 1295960,
+ 2521887,
+ 2511039,
+ 1293384,
+ 2589712,
+ 1798203,
+ 3085651,
+ 3089939,
+ 1196344,
+ 2996338,
+ 1101974,
+ 2302014,
+ 2298382,
+ 1201464,
+ 2304190,
+ 3048995,
+ 3213092,
+ 1494297,
+ 3575813,
+ 3526806,
+ 1210023,
+ 2684768,
+ 2019085,
+ 2113053,
+ 1708746,
+ 2701761,
+ 2632784,
+ 1100711,
+ 2763777,
+ 988678,
+ 2065005,
+ 2137981,
+ 1204391,
+ 2193901,
+ 2000525,
+ 3203955,
+ 3204964,
+ 1301672,
+ 3300756,
+ 1094150,
+ 2397023,
+ 2401662,
+ 995446,
+ 2087069,
+ 1700619,
+ 2693376,
+ 2692865,
+ 998006,
+ 2699568,
+ 2013533,
+ 2105821,
+ 994758,
+ 2204189,
+ 2130878,
+ 1595626,
+ 2548799,
+ 1104582,
+ 2672848,
+ 2725377,
+ 1201256,
+ 2302558,
+ 1200327,
+ 2399359,
+ 2402799,
+ 1793995,
+ 3002467,
+ 1296600,
+ 3089026,
+ 3087987,
+ 1203783,
+ 2502159,
+ 1297656,
+ 2503296,
+ 2508895,
+ 1808139,
+ 3099731,
+ 1293432,
+ 3102259,
+ 3117363,
+ 1196087,
+ 2494463,
+ 1301096,
+ 2501327,
+ 2496655,
+ 1802395,
+ 3104739,
+ 1098263,
+ 2806529,
+ 2857090,
+ 996742,
+ 2097581,
+ 1898588,
+ 1901867,
+ 2397247,
+ 2392238,
+ 2507567,
+ 2499856,
+ 1909404,
+ 1930476,
+ 1299175,
+ 2289310,
+ 2242605,
+ 1896332,
+ 3172500,
+ 1300760,
+ 3105027,
+ 3152356,
+ 1195031,
+ 2494703,
+ 2199262,
+ 2248141,
+ 1599241,
+ 2702161,
+ 2626880,
+ 1104903,
+ 2655233,
+ 1977996,
+ 2007980,
+ 994838,
+ 2089149,
+ 2036764,
+ 1596058,
+ 2686849,
+ 1005990,
+ 2605824,
+ 2600640,
+ 1205047,
+ 2206237,
+ 1303480,
+ 2404702,
+ 2467663,
+ 2878050,
+ 2822802,
+ 2829042,
+ 2825073,
+ 2111053,
+ 1961116,
+ 2070076,
+ 1985725,
+ 2501023,
+ 2398622,
+ 2397983,
+ 2395838,
+ 1797035,
+ 1800827,
+ 1700474,
+ 1780523,
+ 2402671,
+ 2508080,
+ 2516336,
+ 2508191,
+ 1896155,
+ 2000508,
+ 2103709,
+ 2025341,
+ 2786561,
+ 2582800,
+ 2585455,
+ 2587504,
+ 1921148,
+ 1999324,
+ 2019373,
+ 2013212,
+ 1590794,
+ 2692528,
+ 2480287,
+ 2567328,
+ 1899979,
+ 1897868,
+ 1696778,
+ 1804635,
+ 2614480,
+ 2637344,
+ 2971106,
+ 3123747,
+ 1406121,
+ 2774801,
+ 2678448,
+ 1392440,
+ 2747601,
+ 2815954,
+ 2912706,
+ 995270,
+ 2608704,
+ 2560063,
+ 1775291,
+ 1905691,
+ 1885724,
+ 1953580,
+ 1706715,
+ 2808897,
+ 989414,
+ 2673104,
+ 2700097,
+ 993958,
+ 1986140,
+ 1004806,
+ 1999661,
+ 2018556,
+ 1711978,
+ 2703841,
+ 2736913,
+ 2962882,
+ 1197447,
+ 2481712,
+ 2421727,
+ 1197767,
+ 2327758,
+ 2613792,
+ 2707920,
+ 993478,
+ 2592768,
+ 2558544,
+ 994758,
+ 1963052,
+ 1002406,
+ 1941563,
+ 2051437,
+ 1604186,
+ 2606640,
+ 996582,
+ 2603104,
+ 2600096,
+ 993174,
+ 1986188,
+ 2008237,
+ 2048876,
+ 2602896,
+ 2634416,
+ 1104022,
+ 2512655,
+ 2684320,
+ 1199816,
+ 2273342,
+ 2486736,
+ 2556944,
+ 2105005,
+ 3400773,
+ 3309381,
+ 1391688,
+ 3441797,
+ 2299230,
+ 2299134,
+ 997734,
+ 2001276,
+ 1931228,
+ 2789793,
+ 2677552,
+ 2799793,
+ 2826754,
+ 889957,
+ 2015996,
+ 901350,
+ 1889323,
+ 1817403,
+ 1499913,
+ 2378959,
+ 2312623,
+ 2388558,
+ 1915163,
+ 2118157,
+ 1995868,
+ 1974060,
+ 2395647,
+ 2397487,
+ 2403935,
+ 2444735,
+ 1005814,
+ 1924124,
+ 1895467,
+ 2039341,
+ 2697072,
+ 2800705,
+ 2754177,
+ 1199799,
+ 2810721,
+ 1198040,
+ 2371102,
+ 2367502,
+ 1194983,
+ 2392767,
+ 2891554,
+ 2960931,
+ 1199383,
+ 2997202,
+ 3107699,
+ 1195128,
+ 2396414,
+ 1219111,
+ 2298782,
+ 2406175,
+ 1703163,
+ 2920818,
+ 1097222,
+ 2885298,
+ 2854945,
+ 1198808,
+ 2290974,
+ 996214,
+ 2204365,
+ 2195582,
+ 1597865,
+ 2606240,
+ 999350,
+ 2599424,
+ 2598447,
+ 997783,
+ 1995676,
+ 1007222,
+ 2015308,
+ 1998765,
+ 2410543,
+ 2741568,
+ 2865202,
+ 3005730,
+ 1402361,
+ 2872322,
+ 2297838,
+ 2446687,
+ 1798875,
+ 2907058,
+ 2878369,
+ 1115415,
+ 2884162,
+ 1944604,
+ 2101677,
+ 1986108,
+ 1988652,
+ 2608240,
+ 2660192,
+ 1198727,
+ 2893250,
+ 2828673,
+ 1194552,
+ 2337054,
+ 1115478,
+ 2195341,
+ 2306446,
+ 1686731,
+ 2802993,
+ 2492335,
+ 2579280,
+ 998758,
+ 1992780,
+ 1920812,
+ 1982188,
+ 1908956,
+ 2893426,
+ 3015715,
+ 2924946,
+ 1184775,
+ 1985692,
+ 2104748,
+ 2079581,
+ 1904972,
+ 1907884,
+ 2889506,
+ 3010882,
+ 2915345,
+ 1006566,
+ 1788203,
+ 1813659,
+ 1858684,
+ 1795947,
+ 2609264,
+ 2707633,
+ 2641888,
+ 2689360,
+ 1228712,
+ 2296958,
+ 2225933,
+ 2219534,
+ 1189815,
+ 1806715,
+ 2994387,
+ 2995763,
+ 2997554,
+ 982326,
+ 1004678,
+ 1895963,
+ 1964460,
+ 1963900,
+ 991958,
+ 2504383,
+ 2509615,
+ 2507551,
+ 2602240,
+ 1220152,
+ 2402479,
+ 2329742,
+ 2329166,
+ 1089254,
+ 1706715,
+ 2796993,
+ 2794001,
+ 2795058,
+ 1385544,
+ 1314360,
+ 2607824,
+ 2675649,
+ 2677232,
+ 1194919,
+ 2994770,
+ 3025250,
+ 3025954,
+ 1105159,
+ 3003683,
+ 1098871,
+ 2175998,
+ 2203838,
+ 1095575,
+ 2191933,
+ 1901403,
+ 2996690,
+ 2967570,
+ 2796593,
+ 1002070,
+ 2083629,
+ 2017644,
+ 2017644,
+ 1003703,
+ 1704282,
+ 2601696,
+ 2705681,
+ 2680145,
+ 982710,
+ 1007382,
+ 2070221,
+ 2039164,
+ 2037164,
+ 991766,
+ 2568496,
+ 2704512,
+ 2663168,
+ 2704865,
+ 1002598,
+ 2085484,
+ 2021821,
+ 2016349,
+ 991206,
+ 2489263,
+ 2611120,
+ 2585808,
+ 2502447,
+ 1789259,
+ 1795755,
+ 1790219,
+ 1798923,
+ 2406687,
+ 2509695,
+ 2480559,
+ 2498256,
+ 1789691,
+ 1697034,
+ 1885740,
+ 1798746,
+ 2397151,
+ 2402063,
+ 2406366,
+ 2401615,
+ 1788699,
+ 1791051,
+ 1791355,
+ 1799435,
+ 2396014,
+ 2394254,
+ 2298526,
+ 2400911,
+ 1800075,
+ 1799995,
+ 1897676,
+ 1906348,
+ 2499296,
+ 2597184,
+ 2520911,
+ 2398702,
+ 1806235,
+ 1682187,
+ 1815019,
+ 1977820,
+ 2596767,
+ 2596671,
+ 2586944,
+ 2416943,
+ 1797084,
+ 1893740,
+ 1823755,
+ 1797515,
+ 2400718,
+ 2399839,
+ 2398223,
+ 2398367,
+ 1799067,
+ 1679770,
+ 1791947,
+ 1809963,
+ 2441887,
+ 2533904,
+ 2464175,
+ 2702176,
+ 2178365,
+ 2197229,
+ 2202813,
+ 1277576,
+ 2373855,
+ 2672464,
+ 2768353,
+ 2324382,
+ 2508816,
+ 1791835,
+ 1774523,
+ 1799819,
+ 1803291,
+ 2398479,
+ 2416303,
+ 2386159,
+ 2386750,
+ 1913724,
+ 1893403,
+ 1928219,
+ 1833083,
+ 1693291,
+ 2510672,
+ 2725728,
+ 993894,
+ 2779505,
+ 1900315,
+ 1883548,
+ 1805275,
+ 1711195,
+ 1598090,
+ 2508064,
+ 2491471,
+ 2586848,
+ 1895435,
+ 1806587,
+ 1978668,
+ 1795003,
+ 2382159,
+ 2295038,
+ 2402063,
+ 2401438,
+ 1822827,
+ 1809707,
+ 1825339,
+ 1799851,
+ 2397551,
+ 2399551,
+ 2393759,
+ 2400143,
+ 1891675,
+ 1977628,
+ 2005996,
+ 1893628,
+ 1609673,
+ 2495151,
+ 2496415,
+ 2498655,
+ 991174,
+ 2004349,
+ 1917900,
+ 1986476,
+ 1898412,
+ 2500495,
+ 2508127,
+ 2494032,
+ 2499967,
+ 1799051,
+ 1794523,
+ 1803579,
+ 1798667,
+ 2503327,
+ 2414926,
+ 2587984,
+ 2500240,
+ 2071485,
+ 1993964,
+ 2171406,
+ 2100348,
+ 2633248,
+ 2544335,
+ 2727249,
+ 2598640,
+ 1773931,
+ 1774315,
+ 1776555,
+ 1799755,
+ 2628368,
+ 2704336,
+ 2632272,
+ 2616448,
+ 1869452,
+ 1797548,
+ 1869563,
+ 1890700,
+ 3002018,
+ 3098066,
+ 3029267,
+ 2992786,
+ 1797947,
+ 1703867,
+ 1773354,
+ 1797915,
+ 2397935,
+ 2402207,
+ 2396511,
+ 2397455,
+ 1904203,
+ 1993804,
+ 1923020,
+ 1900875,
+ 2392815,
+ 2280366,
+ 2389726,
+ 2400399,
+ 1907195,
+ 1820507,
+ 1993260,
+ 1901228,
+ 2492528,
+ 2497296,
+ 2506431,
+ 2503295,
+ 1894747,
+ 1996188,
+ 1917100,
+ 2012540,
+ 2803121,
+ 2822033,
+ 2821329,
+ 1285784,
+ 3230676,
+ 1201608,
+ 2462543,
+ 2494111,
+ 1189927,
+ 2370975,
+ 2620976,
+ 2672593,
+ 2596160,
+ 2613296,
+ 1201911,
+ 2371663,
+ 2287358,
+ 1303992,
+ 2457791,
+ 1904236,
+ 3111363,
+ 3183987,
+ 1392344,
+ 3298324,
+ 2308126,
+ 2337679,
+ 997174,
+ 2013197,
+ 1963100,
+ 1607610,
+ 2585471,
+ 1001462,
+ 2566048,
+ 2679360,
+ 1094151,
+ 2089149,
+ 1209431,
+ 2141165,
+ 2302942,
+ 1899276,
+ 3131507,
+ 1089702,
+ 2894577,
+ 3081331,
+ 992198,
+ 2066445,
+ 2093693,
+ 2003836,
+ 2601824,
+ 2591840,
+ 2394079,
+ 2397087,
+ 1801291,
+ 1827371,
+ 1988540,
+ 2125581,
+ 2598832,
+ 2577504,
+ 2601248,
+ 2586448,
+ 2101853,
+ 2113261,
+ 1000166,
+ 2018188,
+ 1988220,
+ 1583130,
+ 2578079,
+ 2494959,
+ 2498239,
+ 1793755,
+ 1789771,
+ 2010589,
+ 2006876,
+ 2598752,
+ 2624048,
+ 1018582,
+ 2588287,
+ 2536384,
+ 1184519,
+ 2096205,
+ 1953356,
+ 2096381,
+ 2507455,
+ 2610160,
+ 2511664,
+ 2705232,
+ 1891788,
+ 1875404,
+ 1790795,
+ 1696635,
+ 2397023,
+ 2421262,
+ 901077,
+ 2487311,
+ 2532383,
+ 897270,
+ 1774635,
+ 901237,
+ 1797627,
+ 1798475,
+ 1622906,
+ 2426991,
+ 1187591,
+ 2848737,
+ 1204328,
+ 2499407,
+ 2065709,
+ 1598570,
+ 2604592,
+ 2740720,
+ 991414,
+ 1755883,
+ 1899260,
+ 1799851,
+ 2396207,
+ 2410975,
+ 997350,
+ 2618480,
+ 1004758,
+ 2002732,
+ 1001382,
+ 2001020,
+ 1595066,
+ 2578784,
+ 2699792,
+ 2198429,
+ 2221949,
+ 997719,
+ 2106557,
+ 1601977,
+ 2599776,
+ 996678,
+ 2589376,
+ 1761787,
+ 2012877,
+ 2010764,
+ 2905666,
+ 2789857,
+ 2785281,
+ 1888139,
+ 1798971,
+ 1801211,
+ 2620336,
+ 33308443,
+ 33294556,
+ 2707153,
+ 33369196,
+ 2592416,
+ 2493967,
+ 1993708,
+ 2020285,
+ 2104813,
+ 2206014,
+ 2801393,
+ 2819057,
+ 1406025,
+ 3091315,
+ 3283812,
+ 2257358,
+ 1209735,
+ 2103933,
+ 2299726,
+ 2319038,
+ 1913372,
+ 3011411,
+ 2895058,
+ 3040290,
+ 994166,
+ 2188541,
+ 1987068,
+ 1962252,
+ 2507727,
+ 2511823,
+ 2392894,
+ 2299534,
+ 1889356,
+ 1988300,
+ 2000989,
+ 2129517,
+ 2514783,
+ 2610832,
+ 2605215,
+ 2570448,
+ 1973148,
+ 2068893,
+ 1027942,
+ 2140285,
+ 2265822,
+ 1693195,
+ 2820513,
+ 1205943,
+ 2750641,
+ 2872130,
+ 2195342,
+ 2090717,
+ 2089949,
+ 2118525,
+ 1701834,
+ 2804561,
+ 2703760,
+ 2584095,
+ 1990204,
+ 2006044,
+ 1974076,
+ 1979484,
+ 2395727,
+ 2607920,
+ 2702273,
+ 2794306,
+ 2276894,
+ 2176910,
+ 1205751,
+ 2398751,
+ 2325598,
+ 2814721,
+ 2709233,
+ 2595616,
+ 2728624,
+ 1193447,
+ 2385150,
+ 2195277,
+ 2086413,
+ 1602138,
+ 2710209,
+ 2643217,
+ 2602032,
+ 992102,
+ 2092045,
+ 2013452,
+ 2015468,
+ 1095847,
+ 2587488,
+ 2728352,
+ 2700432,
+ 988054,
+ 2698128,
+ 1212071,
+ 2083581,
+ 2153790,
+ 1099479,
+ 2308590,
+ 2692929,
+ 2754625,
+ 1105462,
+ 2705536,
+ 2701521,
+ 1385273,
+ 2436334,
+ 2386527,
+ 2418607,
+ 1600346,
+ 2704272,
+ 2652081,
+ 993814,
+ 2568511,
+ 1905276,
+ 2009324,
+ 998646,
+ 2106829,
+ 2032685,
+ 1648730,
+ 2597616,
+ 1168519,
+ 2797329,
+ 2860433,
+ 1395129,
+ 2563967,
+ 1085062,
+ 2479375,
+ 2463983,
+ 1594522,
+ 2673617,
+ 2577056,
+ 2696305,
+ 1993292,
+ 2048348,
+ 1018119,
+ 2003852,
+ 1930379,
+ 1596249,
+ 2568400,
+ 1100247,
+ 2680465,
+ 2720337,
+ 1100599,
+ 2110573,
+ 12206314,
+ 12191274,
+ 12882735,
+ 12901615,
+ 2678865,
+ 2680993,
+ 1891083,
+ 1886203,
+ 2088877,
+ 2088845,
+ 2702001,
+ 2704081,
+ 2404430,
+ 2501999,
+ 1904315,
+ 1905339,
+ 1897676,
+ 1921228,
+ 2504016,
+ 2656065,
+ 988246,
+ 2701632,
+ 2604928,
+ 992022,
+ 1837515,
+ 2005197,
+ 2102588,
+ 2705248,
+ 2792705,
+ 2595903,
+ 2568144,
+ 1893084,
+ 1902012,
+ 1794971,
+ 1701642,
+ 2400591,
+ 2396446,
+ 2483840,
+ 2577840,
+ 1804939,
+ 1993820,
+ 1894827,
+ 1896012,
+ 2498112,
+ 2551935,
+ 1310248,
+ 2922930,
+ 2856177,
+ 1192087,
+ 2447791,
+ 1298840,
+ 2462063,
+ 2547584,
+ 1710906,
+ 3010995,
+ 1086839,
+ 2804705,
+ 2798417,
+ 998182,
+ 2083245,
+ 1748218,
+ 1891196,
+ 2608432,
+ 2565551,
+ 2801602,
+ 2803745,
+ 1991596,
+ 1992636,
+ 3232051,
+ 3222180,
+ 4192122,
+ 4147242,
+ 7393454,
+ 7406765,
+ 7519006,
+ 7524350,
+ 3790951,
+ 3787959,
+ 3591110,
+ 3595750,
+ 3696390,
+ 3702167,
+ 4793101,
+ 4945934,
+ 5709763,
+ 5706595,
+ 4797773,
+ 4710157,
+ 3684919,
+ 3683366,
+ 3600246,
+ 3546005,
+ 4307370,
+ 4301547,
+ 5004559,
+ 5070271,
+ 4886894,
+ 4895118,
+ 4055945,
+ 3980297,
+ 2898402,
+ 2898017,
+ 2137565,
+ 2240285,
+ 2418206,
+ 2415743,
+ 3096195,
+ 3065907,
+ 4904830,
+ 4808349,
+ 5012382,
+ 4950110,
+ 3444501,
+ 3466918,
+ 4094185,
+ 4090249,
+ 4625836,
+ 4655820,
+ 12814159,
+ 12818271,
+ 11694151,
+ 11688983,
+ 3183827,
+ 3192851,
+ 2184958,
+ 4287691,
+ 4370427,
+ 3460549,
+ 1726027,
+ 3004946,
+ 3004835,
+ 3124019,
+ 1566490,
+ 3205076,
+ 3256147,
+ 3258500,
+ 1587113,
+ 3319972,
+ 1105399,
+ 2643217,
+ 2643712,
+ 2152333,
+ 2808993,
+ 2808625,
+ 2805857,
+ 3306340,
+ 2895762,
+ 2902946,
+ 2896994,
+ 2446751,
+ 3395909,
+ 3400964,
+ 3398484,
+ 4814702,
+ 2704544,
+ 5312432,
+ 5212144,
+ 5283473,
+ 1878092,
+ 1230247,
+ 3204148,
+ 3220084,
+ 3154739,
+ 1087895,
+ 2188973,
+ 2150125,
+ 2176493,
+ 4046729,
+ 3099858,
+ 5944980,
+ 5943860,
+ 5952309,
+ 2848818,
+ 6253415,
+ 6261015,
+ 6349158,
+ 6991403,
+ 8205026,
+ 8114482,
+ 8310355,
+ 3388901,
+ 8125409,
+ 1095382,
+ 4564284,
+ 4497211,
+ 2583024,
+ 5008351,
+ 4922766,
+ 4986399,
+ 6188838,
+ 5083375,
+ 5188656,
+ 5194848,
+ 6401143,
+ 7314204,
+ 7405933,
+ 7420349,
+ 4491996,
+ 2015596,
+ 3198788,
+ 3108851,
+ 3173411,
+ 2284654,
+ 5690803,
+ 5668227,
+ 5694915,
+ 4895950,
+ 4094809,
+ 4185305,
+ 4127834,
+ 6002069,
+ 7996001,
+ 8034081,
+ 8007344,
+ 2790977,
+ 7488365,
+ 4382811,
+ 4478012,
+ 6218214,
+ 6215414,
+ 8995479,
+ 8991447,
+ 8181442,
+ 8092050,
+ 5892068,
+ 5918212,
+ 5803203,
+ 5908820,
+ 7198156,
+ 7094171,
+ 5993173,
+ 5989940,
+ 6400391,
+ 6482488,
+ 7006715,
+ 7005995,
+ 4809598,
+ 4799405,
+ 4694012,
+ 4605836,
+ 5897380,
+ 5898404,
+ 4796318,
+ 4791726,
+ 2201469,
+ 4078185,
+ 4010953,
+ 6716665,
+ 7400765,
+ 7285085,
+ 7398717,
+ 5188896,
+ 4416811,
+ 4324906,
+ 4504267,
+ 4269018,
+ 5381745,
+ 5384433,
+ 5507074,
+ 5630882,
+ 7429886,
+ 7315613,
+ 7340237,
+ 8418164,
+ 5463905,
+ 5464241,
+ 5592178,
+ 1793483,
+ 3957848,
+ 3610822,
+ 3645478,
+ 1593162,
+ 3328804,
+ 3506550,
+ 1205527,
+ 2752113,
+ 2198654,
+ 2239613,
+ 1004454,
+ 1901324,
+ 2097101,
+ 1696858,
+ 2673585,
+ 2697088,
+ 2712081,
+ 2206269,
+ 2395343,
+ 2290798,
+ 2283614,
+ 1603370,
+ 2683009,
+ 2619136,
+ 991526,
+ 2583904,
+ 1003238,
+ 1989452,
+ 1987868,
+ 999542,
+ 2002572,
+ 1600746,
+ 2605584,
+ 2605840,
+ 1006166,
+ 2607632,
+ 995334,
+ 1997356,
+ 2001692,
+ 1015415,
+ 2011052,
+ 1584585,
+ 2603824,
+ 2598624,
+ 991958,
+ 2587968,
+ 1012711,
+ 1911948,
+ 1978044,
+ 2004204,
+ 2801393,
+ 2902353,
+ 2839442,
+ 1092998,
+ 2896434,
+ 1201688,
+ 2200494,
+ 2258589,
+ 978070,
+ 2182573,
+ 2595216,
+ 2689216,
+ 2599504,
+ 2616800,
+ 1922876,
+ 2054157,
+ 1403449,
+ 2529279,
+ 2441599,
+ 1774682,
+ 3147363,
+ 997686,
+ 2754001,
+ 2797841,
+ 993782,
+ 1992060,
+ 1014406,
+ 2006844,
+ 2009068,
+ 1593914,
+ 2607072,
+ 2590048,
+ 2707473,
+ 1995116,
+ 2027660,
+ 1103862,
+ 2090589,
+ 2003276,
+ 1593930,
+ 2668976,
+ 1004374,
+ 2576368,
+ 2610784,
+ 1088583,
+ 2091165,
+ 1012006,
+ 2016508,
+ 1992236,
+ 1703323,
+ 2722048,
+ 2687137,
+ 2691937,
+ 896277,
+ 1791227,
+ 1982108,
+ 1808603,
+ 2417343,
+ 2409871,
+ 2418991,
+ 1586138,
+ 3179523,
+ 2491279,
+ 2402974,
+ 2891121,
+ 2893618,
+ 3501446,
+ 3597526,
+ 2298206,
+ 2295998,
+ 2515247,
+ 2523952,
+ 984726,
+ 2814514,
+ 2756241,
+ 1595626,
+ 2561071,
+ 3487237,
+ 3610982,
+ 2794033,
+ 2698609,
+ 1809611,
+ 2691024,
+ 2619984,
+ 5114207,
+ 4206634,
+ 4106218,
+ 4206681,
+ 1773194,
+ 2680048,
+ 5099375,
+ 5071711,
+ 4295275,
+ 4290874,
+ 2791297,
+ 2797441,
+ 3299572,
+ 3299588,
+ 3198515,
+ 3231124,
+ 2599104,
+ 2695312,
+ 2599312,
+ 2595952,
+ 3201619,
+ 3204308,
+ 3299940,
+ 3266852,
+ 2597616,
+ 2598992,
+ 2591168,
+ 2590368,
+ 3301076,
+ 3300612,
+ 3515478,
+ 3511509,
+ 2800498,
+ 2701345,
+ 2498479,
+ 2525216,
+ 3198579,
+ 3294372,
+ 3414341,
+ 3454229,
+ 2384031,
+ 4232458,
+ 4409131,
+ 3528277,
+ 5879492,
+ 5901204,
+ 6063621,
+ 4766605,
+ 4777613,
+ 1600538,
+ 4002345,
+ 3938280,
+ 890550,
+ 2454799,
+ 2410622,
+ 3305380,
+ 3303604,
+ 989526,
+ 3394933,
+ 1006582,
+ 1886012,
+ 1991868,
+ 975669,
+ 1991292,
+ 2497232,
+ 2504559,
+ 1004758,
+ 2613984,
+ 2550784,
+ 987430,
+ 1988764,
+ 1001142,
+ 1991997,
+ 1988028,
+ 1600970,
+ 2600384,
+ 997958,
+ 2600223,
+ 2601264,
+ 995814,
+ 2000429,
+ 1903772,
+ 2896226,
+ 2900273,
+ 1601881,
+ 3500949,
+ 1101591,
+ 2692193,
+ 2676561,
+ 2108541,
+ 2200910,
+ 2204877,
+ 2205117,
+ 2590944,
+ 2704112,
+ 2706705,
+ 2704097,
+ 2098701,
+ 1010486,
+ 1995932,
+ 1924908,
+ 1932604,
+ 1597466,
+ 1000070,
+ 2576191,
+ 2597680,
+ 2585471,
+ 992278,
+ 1007542,
+ 2002156,
+ 2001052,
+ 2000685,
+ 1714282,
+ 2560431,
+ 2708801,
+ 2736977,
+ 994294,
+ 2064189,
+ 1751771,
+ 1886988,
+ 2397471,
+ 2402719,
+ 2392687,
+ 2389294,
+ 1724554,
+ 1919756,
+ 1798507,
+ 1799771,
+ 2396527,
+ 2419647,
+ 2621680,
+ 2840993,
+ 1397609,
+ 2688944,
+ 2624944,
+ 1001174,
+ 2373406,
+ 1592506,
+ 2600576,
+ 2598384,
+ 1002534,
+ 2596592,
+ 1916972,
+ 2005964,
+ 1001254,
+ 2012748,
+ 2006509,
+ 1598890,
+ 2596816,
+ 1122471,
+ 2815361,
+ 2748672,
+ 1062582,
+ 2203869,
+ 1005094,
+ 2058301,
+ 2071517,
+ 2335950,
+ 1123367,
+ 2614512,
+ 2608080,
+ 2607776,
+ 1281608,
+ 2324895,
+ 2342062,
+ 2335422,
+ 2901762,
+ 2967922,
+ 2972050,
+ 2971858,
+ 991606,
+ 2207325,
+ 1003110,
+ 1990349,
+ 2061277,
+ 1905004,
+ 2892306,
+ 1387160,
+ 3279540,
+ 3235428,
+ 1219416,
+ 2608928,
+ 1302151,
+ 2530031,
+ 2524319,
+ 1889452,
+ 3191156,
+ 1302440,
+ 3192404,
+ 3208276,
+ 1306392,
+ 2619920,
+ 1082727,
+ 2403966,
+ 2384223,
+ 1593993,
+ 2684400,
+ 1002055,
+ 2603232,
+ 2598463,
+ 1099878,
+ 2098893,
+ 1295304,
+ 2377839,
+ 2390303,
+ 1814875,
+ 3105923,
+ 1194616,
+ 3009250,
+ 3011490,
+ 1295192,
+ 2487631,
+ 2410623,
+ 2497376,
+ 1897131,
+ 3188003,
+ 3133891,
+ 3052146,
+ 1202136,
+ 2579856,
+ 2519231,
+ 2519376,
+ 1292280,
+ 1919243,
+ 3077058,
+ 3207908,
+ 3256020,
+ 1277224,
+ 2279054,
+ 2163405,
+ 2278558,
+ 986422,
+ 2157693,
+ 1703499,
+ 2688912,
+ 2799569,
+ 1104231,
+ 2738561,
+ 1286599,
+ 2309214,
+ 2368703,
+ 1392889,
+ 2735185,
+ 2001884,
+ 3396453,
+ 3394693,
+ 1319896,
+ 3262612,
+ 2302126,
+ 2341294,
+ 992806,
+ 2095181,
+ 2043596,
+ 1601210,
+ 2572816,
+ 1000342,
+ 2508895,
+ 2550320,
+ 995782,
+ 2000124,
+ 1994141,
+ 2008076,
+ 2498960,
+ 2499695,
+ 2397246,
+ 2397327,
+ 1999580,
+ 1909980,
+ 1993116,
+ 2067276,
+ 2506767,
+ 2519087,
+ 1011734,
+ 2475088,
+ 2724289,
+ 1077319,
+ 2168862,
+ 1988124,
+ 2185565,
+ 2713744,
+ 2804689,
+ 2788129,
+ 2779473,
+ 1880764,
+ 1982924,
+ 1801179,
+ 1786859,
+ 2396046,
+ 2306974,
+ 2393775,
+ 2400767,
+ 1799067,
+ 1795499,
+ 1806715,
+ 1806683,
+ 2400223,
+ 2400879,
+ 2396223,
+ 2394862,
+ 1797883,
+ 1794555,
+ 1800155,
+ 1818331,
+ 2517759,
+ 2520751,
+ 2496143,
+ 2489440,
+ 1897740,
+ 1995405,
+ 1911708,
+ 1917163,
+ 1703322,
+ 2696145,
+ 2635312,
+ 985702,
+ 2671073,
+ 998726,
+ 1994172,
+ 1990204,
+ 1004102,
+ 1999244,
+ 1598202,
+ 2603392,
+ 2600592,
+ 997494,
+ 2508895,
+ 1802091,
+ 1776459,
+ 1915436,
+ 1922284,
+ 2606368,
+ 2615216,
+ 2686160,
+ 2685760,
+ 2091708,
+ 2089388,
+ 2084333,
+ 2186718,
+ 2602528,
+ 2601056,
+ 2802721,
+ 2797009,
+ 2294510,
+ 2299326,
+ 1000279,
+ 2109101,
+ 2035388,
+ 2498896,
+ 2397006,
+ 2399375,
+ 2405935,
+ 2695040,
+ 2699489,
+ 2701424,
+ 2690160,
+ 3610822,
+ 3603126,
+ 3602790,
+ 3642711,
+ 2609168,
+ 3595862,
+ 3298452,
+ 5795540,
+ 5855219,
+ 4413467,
+ 3094931,
+ 3014307,
+ 3178659,
+ 3584694,
+ 3380085,
+ 3315589,
+ 3494677,
+ 2591856,
+ 2690272,
+ 2689296,
+ 2685953,
+ 3304276,
+ 3399173,
+ 3398549,
+ 3391380,
+ 2793601,
+ 2710576,
+ 2710352,
+ 2711265,
+ 3314740,
+ 3410261,
+ 3409685,
+ 3433765,
+ 2490303,
+ 4510764,
+ 1602602,
+ 4183530,
+ 4115225,
+ 1993548,
+ 3577446,
+ 899478,
+ 2895985,
+ 2897218,
+ 1801227,
+ 2696544,
+ 3318277,
+ 3364452,
+ 1695370,
+ 3395269,
+ 3337253,
+ 2489952,
+ 2225981,
+ 3056722,
+ 3200804,
+ 3105939,
+ 4005833,
+ 6659337,
+ 6695753,
+ 6693737,
+ 4378411,
+ 2610015,
+ 4315034,
+ 4303514,
+ 54985089,
+ 2663808,
+ 56583738,
+ 56697803,
+ 980470,
+ 2803649,
+ 1883020,
+ 1876844,
+ 1800763,
+ 1685370,
+ 2499663,
+ 2503151,
+ 2495567,
+ 2600096,
+ 1788507,
+ 1792875,
+ 1799627,
+ 1802443,
+ 2402382,
+ 2403774,
+ 2501072,
+ 2523215,
+ 1891196,
+ 1896140,
+ 1814155,
+ 1685323,
+ 2394703,
+ 2391855,
+ 2490655,
+ 2499263,
+ 2017820,
+ 2022364,
+ 1891739,
+ 1892044,
+ 2395055,
+ 2398895,
+ 2398142,
+ 2508912,
+ 1797963,
+ 1802811,
+ 1794235,
+ 1815403,
+ 2608864,
+ 2629024,
+ 2578064,
+ 2709441,
+ 2089500,
+ 2085245,
+ 2103485,
+ 2110061,
+ 2585599,
+ 2595871,
+ 2491791,
+ 2486543,
+ 1795083,
+ 1790347,
+ 1797883,
+ 1803051,
+ 2404031,
+ 2403839,
+ 2396143,
+ 2399087,
+ 1798683,
+ 1798155,
+ 1794250,
+ 1797914,
+ 2397823,
+ 2398751,
+ 2501344,
+ 2504400,
+ 1900683,
+ 1900555,
+ 1807355,
+ 1800603,
+ 2405247,
+ 2406639,
+ 2512111,
+ 2515327,
+ 1992284,
+ 1994460,
+ 1987132,
+ 1984444,
+ 2804641,
+ 2818561,
+ 2790865,
+ 2793345,
+ 1885916,
+ 1881660,
+ 1793323,
+ 1792507,
+ 2392207,
+ 2400399,
+ 2613120,
+ 2614336,
+ 2017788,
+ 2015948,
+ 1904364,
+ 1910492,
+ 2497407,
+ 2505199,
+ 2374559,
+ 2480031,
+ 1888796,
+ 1894108,
+ 2092380,
+ 2091213,
+ 2603280,
+ 2608304,
+ 2404639,
+ 2309390,
+ 1900875,
+ 1897835,
+ 1912924,
+ 1997388,
+ 2491296,
+ 2584336,
+ 2397871,
+ 2492591,
+ 1807659,
+ 1996812,
+ 1895932,
+ 1895836,
+ 2403215,
+ 2403390,
+ 2418846,
+ 2508159,
+ 2000348,
+ 1906668,
+ 2088685,
+ 2001916,
+ 2502399,
+ 2513231,
+ 2402543,
+ 2399839,
+ 1997885,
+ 1992365,
+ 2098493,
+ 2100253,
+ 2597439,
+ 2601504,
+ 2611520,
+ 2614960,
+ 2097948,
+ 2103533,
+ 2085756,
+ 2096236,
+ 2493136,
+ 2496288,
+ 2398607,
+ 2397759,
+ 1794731,
+ 1793819,
+ 1788043,
+ 1792011,
+ 2501423,
+ 2508271,
+ 2529839,
+ 2530912,
+ 1783291,
+ 1791739,
+ 1775883,
+ 1784874,
+ 2405615,
+ 2414271,
+ 2392575,
+ 2384911,
+ 1796859,
+ 1886507,
+ 2116317,
+ 2125325,
+ 2699840,
+ 2623184,
+ 2486319,
+ 2497791,
+ 1893756,
+ 1882652,
+ 1789947,
+ 1901036,
+ 2506447,
+ 2505183,
+ 2500431,
+ 2604336,
+ 1109111,
+ 2112269,
+ 2200893,
+ 2094045,
+ 1605898,
+ 2590864,
+ 2593520,
+ 2714320,
+ 1085718,
+ 2097469,
+ 1984941,
+ 2125501,
+ 989574,
+ 2105197,
+ 2589167,
+ 2481023,
+ 2613968,
+ 2620784,
+ 2104717,
+ 2113117,
+ 2086316,
+ 2080909,
+ 2586864,
+ 2589168,
+ 2597664,
+ 2615472,
+ 2101405,
+ 2201854,
+ 1125527,
+ 2118653,
+ 2238606,
+ 2708112,
+ 2780401,
+ 2783329,
+ 2787553,
+ 2103229,
+ 1989052,
+ 1989500,
+ 1989532,
+ 2589472,
+ 2488287,
+ 2487407,
+ 2492367,
+ 1799931,
+ 2008557,
+ 2008797,
+ 2013021,
+ 2591456,
+ 2396750,
+ 2401134,
+ 2401550,
+ 1791819,
+ 1793003,
+ 1789659,
+ 1790891,
+ 2396398,
+ 2400975,
+ 2404271,
+ 2400031,
+ 1838220,
+ 1900140,
+ 1902700,
+ 1904860,
+ 2585759,
+ 2588447,
+ 2594735,
+ 2602928,
+ 1992477,
+ 1892860,
+ 1894332,
+ 1982700,
+ 2508895,
+ 2506079,
+ 2522063,
+ 2501119,
+ 1895884,
+ 1991997,
+ 1915900,
+ 2012397,
+ 1597993,
+ 2601663,
+ 2701056,
+ 2697984,
+ 2087437,
+ 2197678,
+ 1892236,
+ 1893612,
+ 2414399,
+ 2409295,
+ 2595440,
+ 2599632,
+ 2086477,
+ 2081436,
+ 2101596,
+ 2105708,
+ 2594176,
+ 2603360,
+ 2393695,
+ 2396207,
+ 1826923,
+ 1844428,
+ 1913068,
+ 1917788,
+ 1589178,
+ 2675328,
+ 2572031,
+ 2586944,
+ 1997244,
+ 1981868,
+ 2020156,
+ 1888763,
+ 2602192,
+ 2599616,
+ 2599664,
+ 2791201,
+ 2019308,
+ 1910268,
+ 1928524,
+ 1917452,
+ 2584304,
+ 2592080,
+ 2598128,
+ 2589248,
+ 2005388,
+ 1998684,
+ 1999740,
+ 2015292,
+ 2683057,
+ 2686161,
+ 2685745,
+ 2581248,
+ 1896731,
+ 1896699,
+ 1899963,
+ 1904316,
+ 2397039,
+ 2399071,
+ 2402991,
+ 2395470,
+ 1823771,
+ 1826443,
+ 1823083,
+ 1795819,
+ 2377935,
+ 2377839,
+ 2384767,
+ 2509808,
+ 1893547,
+ 1890267,
+ 1898411,
+ 1794043,
+ 2400159,
+ 2400319,
+ 2399215,
+ 2406766,
+ 1908843,
+ 1910651,
+ 1908555,
+ 1897612,
+ 2380735,
+ 2380623,
+ 2384303,
+ 2401247,
+ 1913372,
+ 1911836,
+ 1912732,
+ 2108764,
+ 2705456,
+ 2703184,
+ 2803313,
+ 987062,
+ 2695105,
+ 1886892,
+ 1885883,
+ 1791259,
+ 1691466,
+ 2406254,
+ 2442735,
+ 2405775,
+ 2406479,
+ 12105771,
+ 11987002,
+ 12126282,
+ 12133946,
+ 2547823,
+ 2537807,
+ 2672896,
+ 2797825,
+ 1954988,
+ 1953804,
+ 1900748,
+ 1782395,
+ 2589360,
+ 2598944,
+ 2484911,
+ 2484303,
+ 1999244,
+ 1997868,
+ 1993724,
+ 1992428,
+ 2600128,
+ 2602944,
+ 2601072,
+ 2604432,
+ 1786859,
+ 1788331,
+ 1797355,
+ 1805595,
+ 2503311,
+ 2503615,
+ 2596064,
+ 2599664,
+ 1892012,
+ 1898412,
+ 1817115,
+ 1810139,
+ 2417231,
+ 2413007,
+ 2496960,
+ 2499008,
+ 1982364,
+ 1984204,
+ 1887499,
+ 1896667,
+ 2403870,
+ 2408335,
+ 2418815,
+ 2412319,
+ 1792811,
+ 1795738,
+ 1890252,
+ 1889660,
+ 2598592,
+ 2606048,
+ 2617200,
+ 2614208,
+ 1993229,
+ 1993357,
+ 1878891,
+ 1880635,
+ 2408446,
+ 2409198,
+ 2507919,
+ 2513391,
+ 1999565,
+ 1999837,
+ 1991613,
+ 1993581,
+ 2490111,
+ 2493439,
+ 2495391,
+ 2501071,
+ 1997260,
+ 1996652,
+ 1996684,
+ 2001932,
+ 2505663,
+ 2510927,
+ 2403103,
+ 2408975,
+ 1801419,
+ 1799307,
+ 1797755,
+ 1796331,
+ 2410319,
+ 2410623,
+ 2488815,
+ 2484943,
+ 1877484,
+ 1882860,
+ 1815419,
+ 1819947,
+ 2502495,
+ 2505263,
+ 2487551,
+ 2491279,
+ 1796395,
+ 1801707,
+ 1799435,
+ 1802043,
+ 2388318,
+ 2397679,
+ 2389791,
+ 2387167,
+ 1800107,
+ 1809804,
+ 1797451,
+ 1796571,
+ 2520191,
+ 2523903,
+ 2619328,
+ 2618544,
+ 1987916,
+ 1988620,
+ 1989196,
+ 1991052,
+ 2478335,
+ 2483615,
+ 2396959,
+ 2401119,
+ 1806843,
+ 1811067,
+ 1793211,
+ 1892267,
+ 2409135,
+ 2506352,
+ 2405070,
+ 2400895,
+ 1885628,
+ 1792123,
+ 1894796,
+ 1801211,
+ 2399070,
+ 2406430,
+ 2418815,
+ 2410239,
+ 1796411,
+ 1796795,
+ 1793691,
+ 1793019,
+ 2412367,
+ 2410863,
+ 2503951,
+ 2625584,
+ 2172029,
+ 2180733,
+ 2062748,
+ 2199182,
+ 2512560,
+ 2509184,
+ 2399375,
+ 2390846,
+ 1117847,
+ 2011452,
+ 2097309,
+ 2004700,
+ 2499503,
+ 2417102,
+ 2511999,
+ 2602176,
+ 1899996,
+ 1901388,
+ 1891500,
+ 1897388,
+ 2483071,
+ 2488255,
+ 2488751,
+ 2396383,
+ 1821483,
+ 1815547,
+ 1822971,
+ 1794411,
+ 2381023,
+ 2385887,
+ 2389551,
+ 2407838,
+ 1808555,
+ 1810683,
+ 1810491,
+ 1794619,
+ 2393151,
+ 2397519,
+ 2395199,
+ 2406543,
+ 1889931,
+ 1890011,
+ 1886955,
+ 1892188,
+ 2504303,
+ 2502495,
+ 2506655,
+ 1092215,
+ 2812561,
+ 1994989,
+ 1991373,
+ 1889387,
+ 1998492,
+ 2696784,
+ 2700224,
+ 2520016,
+ 2526768,
+ 1797371,
+ 1805467,
+ 1781899,
+ 1778043,
+ 2400447,
+ 2390399,
+ 2395150,
+ 2393262,
+ 1798091,
+ 1895739,
+ 1909580,
+ 1912124,
+ 2498607,
+ 2500992,
+ 2404879,
+ 2405871,
+ 1798427,
+ 1706810,
+ 1988364,
+ 1991804,
+ 2599856,
+ 2592256,
+ 2497695,
+ 2615168,
+ 1896476,
+ 1901164,
+ 1795723,
+ 1801595,
+ 2398878,
+ 2497487,
+ 2395887,
+ 2375358,
+ 1809115,
+ 1708154,
+ 1804459,
+ 1705851,
+ 2405295,
+ 2404975,
+ 2504207,
+ 2509839,
+ 1997196,
+ 2002188,
+ 1891212,
+ 1890524,
+ 2382607,
+ 2388623,
+ 2715504,
+ 2713200,
+ 2194029,
+ 2193181,
+ 1889948,
+ 1992908,
+ 2405503,
+ 2404655,
+ 2389710,
+ 2387839,
+ 1795627,
+ 1795227,
+ 1816444,
+ 1811531,
+ 2399279,
+ 2404671,
+ 2386958,
+ 2389087,
+ 1801979,
+ 1803243,
+ 1796315,
+ 1704282,
+ 2399678,
+ 2397966,
+ 2380191,
+ 2391263,
+ 1802107,
+ 1801707,
+ 1808331,
+ 1815483,
+ 2390639,
+ 2384607,
+ 2397870,
+ 2395246,
+ 1899755,
+ 1902060,
+ 1901964,
+ 1903244,
+ 2397967,
+ 2397646,
+ 2394239,
+ 2397775,
+ 1798731,
+ 1795243,
+ 1798315,
+ 1799707,
+ 2401471,
+ 2401887,
+ 900421,
+ 2496991,
+ 2513775,
+ 1808379,
+ 1799099,
+ 1713547,
+ 1798091,
+ 2396255,
+ 2399935,
+ 2376206,
+ 2414751,
+ 898502,
+ 1896715,
+ 1914812,
+ 1922748,
+ 2499263,
+ 2502784,
+ 2286222,
+ 2275533,
+ 1699978,
+ 1593145,
+ 1689610,
+ 1691867,
+ 2300638,
+ 2300206,
+ 3328821,
+ 3235348,
+ 2707713,
+ 2709009,
+ 1977292,
+ 1998236,
+ 2604688,
+ 2606576,
+ 2390270,
+ 2381870,
+ 1788923,
+ 1787339,
+ 2000157,
+ 2007629,
+ 2599904,
+ 2597216,
+ 2393150,
+ 2398942,
+ 1798219,
+ 1797723,
+ 1804155,
+ 1803211,
+ 2398622,
+ 2399310,
+ 2595296,
+ 2598672,
+ 2004636,
+ 2007084,
+ 1821547,
+ 1820795,
+ 2397071,
+ 2395615,
+ 2470351,
+ 2475311,
+ 1930940,
+ 1932972,
+ 1910780,
+ 1910284,
+ 2472143,
+ 2478639,
+ 2390383,
+ 2388271,
+ 1796635,
+ 1795051,
+ 2017916,
+ 2020668,
+ 2611632,
+ 2611472,
+ 2376351,
+ 2482687,
+ 1897404,
+ 1900108,
+ 2698464,
+ 2714385,
+ 3288020,
+ 3387396,
+ 3415445,
+ 3392853,
+ 2697344,
+ 2692817,
+ 2583216,
+ 2585327,
+ 3098771,
+ 3100035,
+ 3102659,
+ 3101443,
+ 2501904,
+ 2400463,
+ 1701866,
+ 2590096,
+ 2504576,
+ 4820493,
+ 4205482,
+ 4102937,
+ 4179673,
+ 1693834,
+ 2877042,
+ 3721942,
+ 3634166,
+ 3702727,
+ 3611526,
+ 2389583,
+ 2387023,
+ 3096163,
+ 3091443,
+ 4997567,
+ 5007295,
+ 3498453,
+ 3496085,
+ 3290196,
+ 3298516,
+ 3326372,
+ 3328948,
+ 2594192,
+ 2597472,
+ 5203680,
+ 5203744,
+ 6092021,
+ 6103861,
+ 3469445,
+ 3476901,
+ 3488661,
+ 3602694,
+ 3498758,
+ 3602838,
+ 2899042,
+ 3024307,
+ 3199315,
+ 3189796,
+ 3493381,
+ 3504037,
+ 3398965,
+ 3302756,
+ 2808545,
+ 2806881,
+ 2800241,
+ 2796817,
+ 3297460,
+ 3294324,
+ 4863038,
+ 4963055,
+ 3697607,
+ 3697815,
+ 1692874,
+ 2948482,
+ 2872113,
+ 2688048,
+ 2100525,
+ 2072637,
+ 2124173,
+ 1998253,
+ 2497776,
+ 2384831,
+ 2499951,
+ 2494559,
+ 1809739,
+ 1806235,
+ 1804315,
+ 1912492,
+ 2622832,
+ 2621104,
+ 2532448,
+ 2585679,
+ 1853243,
+ 1855915,
+ 1856619,
+ 1807084,
+ 2395663,
+ 2398143,
+ 2398367,
+ 2407006,
+ 1799611,
+ 1798859,
+ 1897227,
+ 1788731,
+ 2400494,
+ 2398142,
+ 2302862,
+ 2406847,
+ 1924524,
+ 1923964,
+ 1935628,
+ 2002556,
+ 2692929,
+ 2694113,
+ 2690769,
+ 2604192,
+ 1899563,
+ 1896059,
+ 1898811,
+ 1977004,
+ 2702273,
+ 2706225,
+ 2715057,
+ 2593792,
+ 1785963,
+ 1793387,
+ 1793051,
+ 1827531,
+ 2496735,
+ 2497695,
+ 2498831,
+ 2585760,
+ 1998220,
+ 2001164,
+ 1998252,
+ 1129175,
+ 2144573,
+ 2696529,
+ 2692417,
+ 2560976,
+ 2568976,
+ 2204685,
+ 2204893,
+ 2420015,
+ 2537135,
+ 2796753,
+ 2891666,
+ 2578543,
+ 2559472,
+ 1893324,
+ 1899259,
+ 1914860,
+ 1909532,
+ 2587936,
+ 2578384,
+ 2581936,
+ 2630224,
+ 999798,
+ 1928172,
+ 2120749,
+ 1096135,
+ 2067404,
+ 3000786,
+ 2905537,
+ 2906369,
+ 2807890,
+ 1998365,
+ 1998173,
+ 1989804,
+ 2004029,
+ 2601024,
+ 2614256,
+ 2597744,
+ 2596496,
+ 1983532,
+ 1990156,
+ 1899611,
+ 1904987,
+ 2596080,
+ 2601328,
+ 2588416,
+ 2695969,
+ 1794683,
+ 1799995,
+ 1799019,
+ 1695066,
+ 2397742,
+ 2411086,
+ 2680800,
+ 2688416,
+ 2096205,
+ 2091581,
+ 2018525,
+ 2026413,
+ 2603024,
+ 2598432,
+ 2391663,
+ 2386271,
+ 1802555,
+ 1906012,
+ 1799098,
+ 1802395,
+ 2501807,
+ 2403054,
+ 2504816,
+ 2502575,
+ 1790955,
+ 1785979,
+ 1790667,
+ 1791883,
+ 2403823,
+ 2402575,
+ 2395742,
+ 2399246,
+ 1988348,
+ 2099165,
+ 1998413,
+ 1992653,
+ 2610512,
+ 2518447,
+ 2817073,
+ 2925922,
+ 2183278,
+ 2277710,
+ 1992300,
+ 1985516,
+ 2576031,
+ 2468767,
+ 2612128,
+ 2515503,
+ 1819611,
+ 1828187,
+ 1776603,
+ 1780203,
+ 2398015,
+ 2494976,
+ 2406591,
+ 2411055,
+ 2137965,
+ 2041532,
+ 2191389,
+ 2198829,
+ 2462095,
+ 2468671,
+ 2400079,
+ 2399119,
+ 1796555,
+ 1796139,
+ 1792667,
+ 1794363,
+ 2396703,
+ 2394559,
+ 2398174,
+ 2393854,
+ 1798235,
+ 1799067,
+ 1799915,
+ 1799707,
+ 2403871,
+ 2406367,
+ 2399023,
+ 2402287,
+ 1798363,
+ 1799563,
+ 40524648,
+ 41218316,
+ 2758817,
+ 41224588,
+ 2589504,
+ 2887953,
+ 2887761,
+ 2890993,
+ 2704464,
+ 3107443,
+ 3109203,
+ 3107043,
+ 3299524,
+ 2922306,
+ 2918706,
+ 2920050,
+ 2911234,
+ 3483077,
+ 3486133,
+ 3492086,
+ 4988175,
+ 3381909,
+ 3387589,
+ 3383764,
+ 2492895,
+ 3395572,
+ 4995183,
+ 5000367,
+ 3394613,
+ 3393733,
+ 3319316,
+ 3314180,
+ 4929342,
+ 4926430,
+ 3383973,
+ 3480293,
+ 2514319,
+ 3490278,
+ 3539302,
+ 2484511,
+ 4997375,
+ 1000886,
+ 3396949,
+ 3442629,
+ 3505605,
+ 5022143,
+ 5027326,
+ 5027759,
+ 3395141,
+ 3283764,
+ 3295844,
+ 3277588,
+ 3102611,
+ 2578320,
+ 2583904,
+ 2598000,
+ 5097807,
+ 4117833,
+ 4115561,
+ 4112265,
+ 2500960,
+ 4991391,
+ 4999327,
+ 4991279,
+ 4096249,
+ 2793425,
+ 2787265,
+ 2701824,
+ 2901201,
+ 4512428,
+ 4513356,
+ 4507116,
+ 6008181,
+ 3909191,
+ 3899655,
+ 3916295,
+ 4119961,
+ 3463974,
+ 3469702,
+ 3474358,
+ 3366357,
+ 5212160,
+ 5221856,
+ 5228640,
+ 3600006,
+ 3194899,
+ 3193923,
+ 3301492,
+ 3302292,
+ 2799217,
+ 2796241,
+ 2788017,
+ 4994751,
+ 4189594,
+ 4093913,
+ 4189642,
+ 2702032,
+ 4901758,
+ 4904878,
+ 4901790,
+ 4111817,
+ 1790395,
+ 1786379,
+ 1787227,
+ 1789083,
+ 2401902,
+ 2400974,
+ 2400894,
+ 2407199,
+ 1794955,
+ 1794795,
+ 1794379,
+ 1788731,
+ 2401263,
+ 2402175,
+ 2403167,
+ 2500031,
+ 1899660,
+ 1898300,
+ 1904028,
+ 1811595,
+ 2505215,
+ 2513855,
+ 2506959,
+ 2588160,
+ 1893676,
+ 1891788,
+ 1894908,
+ 1811035,
+ 2399870,
+ 2405134,
+ 2415550,
+ 2488479,
+ 1911980,
+ 1906172,
+ 1903516,
+ 1800683,
+ 2405359,
+ 2411535,
+ 2412335,
+ 2526272,
+ 1987980,
+ 1986876,
+ 1994572,
+ 1973692,
+ 2597200,
+ 2599296,
+ 2598816,
+ 2524223,
+ 1895035,
+ 1893227,
+ 1902203,
+ 1974685,
+ 2504912,
+ 2506816,
+ 2503872,
+ 2399966,
+ 1796075,
+ 1799723,
+ 1791067,
+ 1794699,
+ 2403134,
+ 2400318,
+ 2404302,
+ 2399663,
+ 1798363,
+ 1796603,
+ 1801643,
+ 1803787,
+ 2500960,
+ 2500928,
+ 2506928,
+ 2714096,
+ 2004460,
+ 2002348,
+ 2011948,
+ 1880412,
+ 1601866,
+ 2582112,
+ 2578448,
+ 2586176,
+ 897301,
+ 1904107,
+ 1904139,
+ 1905371,
+ 1896668,
+ 2499824,
+ 2500304,
+ 2505088,
+ 2498159,
+ 1900971,
+ 1896875,
+ 1901243,
+ 1903068,
+ 2405567,
+ 2404159,
+ 2409919,
+ 2393342,
+ 1791995,
+ 1791739,
+ 1797771,
+ 1799675,
+ 2622544,
+ 2623088,
+ 2630816,
+ 2709233,
+ 1974492,
+ 1978732,
+ 1980076,
+ 1917308,
+ 2495327,
+ 2494959,
+ 2497680,
+ 2499087,
+ 1792091,
+ 1792267,
+ 1796636,
+ 1893660,
+ 2609664,
+ 2608783,
+ 2608831,
+ 2604416,
+ 1981533,
+ 1985997,
+ 1989981,
+ 1016134,
+ 2015372,
+ 2599824,
+ 2611536,
+ 2677728,
+ 2689680,
+ 1995004,
+ 1982348,
+ 1799547,
+ 1802523,
+ 2517311,
+ 2520255,
+ 2706753,
+ 2715713,
+ 1979420,
+ 1982700,
+ 1884971,
+ 1886203,
+ 2696785,
+ 2700273,
+ 2587600,
+ 2592112,
+ 1803979,
+ 1804843,
+ 1911260,
+ 1914988,
+ 2494527,
+ 2502703,
+ 2505279,
+ 2511631,
+ 2012092,
+ 2009964,
+ 1973404,
+ 1982268,
+ 2490320,
+ 2492976,
+ 2394991,
+ 2395087,
+ 1792347,
+ 1797643,
+ 1799307,
+ 1793963,
+ 2397534,
+ 2399246,
+ 2399535,
+ 2399007,
+ 1794507,
+ 1796283,
+ 1798987,
+ 1799051,
+ 2400815,
+ 2403039,
+ 2398702,
+ 2398270,
+ 1797435,
+ 1799739,
+ 1801179,
+ 1800747,
+ 2397775,
+ 2399519,
+ 2398287,
+ 2399167,
+ 1797579,
+ 1799419,
+ 1799483,
+ 1797707,
+ 2596591,
+ 2705200,
+ 2600496,
+ 2600432,
+ 1992381,
+ 1999292,
+ 2223629,
+ 2221821,
+ 2805649,
+ 2800993,
+ 2704593,
+ 2803650,
+ 2401214,
+ 2377631,
+ 2604064,
+ 2628064,
+ 2833089,
+ 3012323,
+ 2993826,
+ 2880225,
+ 969094,
+ 2399887,
+ 2331454,
+ 893894,
+ 1965516,
+ 1602554,
+ 2475167,
+ 2497791,
+ 896245,
+ 2505568,
+ 1854412,
+ 2027597,
+ 1999564,
+ 1997468,
+ 2694848,
+ 2700016,
+ 1416313,
+ 3315285,
+ 3234596,
+ 1408473,
+ 2778833,
+ 2396766,
+ 2462031,
+ 2712561,
+ 2802289,
+ 2596240,
+ 2630640,
+ 1992700,
+ 1998412,
+ 2000204,
+ 1990284,
+ 2393502,
+ 2488975,
+ 2431823,
+ 2321694,
+ 1897420,
+ 1802331,
+ 1981548,
+ 1978140,
+ 2501103,
+ 2499279,
+ 2398831,
+ 2410399,
+ 1901900,
+ 2002029,
+ 1898428,
+ 1893564,
+ 2405231,
+ 2404398,
+ 2484943,
+ 2493487,
+ 1892315,
+ 1892556,
+ 1804891,
+ 1809515,
+ 2395103,
+ 2396575,
+ 2498719,
+ 2501535,
+ 1889436,
+ 1888827,
+ 1812731,
+ 1807195,
+ 2533135,
+ 2531328,
+ 2582064,
+ 2582176,
+ 1882716,
+ 1882603,
+ 1808315,
+ 1811179,
+ 2385022,
+ 2383615,
+ 2403231,
+ 2411215,
+ 1799851,
+ 1798347,
+ 1887227,
+ 1904139,
+ 2522768,
+ 2425807,
+ 2492704,
+ 2481088,
+ 1877195,
+ 1970572,
+ 1906123,
+ 1906875,
+ 2496495,
+ 2497647,
+ 2393071,
+ 2395247,
+ 1800667,
+ 1801003,
+ 1802587,
+ 1805963,
+ 2425007,
+ 2423599,
+ 2399103,
+ 2399999,
+ 1881916,
+ 1881835,
+ 1901275,
+ 1906987,
+ 2721952,
+ 2715825,
+ 2791713,
+ 2790289,
+ 1003798,
+ 2085309,
+ 2015740,
+ 1996413,
+ 2597840,
+ 2596784,
+ 2599280,
+ 2493167,
+ 1909516,
+ 1910236,
+ 1906556,
+ 1897003,
+ 2500303,
+ 2388702,
+ 2496303,
+ 2501232,
+ 1802091,
+ 1889548,
+ 1827451,
+ 1798443,
+ 2401711,
+ 2305710,
+ 2378063,
+ 2414334,
+ 2096461,
+ 2103741,
+ 2091996,
+ 2188638,
+ 2592672,
+ 2629648,
+ 2737649,
+ 985798,
+ 2700720,
+ 2067693,
+ 2056092,
+ 2094909,
+ 2118173,
+ 1616361,
+ 2609504,
+ 2637216,
+ 987847,
+ 2582576,
+ 1960636,
+ 2084909,
+ 2013516,
+ 2036077,
+ 1713290,
+ 2719681,
+ 2662800,
+ 973590,
+ 2663008,
+ 998982,
+ 1938364,
+ 2006732,
+ 1108551,
+ 2102781,
+ 1590298,
+ 2694976,
+ 2698801,
+ 992774,
+ 2591696,
+ 1014694,
+ 1882155,
+ 2007197,
+ 985926,
+ 2023596,
+ 1602474,
+ 2677377,
+ 2628272,
+ 992982,
+ 2570576,
+ 1006262,
+ 1964924,
+ 2035948,
+ 992198,
+ 1996668,
+ 1619258,
+ 2610752,
+ 2611216,
+ 983510,
+ 2603200,
+ 1857371,
+ 1987676,
+ 1898012,
+ 1903067,
+ 2605232,
+ 2598784,
+ 2599696,
+ 2620785,
+ 1001494,
+ 1983068,
+ 1930652,
+ 996518,
+ 1972092,
+ 1718603,
+ 2678592,
+ 2751121,
+ 1083414,
+ 2800561,
+ 1007702,
+ 2093533,
+ 2093069,
+ 992022,
+ 2003996,
+ 1617386,
+ 2607984,
+ 2611312,
+ 983238,
+ 2602784,
+ 1993116,
+ 2051293,
+ 2000412,
+ 1995452,
+ 2584288,
+ 2635104,
+ 2601216,
+ 2603536,
+ 2107981,
+ 2056060,
+ 12740382,
+ 12745358,
+ 1667770,
+ 13207633,
+ 13347297,
+ 1100407,
+ 2758449,
+ 1312168,
+ 2423775,
+ 2415263,
+ 1289976,
+ 2604672,
+ 1692699,
+ 2982290,
+ 2980898,
+ 992102,
+ 2597200,
+ 1004758,
+ 1997020,
+ 1981068,
+ 1899131,
+ 2414862,
+ 2432319,
+ 2437567,
+ 987015,
+ 2596736,
+ 1107830,
+ 2073501,
+ 2087037,
+ 1289080,
+ 2393039,
+ 1913356,
+ 3203652,
+ 3202564,
+ 1079975,
+ 2999986,
+ 1000742,
+ 2083084,
+ 2081308,
+ 991926,
+ 1991628,
+ 1607562,
+ 2600272,
+ 2600224,
+ 1111430,
+ 2714193,
+ 1399241,
+ 2510272,
+ 2509584,
+ 1198199,
+ 2512735,
+ 1892460,
+ 2965202,
+ 3081922,
+ 2886018,
+ 2194861,
+ 2206253,
+ 2209278,
+ 2206045,
+ 2597712,
+ 2512495,
+ 2685393,
+ 1105767,
+ 2819378,
+ 1301048,
+ 2497792,
+ 2465935,
+ 1193399,
+ 2469583,
+ 1707851,
+ 2898961,
+ 2891922,
+ 1184903,
+ 2898577,
+ 1100295,
+ 2276574,
+ 2283885,
+ 993110,
+ 2100269,
+ 5647442,
+ 6648329,
+ 6624665,
+ 6618537,
+ 2063885,
+ 2069085,
+ 2065069,
+ 2086141,
+ 1738010,
+ 2830881,
+ 2814673,
+ 2827153,
+ 1057287,
+ 1972044,
+ 2003132,
+ 1994908,
+ 1089815,
+ 2093868,
+ 1608202,
+ 2676672,
+ 2690977,
+ 994710,
+ 2599056,
+ 1002598,
+ 1997805,
+ 1997052,
+ 992694,
+ 1910636,
+ 1611306,
+ 2477071,
+ 2588911,
+ 3497989,
+ 1114391,
+ 3016754,
+ 3017363,
+ 3116323,
+ 1287112,
+ 1911852,
+ 3275940,
+ 3220628,
+ 3222036,
+ 1285688,
+ 2432591,
+ 2500751,
+ 2500303,
+ 2194205,
+ 1611930,
+ 2660401,
+ 2595440,
+ 2587728,
+ 982198,
+ 2013900,
+ 2083933,
+ 2088541,
+ 1999660,
+ 2707488,
+ 2913842,
+ 2806513,
+ 2913522,
+ 2085148,
+ 2308814,
+ 2208109,
+ 1246856,
+ 2546160,
+ 2661872,
+ 2786993,
+ 995239,
+ 2626272,
+ 2563231,
+ 993286,
+ 1939372,
+ 1112006,
+ 2107837,
+ 2106989,
+ 1594746,
+ 2717409,
+ 1014870,
+ 2610384,
+ 2608896,
+ 983142,
+ 2001148,
+ 1125047,
+ 1995852,
+ 2102909,
+ 1899068,
+ 3059795,
+ 1373416,
+ 3364709,
+ 3300404,
+ 1311960,
+ 2643264,
+ 1409465,
+ 2699008,
+ 2741361,
+ 1788091,
+ 3198179,
+ 1091303,
+ 2882145,
+ 2881137,
+ 991878,
+ 2093757,
+ 1004550,
+ 1994940,
+ 1997852,
+ 1596042,
+ 2591936,
+ 1219351,
+ 2816146,
+ 2817986,
+ 1198407,
+ 2415615,
+ 1200248,
+ 2399262,
+ 2396158,
+ 1796459,
+ 2997234,
+ 1301224,
+ 3098467,
+ 3099123,
+ 1191383,
+ 2493487,
+ 1305304,
+ 2497792,
+ 2499264,
+ 1699290,
+ 3006755,
+ 1305512,
+ 3003554,
+ 3006434,
+ 1087559,
+ 2392110,
+ 1205847,
+ 2270910,
+ 2323758,
+ 1799883,
+ 3006227,
+ 2694048,
+ 2785697,
+ 1104663,
+ 2198302,
+ 2148189,
+ 991110,
+ 2089309,
+ 1601578,
+ 2457807,
+ 2583584,
+ 992390,
+ 2487871,
+ 2183933,
+ 2113276,
+ 2098877,
+ 2097421,
+ 2700209,
+ 2798898,
+ 2698464,
+ 2817857,
+ 1006519,
+ 2021020,
+ 1925627,
+ 1095190,
+ 2075805,
+ 1605674,
+ 2658289,
+ 2719425,
+ 990246,
+ 2594976,
+ 1008054,
+ 1997116,
+ 1998364,
+ 992342,
+ 1997068,
+ 1609866,
+ 2600880,
+ 2601104,
+ 988838,
+ 2513551,
+ 2063181,
+ 2211565,
+ 2105741,
+ 2104093,
+ 2704016,
+ 2709009,
+ 2804545,
+ 2806913,
+ 2503472,
+ 2503407,
+ 2390223,
+ 2504464,
+ 1707306,
+ 2703504,
+ 2621088,
+ 992886,
+ 2675760,
+ 1017063,
+ 1978268,
+ 2036684,
+ 985142,
+ 1998828,
+ 1717146,
+ 2703681,
+ 2703553,
+ 1079447,
+ 2797009,
+ 1001702,
+ 2079853,
+ 2064589,
+ 2006589,
+ 2609296,
+ 2493295,
+ 2618784,
+ 1185735,
+ 2794625,
+ 2091965,
+ 2080540,
+ 2003404,
+ 2006108,
+ 2632176,
+ 2664817,
+ 1068694,
+ 2707313,
+ 2621344,
+ 995366,
+ 2033100,
+ 1003335,
+ 1974428,
+ 2034236,
+ 1595289,
+ 2597344,
+ 1002742,
+ 2599408,
+ 2598640,
+ 994055,
+ 1897820,
+ 1001702,
+ 2019772,
+ 1992397,
+ 1607529,
+ 2712048,
+ 994887,
+ 2574192,
+ 2602607,
+ 997270,
+ 1991388,
+ 999206,
+ 2001772,
+ 1995549,
+ 1601818,
+ 2603872,
+ 2411103,
+ 2471935,
+ 1795419,
+ 1782299,
+ 1799643,
+ 1784683,
+ 2425454,
+ 2434447,
+ 1087799,
+ 2704705,
+ 2628752,
+ 1974812,
+ 1891580,
+ 1809947,
+ 1889003,
+ 2398383,
+ 2402254,
+ 2387966,
+ 2391951,
+ 1911451,
+ 2000029,
+ 2002733,
+ 2016940,
+ 1592377,
+ 2687585,
+ 2493343,
+ 2516720,
+ 998262,
+ 1991996,
+ 1911116,
+ 995110,
+ 1955084,
+ 1602890,
+ 2573647,
+ 3003234,
+ 2396446,
+ 2423823,
+ 1112423,
+ 2109469,
+ 2900018,
+ 1393480,
+ 3285236,
+ 1197416,
+ 1205495,
+ 2403375,
+ 1893388,
+ 1401416,
+ 3295284,
+ 1194744,
+ 1203735,
+ 2399167,
+ 1800507,
+ 1211383,
+ 3008098,
+ 1193272,
+ 1300504,
+ 2493727,
+ 1882475,
+ 1208968,
+ 3104051,
+ 1096438,
+ 2381567,
+ 2006140,
+ 3487270,
+ 1392905,
+ 1420984,
+ 2811281,
+ 1393593,
+ 1886987,
+ 3279108,
+ 1404601,
+ 1307656,
+ 2714000,
+ 1395896,
+ 1985133,
+ 3377413,
+ 1312872,
+ 1108486,
+ 2339870,
+ 1075447,
+ 1810523,
+ 2991459,
+ 1211127,
+ 1209176,
+ 2399006,
+ 1091782,
+ 1808220,
+ 2900290,
+ 1292439,
+ 1299128,
+ 2592496,
+ 1192680,
+ 2601760,
+ 1107287,
+ 2702384,
+ 985686,
+ 1001398,
+ 1993052,
+ 1712522,
+ 1408665,
+ 3110755,
+ 1295992,
+ 1200807,
+ 2496912,
+ 1697051,
+ 1202471,
+ 2899777,
+ 1298888,
+ 1202583,
+ 2503040,
+ 1675914,
+ 1204664,
+ 2886257,
+ 1201863,
+ 2302046,
+ 1805196,
+ 1197031,
+ 1190455,
+ 1103687,
+ 1804731,
+ 1300520,
+ 1098471,
+ 1196439,
+ 1799755,
+ 1104055,
+ 992790,
+ 1202871,
+ 1808043,
+ 1201655,
+ 1092471,
+ 1208024,
+ 1796587,
+ 993718,
+ 998422
+ ],
+ "checkpoint_ns": [
+ 60045695,
+ 58246612,
+ 39362913,
+ 46641677
+ ],
+ "batches": 1891,
+ "segment_files": 4,
+ "blob_files": 0,
+ "energy": {
+ "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)",
+ "window_s": 2.635780498,
+ "valid": true,
+ "refusal": null,
+ "samples": 28,
+ "largest_gap_ms": 101.45,
+ "pkg_j": 173.869,
+ "cpu_p_j": 84.605,
+ "cpu_e_j": 6.213,
+ "rest_j": 83.051,
+ "pkg_mean_w": 65.96490114860848,
+ "pkg_edge_sd_j": 5.386011624907425,
+ "sys_total_mean_w": 78.07285714285715,
+ "nvme_temp_k": 319.0,
+ "loadavg_start": [
+ 14.85,
+ 9.49,
+ 7.68
+ ],
+ "loadavg_end": [
+ 14.85,
+ 9.49,
+ 7.68
+ ],
+ "machine_busy_cpu_s": 19.270000000018626
+ }
+ },
+ {
+ "agents": 8,
+ "rep": 0,
+ "accepted": 4000,
+ "elapsed_ns": 1361697145,
+ "latency_ns": [
+ 1404825,
+ 3787751,
+ 3881304,
+ 3819143,
+ 3819383,
+ 3811511,
+ 3830135,
+ 3826088,
+ 1404201,
+ 3881319,
+ 3217428,
+ 3298372,
+ 3304820,
+ 3384676,
+ 3320004,
+ 3351861,
+ 3750967,
+ 3826696,
+ 2675888,
+ 2747985,
+ 2984722,
+ 2927090,
+ 2924242,
+ 2900914,
+ 1293080,
+ 2453487,
+ 2375886,
+ 3011731,
+ 3026978,
+ 3012547,
+ 3014675,
+ 3004306,
+ 3108851,
+ 3126995,
+ 3121715,
+ 1304440,
+ 2524303,
+ 2779153,
+ 2721313,
+ 2715424,
+ 2723201,
+ 1291896,
+ 2580016,
+ 2589472,
+ 1905276,
+ 3282164,
+ 3182292,
+ 3179204,
+ 3272388,
+ 3182883,
+ 1287640,
+ 3190035,
+ 3181940,
+ 2136749,
+ 2072557,
+ 2215598,
+ 2297181,
+ 2295566,
+ 1070454,
+ 2181677,
+ 2102717,
+ 2073244,
+ 2690704,
+ 2691392,
+ 2668081,
+ 2693328,
+ 2492480,
+ 2473679,
+ 2468751,
+ 2564432,
+ 1654810,
+ 1884796,
+ 1841531,
+ 1949020,
+ 1799323,
+ 1825451,
+ 1816523,
+ 1823195,
+ 2490992,
+ 2408431,
+ 2442399,
+ 2477679,
+ 2500943,
+ 2474976,
+ 2481135,
+ 2477839,
+ 1804875,
+ 1671867,
+ 1899995,
+ 1858395,
+ 2022524,
+ 2042780,
+ 2062060,
+ 2061869,
+ 2797185,
+ 2800001,
+ 2753825,
+ 2848546,
+ 2996147,
+ 2815778,
+ 2969426,
+ 2926673,
+ 2302750,
+ 2213614,
+ 2390574,
+ 2300382,
+ 2005564,
+ 2011036,
+ 2152253,
+ 2042685,
+ 2596896,
+ 2596000,
+ 2619040,
+ 2728657,
+ 881877,
+ 2578688,
+ 2508624,
+ 2528127,
+ 2508895,
+ 1799979,
+ 1645194,
+ 1591082,
+ 2112013,
+ 2105453,
+ 2091757,
+ 2125693,
+ 2236109,
+ 2795985,
+ 2881441,
+ 2921634,
+ 996246,
+ 2426799,
+ 2563119,
+ 2737793,
+ 2570768,
+ 2568800,
+ 1100951,
+ 2053452,
+ 2157534,
+ 2001404,
+ 2014733,
+ 2007948,
+ 2061293,
+ 2070669,
+ 1594394,
+ 2586095,
+ 2523008,
+ 2493311,
+ 911477,
+ 2501295,
+ 2496239,
+ 2455007,
+ 2452831,
+ 994487,
+ 1878395,
+ 1974125,
+ 1917948,
+ 995990,
+ 1993308,
+ 1991852,
+ 1951452,
+ 1983692,
+ 2438639,
+ 2651568,
+ 2632944,
+ 1010774,
+ 2723504,
+ 2647184,
+ 2659185,
+ 2647248,
+ 2644976,
+ 1185767,
+ 2145245,
+ 2169725,
+ 2085517,
+ 2185006,
+ 2143261,
+ 2156461,
+ 2156301,
+ 2839602,
+ 2926146,
+ 3089427,
+ 3110051,
+ 2943698,
+ 3102995,
+ 3144595,
+ 3162772,
+ 968790,
+ 1997532,
+ 2252110,
+ 2223101,
+ 1982812,
+ 1969516,
+ 1985836,
+ 1941851,
+ 2494511,
+ 2490783,
+ 2504223,
+ 2435039,
+ 2497808,
+ 2497695,
+ 2467983,
+ 2472544,
+ 1897836,
+ 1897836,
+ 1894555,
+ 1897132,
+ 1801403,
+ 1813099,
+ 1809547,
+ 1826619,
+ 1499289,
+ 2513567,
+ 2442031,
+ 2413775,
+ 2597024,
+ 2302670,
+ 2487759,
+ 2493728,
+ 1894011,
+ 1715994,
+ 1893004,
+ 1904299,
+ 1974508,
+ 1119335,
+ 1921068,
+ 2103613,
+ 2026492,
+ 2598576,
+ 2567184,
+ 2564944,
+ 2572032,
+ 2382783,
+ 2385615,
+ 2312958,
+ 2439855,
+ 1752523,
+ 1977164,
+ 1938076,
+ 1961228,
+ 798181,
+ 1871963,
+ 1843531,
+ 1935132,
+ 1838299,
+ 2224350,
+ 2262413,
+ 2266462,
+ 2300814,
+ 2303790,
+ 2302959,
+ 2301102,
+ 2302830,
+ 1698026,
+ 1699195,
+ 1680602,
+ 2021020,
+ 1865147,
+ 2017389,
+ 2019660,
+ 1995212,
+ 2700433,
+ 2729137,
+ 2698769,
+ 2708177,
+ 2790129,
+ 2712256,
+ 2710048,
+ 2717585,
+ 2096765,
+ 1975740,
+ 2135005,
+ 1129591,
+ 2119309,
+ 2101229,
+ 2188542,
+ 2272814,
+ 2118253,
+ 3007970,
+ 3016354,
+ 2883233,
+ 2779729,
+ 2886770,
+ 2887281,
+ 2886289,
+ 2898081,
+ 2201709,
+ 2172542,
+ 2314206,
+ 2391967,
+ 2307870,
+ 2308686,
+ 2310782,
+ 2314335,
+ 1678203,
+ 2887618,
+ 2858545,
+ 996934,
+ 2468735,
+ 2686784,
+ 2679649,
+ 2678257,
+ 2679233,
+ 986182,
+ 1986396,
+ 1928508,
+ 1629610,
+ 1790939,
+ 1626106,
+ 1790123,
+ 1793643,
+ 2415583,
+ 2470687,
+ 2438703,
+ 1409752,
+ 3028018,
+ 3103667,
+ 3025555,
+ 3028082,
+ 3169283,
+ 1189639,
+ 2539392,
+ 2614032,
+ 2190574,
+ 2205181,
+ 2218846,
+ 2304126,
+ 2235486,
+ 3007651,
+ 3017586,
+ 2982146,
+ 2896225,
+ 2707776,
+ 2876610,
+ 2865025,
+ 2856753,
+ 1774347,
+ 1764683,
+ 1754667,
+ 1698331,
+ 1700203,
+ 1643514,
+ 1734938,
+ 1701179,
+ 2437103,
+ 2435743,
+ 2421583,
+ 2494303,
+ 2496367,
+ 2501120,
+ 2492144,
+ 2493199,
+ 1102679,
+ 1832283,
+ 1973932,
+ 2147517,
+ 2099229,
+ 2000860,
+ 2084028,
+ 2081437,
+ 2579312,
+ 2510672,
+ 2680528,
+ 2567791,
+ 2504175,
+ 2515695,
+ 2508288,
+ 2510751,
+ 1789434,
+ 1881771,
+ 1851531,
+ 1807292,
+ 1798843,
+ 1798603,
+ 1796107,
+ 1789659,
+ 2400927,
+ 2400943,
+ 2400463,
+ 2397502,
+ 2395199,
+ 2395151,
+ 2393742,
+ 2395855,
+ 1798731,
+ 1797051,
+ 1777419,
+ 1782651,
+ 1795067,
+ 1801019,
+ 1782698,
+ 1820076,
+ 2510367,
+ 2500751,
+ 2528895,
+ 2547024,
+ 2600448,
+ 2591103,
+ 2623872,
+ 2769585,
+ 891861,
+ 1996989,
+ 1966012,
+ 1923500,
+ 1919147,
+ 1000102,
+ 1726730,
+ 1880652,
+ 1884828,
+ 1498553,
+ 2355278,
+ 2413743,
+ 2552191,
+ 2466223,
+ 2505152,
+ 2424847,
+ 2509791,
+ 1887772,
+ 1893308,
+ 1897644,
+ 1872396,
+ 1871532,
+ 1905243,
+ 1900955,
+ 1882764,
+ 2619072,
+ 2710145,
+ 2655328,
+ 2655792,
+ 2665792,
+ 2774721,
+ 2781409,
+ 2800097,
+ 1889932,
+ 2082541,
+ 2134813,
+ 2120061,
+ 2090317,
+ 1805515,
+ 1894796,
+ 1809035,
+ 2423087,
+ 2431327,
+ 2369166,
+ 2347822,
+ 2408047,
+ 2565200,
+ 2685009,
+ 2713440,
+ 1981340,
+ 2162653,
+ 2092621,
+ 2093964,
+ 2245085,
+ 1901531,
+ 1901387,
+ 1862795,
+ 2399791,
+ 2307534,
+ 2423391,
+ 2377791,
+ 2407999,
+ 2502160,
+ 2416927,
+ 2621392,
+ 2126541,
+ 2210590,
+ 2109661,
+ 2133805,
+ 2127453,
+ 2017292,
+ 2123565,
+ 2077517,
+ 1731083,
+ 2603424,
+ 2731441,
+ 2709120,
+ 2653200,
+ 2709073,
+ 1259031,
+ 2813537,
+ 2976034,
+ 2379230,
+ 2368206,
+ 2401615,
+ 2361054,
+ 2423487,
+ 2100669,
+ 2193998,
+ 2114269,
+ 2602272,
+ 2608688,
+ 2462383,
+ 2615408,
+ 2595808,
+ 1084327,
+ 2833026,
+ 2783393,
+ 2790881,
+ 2071725,
+ 2180221,
+ 2095325,
+ 2092509,
+ 1997724,
+ 1866075,
+ 1903531,
+ 1975596,
+ 2492687,
+ 2361726,
+ 2505600,
+ 2520527,
+ 2498895,
+ 2610160,
+ 2570896,
+ 2501951,
+ 2006252,
+ 1899099,
+ 2100189,
+ 2001916,
+ 1890268,
+ 1875371,
+ 1850860,
+ 1886540,
+ 2690113,
+ 2696289,
+ 2644784,
+ 2738289,
+ 2708640,
+ 2726225,
+ 2766000,
+ 2754625,
+ 1896252,
+ 1985964,
+ 1925148,
+ 1895883,
+ 1897004,
+ 1790555,
+ 1805084,
+ 1858011,
+ 2395358,
+ 2311294,
+ 2394047,
+ 2396159,
+ 2498783,
+ 2505855,
+ 2507615,
+ 2477119,
+ 1906252,
+ 1906588,
+ 1861867,
+ 1903787,
+ 1905468,
+ 1901404,
+ 1894491,
+ 1887324,
+ 2811026,
+ 2920354,
+ 2996626,
+ 2991539,
+ 3074227,
+ 3071587,
+ 3115555,
+ 3098947,
+ 2081612,
+ 2002572,
+ 1918699,
+ 2163037,
+ 2000524,
+ 2006204,
+ 1937996,
+ 1993629,
+ 2895266,
+ 2899906,
+ 2991491,
+ 2936514,
+ 2902066,
+ 2895826,
+ 2982162,
+ 2964962,
+ 1991228,
+ 2077549,
+ 1980364,
+ 2028412,
+ 1922796,
+ 2017564,
+ 1951148,
+ 1978012,
+ 1487241,
+ 2506240,
+ 2506031,
+ 2508063,
+ 2555840,
+ 996310,
+ 2481055,
+ 2475503,
+ 2481935,
+ 2101420,
+ 2022284,
+ 2078045,
+ 2064828,
+ 2103245,
+ 1892060,
+ 2020189,
+ 2081245,
+ 2703024,
+ 2566352,
+ 2724113,
+ 2846194,
+ 2599888,
+ 2594912,
+ 2687872,
+ 2555903,
+ 1873340,
+ 1777227,
+ 1965260,
+ 1866443,
+ 1897931,
+ 1895404,
+ 1974428,
+ 2071612,
+ 2517007,
+ 2431903,
+ 2394943,
+ 2610480,
+ 2610992,
+ 2574576,
+ 2546000,
+ 2595792,
+ 2296622,
+ 2297390,
+ 2299774,
+ 2303278,
+ 2290974,
+ 2343006,
+ 2320846,
+ 2366590,
+ 3087939,
+ 3174147,
+ 3210612,
+ 3184051,
+ 3122627,
+ 3122211,
+ 3118307,
+ 3121843,
+ 2391055,
+ 2269246,
+ 2386031,
+ 2351038,
+ 2372159,
+ 2320366,
+ 2321486,
+ 2324623,
+ 2799633,
+ 2791025,
+ 2813793,
+ 2807074,
+ 3015362,
+ 3012339,
+ 3014131,
+ 3008130,
+ 2397422,
+ 2492303,
+ 2434335,
+ 2434655,
+ 1305832,
+ 2560432,
+ 2533711,
+ 2530607,
+ 2532015,
+ 2018029,
+ 3269588,
+ 3374901,
+ 3302228,
+ 3316837,
+ 3527013,
+ 3531670,
+ 3542406,
+ 1308616,
+ 2648704,
+ 2886993,
+ 2851330,
+ 2793473,
+ 1194807,
+ 2490080,
+ 2501519,
+ 2491983,
+ 2793937,
+ 2660944,
+ 2863810,
+ 2823809,
+ 899461,
+ 2336958,
+ 2409390,
+ 2592592,
+ 2415215,
+ 2105453,
+ 1953740,
+ 2081901,
+ 2088141,
+ 2203326,
+ 2119565,
+ 2240142,
+ 2167933,
+ 2462879,
+ 2562543,
+ 2516511,
+ 2714161,
+ 2564624,
+ 2705696,
+ 2731729,
+ 2720881,
+ 1908300,
+ 2243630,
+ 2181230,
+ 1902235,
+ 1811819,
+ 1906364,
+ 2090829,
+ 1943900,
+ 2494223,
+ 2474463,
+ 2489311,
+ 2493392,
+ 2463823,
+ 2444478,
+ 2554720,
+ 2463263,
+ 1881163,
+ 1975132,
+ 1969708,
+ 1026935,
+ 2197245,
+ 2139501,
+ 2131358,
+ 2130541,
+ 2130029,
+ 2693537,
+ 2640128,
+ 2603583,
+ 2403774,
+ 2570368,
+ 2581663,
+ 2666704,
+ 2604128,
+ 1907787,
+ 1833675,
+ 1742459,
+ 1900236,
+ 1928908,
+ 1929052,
+ 1903099,
+ 2106589,
+ 1693050,
+ 2737489,
+ 2757937,
+ 2520512,
+ 2701089,
+ 2669104,
+ 2697345,
+ 2686065,
+ 1891228,
+ 1907452,
+ 1909580,
+ 1894187,
+ 1732746,
+ 1996012,
+ 1927148,
+ 1869691,
+ 2655264,
+ 2631920,
+ 2890482,
+ 1004822,
```
The diff is longer than this page shows; the raw diff has all of it.