Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//! IT READ ZERO FOR TWO REASONS, AND ONLY ONE OF THEM WAS THE EXPECTED ONE.
//!
//! First, the reading is in the OPEN, not in the load. `restore_large_scale.rs` builds the engine
//! -- and with it the block store -- and only then takes `pages_before` and opens the span it
//! -- and with it the block store -- and only then takes `blocks_before` and opens the span it
//! measures. Every byte this store reads on a cold start has already been read by the time that
//! span begins, so the row it prints is a zero taken after the fact.
//!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ fn seed_strings(engine: &TemporalEngine, count: usize) {
/// multiplying the record count by a number somebody remembered.
struct AddressCount {
buckets: usize,
page_entries: usize,
block_entries: usize,
model_map: usize,
blocks_per_bucket: Vec<usize>,
}

impl AddressCount {
fn total(&self) -> usize {
self.page_entries + self.model_map
self.block_entries + self.model_map
}
}

Expand All @@ -123,7 +123,7 @@ fn count_addresses(shard: &crate::engine::state::ShardState) -> AddressCount {
.collect();
AddressCount {
buckets: shard.bucket_index.bucket_map.len(),
page_entries: blocks_per_bucket.iter().sum(),
block_entries: blocks_per_bucket.iter().sum(),
model_map: shard.strings().len(),
blocks_per_bucket,
}
Expand Down Expand Up @@ -210,15 +210,15 @@ fn what_a_block_address_costs_per_record_at_two_ranges_and_two_corpus_sizes() {
"denominator: no routing buckets, so every per-bucket figure is meaningless"
);
assert!(
addresses.page_entries > 0,
addresses.block_entries > 0,
"denominator: no page-index entries, so there are no addresses to measure"
);

println!("\n--- {range_label}, {records} records ---");
println!(
" buckets={} page entries={} model-map addresses={} addresses total={}",
addresses.buckets,
addresses.page_entries,
addresses.block_entries,
addresses.model_map,
addresses.total()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,9 @@ fn what_a_mark_in_place_delete_would_retain_at_two_corpus_sizes_and_two_delete_r
assert_eq!(acked, arm.records, "DENOMINATOR: the seed did not ack every record");

let before = blocks_by_bucket(&engine);
let pages_before: usize = before.values().sum();
let blocks_before: usize = before.values().sum();
assert!(
pages_before > 0,
blocks_before > 0,
"DENOMINATOR [{}]: the seed filed no page at all, so nothing could be retained",
arm.label
);
Expand All @@ -336,7 +336,7 @@ fn what_a_mark_in_place_delete_would_retain_at_two_corpus_sizes_and_two_delete_r

let after = blocks_by_bucket(&engine);
let tombs = tombstones_by_bucket(&engine);
let pages_after: usize = after.values().sum();
let blocks_after: usize = after.values().sum();
let tombs_total: usize = tombs.values().sum();

// The entries a mark-in-place delete would have KEPT: the pages each bucket lost.
Expand Down Expand Up @@ -385,7 +385,7 @@ fn what_a_mark_in_place_delete_would_retain_at_two_corpus_sizes_and_two_delete_r
println!("=== {}", arm.label);
println!(
" records acked {acked} keys deleted {deleted} buckets {n_buckets} \
pages {pages_before} -> {pages_after} tombstoned ids {tombs_total}"
pages {blocks_before} -> {blocks_after} tombstoned ids {tombs_total}"
);
println!(
" retained entries would be {retained_total} over {n_buckets} buckets; \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,14 @@ fn a_compaction_round_folds_a_containers_blocks_and_folds_its_entry_count_with_t
);

let mut kinds_folded = 0usize;
for (kind, pages_before, entries_before) in &before {
let (pages_after, entries_after) = addresses_and_entries(&engine, kind, "folded");
for (kind, blocks_before, entries_before) in &before {
let (blocks_after, entries_after) = addresses_and_entries(&engine, kind, "folded");
println!(
" {kind:>6} {pages_before:>12} {pages_after:>11} {entries_before:>13} {entries_after:>12}"
" {kind:>6} {blocks_before:>12} {blocks_after:>11} {entries_before:>13} {entries_after:>12}"
);
assert!(
pages_after < *pages_before,
"{kind} holds {pages_after} pages where it held {pages_before}, so nothing folded"
blocks_after < *blocks_before,
"{kind} holds {blocks_after} pages where it held {blocks_before}, so nothing folded"
);
// THE ENTRY COUNT FOLDS WITH THE PAGES, AND THAT IS THE ROW THIS ARM EXISTS TO HOLD. It
// asserted `entries_after == entries_before` for as long as an entry named its element:
Expand All @@ -338,12 +338,12 @@ fn a_compaction_round_folds_a_containers_blocks_and_folds_its_entry_count_with_t
//
// WHAT THIS IS WORTH, STATED EXACTLY, BECAUSE IT IS LESS THAN IT LOOKS. On this tree the
// page fold and the entry fold are the SAME EVENT: there is no field left that could keep
// two entries over one folded page, so `pages_after < pages_before` above and the
// two entries over one folded page, so `blocks_after < blocks_before` above and the
// assertion below cannot part company. It is kept as a TRIPWIRE on the claim that
// inverted -- it FAILS on the engine this arm was written against, where the page column
// fell and the entry column did not -- and not as an independent guard.
//
// `entries_after == pages_after` WAS WRITTEN HERE AND THEN DELETED AS VACUOUS, which is
// `entries_after == blocks_after` WAS WRITTEN HERE AND THEN DELETED AS VACUOUS, which is
// recorded because it reads like the stronger assertion. `addresses_and_entries` derives
// its PAGE column by deduplicating the very entries it counts for the ENTRY column, so the
// two columns are one measurement and nothing independent could make them disagree.
Expand All @@ -360,7 +360,7 @@ fn a_compaction_round_folds_a_containers_blocks_and_folds_its_entry_count_with_t
assert!(
entries_after < *entries_before,
"{kind} holds {entries_after} entries where it held {entries_before}; a round that \
folded {pages_before} pages into {pages_after} left the entry count alone, which is \
folded {blocks_before} pages into {blocks_after} left the entry count alone, which is \
what an entry that names its element does"
);
kinds_folded += 1;
Expand Down Expand Up @@ -665,45 +665,45 @@ fn the_element_cap_binds_so_one_block_never_holds_a_whole_large_container() {
},
);
}
let (pages_before, entries_before) = addresses_and_entries(&engine, "hash", "capped");
assert_eq!(OVER_CAP_ELEMENTS, pages_before);
let (blocks_before, entries_before) = addresses_and_entries(&engine, "hash", "capped");
assert_eq!(OVER_CAP_ELEMENTS, blocks_before);
assert_eq!(OVER_CAP_ELEMENTS, entries_before);

crate::engine::reset_container_batch_counts();
engine
.compact_shard_blocks(1)
.expect("the round must succeed");
let (batches, folded) = crate::engine::container_batch_counts();
let (pages_after, entries_after) = addresses_and_entries(&engine, "hash", "capped");
let (blocks_after, entries_after) = addresses_and_entries(&engine, "hash", "capped");

let cap = crate::engine::CONTAINER_BATCH_ELEMENT_CAP;
println!(
"\n=== the element cap ===\n cap {cap}, elements {OVER_CAP_ELEMENTS}: {pages_before} pages -> {pages_after}, {batches} batches, {folded} folded"
"\n=== the element cap ===\n cap {cap}, elements {OVER_CAP_ELEMENTS}: {blocks_before} pages -> {blocks_after}, {batches} batches, {folded} folded"
);
assert!(
batches > 0 && folded > 0,
"nothing folded, so the cap was not exercised"
);
assert!(
pages_after > 1,
"{OVER_CAP_ELEMENTS} elements folded into {pages_after} page(s) against a cap of {cap}, so \
blocks_after > 1,
"{OVER_CAP_ELEMENTS} elements folded into {blocks_after} page(s) against a cap of {cap}, so \
the cap did not bind and one page holds the whole container"
);
let smallest_possible = (OVER_CAP_ELEMENTS + cap - 1) / cap;
assert!(
pages_after >= smallest_possible,
"{OVER_CAP_ELEMENTS} elements cannot fit in {pages_after} pages of at most {cap}"
blocks_after >= smallest_possible,
"{OVER_CAP_ELEMENTS} elements cannot fit in {blocks_after} pages of at most {cap}"
);
// THE ENTRY COUNT IS THE PAGE COUNT NOW, WHICH IS THE COLLAPSE AND NOT A DRIFT.
//
// This asserted `entries_after == OVER_CAP_ELEMENTS` under "the entry count must not move": one
// entry per element, whatever the pages did. Every container kind is page-named, so the index
// files one entry per distinct PAGE and the count is the page count. Asserted against
// `pages_after` rather than re-goldened to a literal, so the claim is still a relation between
// `blocks_after` rather than re-goldened to a literal, so the claim is still a relation between
// two measured things and a count that drifted from the pages would still fail.
assert_eq!(
pages_after, entries_after,
"the index filed {entries_after} entries over {pages_after} page(s). One entry a page is \
blocks_after, entries_after,
"the index filed {entries_after} entries over {blocks_after} page(s). One entry a page is \
what the collapse means: more entries than pages is a stale entry over a dead page, and \
fewer means a page nothing names"
);
Expand Down
16 changes: 8 additions & 8 deletions crates/temporalstore-rust/src/engine/tests/evict_scale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1930,7 +1930,7 @@ fn releasing_a_mixed_batch_releases_exactly_the_clean_buckets_and_leaves_the_res
(released, dirty, blocks, objects)
};

let pages_before = live_blocks_by_key(&engine);
let live_blocks_before = live_blocks_by_key(&engine);

crate::engine::reset_model_map_addresses_visited();
crate::engine::reset_bucket_release_model_derivations();
Expand All @@ -1940,7 +1940,7 @@ fn releasing_a_mixed_batch_releases_exactly_the_clean_buckets_and_leaves_the_res
release_bucket_blocks(shard, &candidates)
};
let derivations = crate::engine::bucket_release_model_derivations();
let pages_after = live_blocks_by_key(&engine);
let live_blocks_after = live_blocks_by_key(&engine);

