Skip to content

Commit 00e78d4

Browse files
committed
test(storage): measure the end state against the file store, not the old one
btrfs charges very differently for four hundred small files than for one large one, so comparing what the disk still costs against what the environment used to occupy was a statement about filesystem overhead rather than about the migration. It compares against what the file store actually occupies now. The load-bearing assertion, that retiring hands back most of what the environment held, was passing on btrfs already. The numbers are printed as well as asserted: on this machine the environment held 14.1 MB, the file store holds 6.6 MB, and 14.1 MB came back.
1 parent d098041 commit 00e78d4

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

tests/migration_reclaims_disk.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ async fn retiring_the_legacy_environment_returns_its_bytes_to_the_filesystem() {
263263
// Only the file store's copy should be left.
264264
let left_on_disk = allocated_bytes(&root);
265265
let file_store_blocks = allocated_bytes(&root.join("chunks"));
266+
let recovered = free_at_end.saturating_sub(free_at_peak);
266267
assert!(
267268
left_on_disk <= file_store_blocks + (payload / 10),
268269
"something other than the file store is still using disk: {left_on_disk} total \
@@ -272,19 +273,28 @@ async fn retiring_the_legacy_environment_returns_its_bytes_to_the_filesystem() {
272273
// And the filesystem agrees, measured against the peak rather than against a guess.
273274
// Retiring should hand back most of what the environment was occupying, which makes
274275
// this a statement about the environment's own size rather than about the payload.
275-
let recovered = free_at_end.saturating_sub(free_at_peak);
276276
assert!(
277277
recovered > environment_blocks / 2,
278278
"retiring recovered {recovered} bytes of an environment occupying \
279279
{environment_blocks}"
280280
);
281281

282-
// And what is left costs roughly one copy rather than two.
282+
// And what is left costs roughly one copy rather than two, measured against what the
283+
// file store actually occupies rather than against what the environment did. The two
284+
// are not interchangeable: how much a filesystem spends on four hundred small files
285+
// against one large one is its own business, and btrfs in particular charges very
286+
// differently for the two. Printed as well as asserted, so a number that is drifting
287+
// shows up in the log before it trips anything.
283288
let consumed = free_at_start.saturating_sub(free_at_end);
289+
println!(
290+
"reclaim: environment {environment_blocks} bytes, file store {file_store_blocks}, \
291+
peak cost {}, end cost {consumed}, recovered {recovered}",
292+
free_at_start.saturating_sub(free_at_peak)
293+
);
284294
assert!(
285-
consumed < environment_blocks,
286-
"the filesystem is still down {consumed} bytes against an environment of \
287-
{environment_blocks}, so its space did not come back"
295+
consumed < file_store_blocks + environment_blocks / 2,
296+
"the filesystem is still down {consumed} bytes with only {file_store_blocks} of \
297+
file store to account for it, so the environment's space did not come back"
288298
);
289299

290300
// Every chunk is still served, read back through a store opened from scratch, which

0 commit comments

Comments
 (0)