mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
test: expose whole-map checkpoint copy at one TiB
This commit is contained in:
1 parent
468b7a3db2
commit
a8d922942b
2 files changed
+67
No files matched your search
@@ -0,0 +1,56 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// This allocation bound is deliberately loose: one changed leaf and its
|
||||
// bounded-fanout ancestors fit well below it, whereas copying the 1-TiB
|
||||
// entry vector alone costs 6 MiB. It is a copy-cost control, not a CPU or
|
||||
// whole-store stop qualification.
|
||||
func TestChunkMapCheckpointOneChangedPageDoesNotCopyTheWholeMap(t *testing.T) {
|
||||
d := mapDescriptorV3(t)
|
||||
d.VolumeSize = 1 << 40
|
||||
d.MapFormatID = mapFormatIDCoverage
|
||||
const chunkBlocks = 1024
|
||||
m, err := createChunkLSNMapV3(filepath.Join(t.TempDir(), "map"), d, chunkBlocks)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
if err := m.Close(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
})
|
||||
shape, err := mapShapeForV3(d, chunkBlocks)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
empty := &chunkLocalBits{}
|
||||
entries := make([]chunkLSNEntryV3, shape.chunks)
|
||||
for i := range entries {
|
||||
entries[i] = chunkLSNEntryV3{Unknown: true, Local: empty}
|
||||
}
|
||||
prior, err := m.Prepare(1, 0, entries, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
entries[0] = chunkLSNEntryV3{LSN: 1, Unknown: true, Local: empty.mark(0, chunkBlocks)}
|
||||
runtime.GC()
|
||||
var before, after runtime.MemStats
|
||||
runtime.ReadMemStats(&before)
|
||||
next, err := m.Prepare(2, 1, entries, prior)
|
||||
runtime.ReadMemStats(&after)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if prior.entries[0].LSN != 0 || next.entries[0].LSN != 1 {
|
||||
t.Fatal("preparation changed the prior snapshot or lost the changed page")
|
||||
}
|
||||
const allocationBound = 2 << 20
|
||||
if allocated := after.TotalAlloc - before.TotalAlloc; allocated > allocationBound {
|
||||
t.Fatalf("one changed page allocated %d bytes at 1 TiB; bound %d excludes a whole-map copy", allocated, allocationBound)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
# version: page-reuse/1
|
||||
step condition outcome
|
||||
write any time, also between prepare and publish the page's memory version rises; the page is dirty while its memory version exceeds its retired version
|
||||
prepare a page is dirty its content goes to a fresh extent; the candidate captures its memory version
|
||||
prepare a page is clean the candidate reuses the SELECTED slot root's extent for it (never the other slot's)
|
||||
publish succeeded (slot written and synced) retire each captured page at its CAPTURED version only; release the log up to it; a newer memory version stays dirty
|
||||
publish failed cleanly the candidate is kept for retry and keeps its pins; nothing is retired
|
||||
abandon a candidate is dropped nothing is retired; its fresh extents become garbage
|
||||
crash during publish the slot write landed whole or not; the selected root decides; retired versions are rebuilt from it; the log was never released above it
|
||||
retire before publish refused: a page is marked clean only up to a durable root or the candidate that captured it
|
||||
free an extent only if no valid slot root (selected or other) and no kept or uncertain candidate names it
|
||||
|
Reference in new issue
Block a user