println!(
" mixed batch: {} candidates, oracle says release {:?} and refuse {} on dirt; the \
Expand Down Expand Up @@ -2049,14 +2049,14 @@ fn releasing_a_mixed_batch_releases_exactly_the_clean_buckets_and_leaves_the_res
}

assert_eq!(
pages_after.len(),
pages_before.len(),
live_blocks_after.len(),
live_blocks_before.len(),
"the shard held {} distinct live keys before the release and {} after",
pages_before.len(),
pages_after.len()
live_blocks_before.len(),
live_blocks_after.len()
);
for (key, before) in &pages_before {
let after = pages_after.get(key).copied().unwrap_or_default();
for (key, before) in &live_blocks_before {
let after = live_blocks_after.get(key).copied().unwrap_or_default();
assert_eq!(
after, *before,
"key {key} had {before} live pages before the release and {after} after"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ struct Recovery {
wal_reads: u64,
index_log_read_bytes: u64,
index_log_reads: u64,
page_read_bytes: u64,
block_read_bytes: u64,
page_reads: u64,
/// The two stores' OWN `bytes_read`, which counts what a scan handed back rather than what it
/// read off disk. Printed beside the physical counters so the difference stays visible; never
Expand Down Expand Up @@ -469,7 +469,7 @@ impl Recovery {
+ self.manifest_bytes_read
+ self.wal_read_bytes
+ self.index_log_read_bytes
+ self.page_read_bytes
+ self.block_read_bytes
}

/// THE SUBJECT: the kernel's total less the rows above.
Expand Down Expand Up @@ -601,7 +601,7 @@ fn recover(
let (wal_before, wal_reads_before) = crate::wal::wal_piece_read_counts_on_this_thread();
let (index_before, index_reads_before) =
crate::index_log::index_log_piece_read_counts_on_this_thread();
let pages_before = engine.block_store().stats();
let blocks_before = engine.block_store().stats();
let started = std::time::Instant::now();

let (response, kernel_rchar) = kernel_read_span(|| {
Expand Down Expand Up @@ -629,7 +629,7 @@ fn recover(
let (index_after, index_reads_after) =
crate::index_log::index_log_piece_read_counts_on_this_thread();
// BEFORE the readback below, which would charge its own page reads to the recovery.
let pages_after = engine.block_store().stats();
let blocks_after = engine.block_store().stats();
let manifest = crate::engine::bucket_dump_manifest_io_counts();
// `stats`, not `raw_stats`: the cached `last_sequence` is set by an APPEND, and a store
// that only replayed never appended, so `raw_stats` answered 0 here for every arm and the
Expand Down Expand Up @@ -694,10 +694,10 @@ fn recover(
wal_reads: wal_reads_after - wal_reads_before,
index_log_read_bytes: index_after - index_before,
index_log_reads: index_reads_after - index_reads_before,
page_read_bytes: pages_after
block_read_bytes: blocks_after
.bytes_read
.saturating_sub(pages_before.bytes_read),
page_reads: pages_after.reads.saturating_sub(pages_before.reads),
.saturating_sub(blocks_before.bytes_read),
page_reads: blocks_after.reads.saturating_sub(blocks_before.reads),
wal_handed_back: wal_stats.bytes_read,
index_log_handed_back: index_stats.bytes_read,
kernel_rchar,
Expand Down Expand Up @@ -800,7 +800,7 @@ fn show_recovery(reading: &Recovery) {
reading.replay_scans,
reading.index_log_read_bytes,
reading.index_log_reads,
reading.page_read_bytes,
reading.block_read_bytes,
reading.page_reads,
reading.named(),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ fn restore(dir: &std::path::Path, corpus: Corpus) -> Restart {
);
crate::engine::reset_bucket_dump_manifest_io_counts();
let index_log_before = engine.index_log_store().stats(1);
let pages_before = engine.block_store().stats();
let blocks_before = engine.block_store().stats();
reset_promote_model_map_check_counts();
reset_peak_rss();
let rss_before_kb = vm_status_kb("VmRSS").unwrap_or(0);
Expand Down Expand Up @@ -624,7 +624,7 @@ fn restore(dir: &std::path::Path, corpus: Corpus) -> Restart {
let wal = engine.write_ahead_log_store().raw_stats(1);
let index_log_after = engine.index_log_store().stats(1);
// BEFORE the probe reads below, which would charge their own page reads to the restore.
let pages_after = engine.block_store().stats();
let blocks_after = engine.block_store().stats();
let (promote_checks, promote_rebuilds, promote_blocks) = promote_model_map_check_counts();
let mut readable = 0usize;
let mut probe = 0usize;
Expand Down Expand Up @@ -656,10 +656,10 @@ fn restore(dir: &std::path::Path, corpus: Corpus) -> Restart {
.bytes_read
.saturating_sub(index_log_before.bytes_read),
index_log_reads: index_log_after.reads.saturating_sub(index_log_before.reads),
block_bytes_read: pages_after
block_bytes_read: blocks_after
.bytes_read
.saturating_sub(pages_before.bytes_read),
page_reads: pages_after.reads.saturating_sub(pages_before.reads),
.saturating_sub(blocks_before.bytes_read),
page_reads: blocks_after.reads.saturating_sub(blocks_before.reads),
promote_checks,
promote_rebuilds,
promote_blocks,
Expand Down
14 changes: 7 additions & 7 deletions crates/temporalstore-rust/src/engine/tests/round_walk_scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,9 +677,9 @@ fn the_two_ranges_still_place_a_block_differently_and_the_summary_walk_follows_t
let shard = shards.get_mut(&1).expect("shard 1");
let _released = assert_no_released_bucket_is_dirty(shard);

let pages_before = collect_live_block_entries(shard).len();
let blocks_before = collect_live_block_entries(shard).len();
assert!(
pages_before > 0,
blocks_before > 0,
"{label}: the fixture stored no page, so there is nothing to file anywhere"
);

Expand All @@ -702,8 +702,8 @@ fn the_two_ranges_still_place_a_block_differently_and_the_summary_walk_follows_t
let entries = collect_live_block_entries(shard);
assert_eq!(
entries.len(),
pages_before,
"{label}: the reconstruct changed the page count ({pages_before} -> {}), so the two \
blocks_before,
"{label}: the reconstruct changed the page count ({blocks_before} -> {}), so the two \
arms are not comparing the same store",
entries.len()
);
Expand Down Expand Up @@ -1084,7 +1084,7 @@ fn a_round_immediately_after_a_restart_would_see_no_buckets_at_all() {
const RECORDS: usize = 1_200;

let dir = tempfile::tempdir().expect("tempdir");
let (buckets_before, pages_before) = {
let (buckets_before, blocks_before) = {
let engine = engine_on(dir.path());
load_on_range(&engine, NARROW_END_BUCKET);
seed(&engine, 0, RECORDS);
Expand All @@ -1101,9 +1101,9 @@ fn a_round_immediately_after_a_restart_would_see_no_buckets_at_all() {
(full.len(), full.values().sum::<u64>())
};
assert!(
buckets_before > 0 && pages_before > 0,
buckets_before > 0 && blocks_before > 0,
"the fixture stored nothing before the restart ({buckets_before} buckets, \
{pages_before} pages)"
{blocks_before} pages)"
);

// The restart: a new engine over the same directories, loaded on the same range.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,10 @@ fn the_set_listing_takes_its_identity_from_the_entries_and_not_from_the_payload(

// ONE ENTRY A PAGE IS THE PREMISE, so it is asserted rather than assumed. If a set ever went
// back to an entry per element this reads MEMBERS and the whole-page reasoning stops applying.
let (pages_before, live_before, _) = block_and_entry_counts(&engine, "listing/one-name-gone");
let (blocks_before, live_before, _) = block_and_entry_counts(&engine, "listing/one-name-gone");
assert_eq!(
1, live_before,
"the folded object holds {live_before} live entr(ies) over {pages_before} page(s). One \
"the folded object holds {live_before} live entr(ies) over {blocks_before} page(s). One \
entry a page is what makes a whole-page un-naming the only one available, and this arm \
is built on it"
);
Expand All @@ -454,9 +454,9 @@ fn the_set_listing_takes_its_identity_from_the_entries_and_not_from_the_payload(
// control below has to read these addresses straight off the block store.
let addresses = live_block_addresses(&engine, "listing/one-name-gone");
assert_eq!(
pages_before,
blocks_before,
addresses.len(),
"captured {} address(es) for {pages_before} live page(s)",
"captured {} address(es) for {blocks_before} live page(s)",
addresses.len()
);

Expand Down
Loading
Loading