1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//! A segment abandoned with live LARGE blocks, whose blocks are then freed
//! from another thread, must be fully reusable once adopted.
//!
//! `docs/plans/huge-free-retention.md`, mechanism 1: a model loaded on one
//! thread, which then exited, and dropped on another kept ~0.6 of the model's
//! size resident and unreusable, whatever `purge_delay` said. Adoption retired
//! ONE dead large span per segment and left the rest to "later collects", but
//! a large span is never queued, so no collect ever reached it again.
//!
//! Own test binary: it reasons about which segments exist process-wide, and a
//! parallel test abandoning or adopting segments would muddy that.
use ;
use USABLE_SLICES;
use SEGMENT_SLICE_SIZE;
use thread;
/// A large (single-block) span at EVERY geometry: two slices is past
/// `MEDIUM_OBJ_SIZE_MAX` everywhere this crate builds (`tests/spans.rs`). A
/// literal 2.5 MB was a large span at the shipped 32 MiB segment and a HUGE
/// block, one segment each, under `ra_small_profile` and `ra_segment_size =
/// "256k"`, where this test then failed for a reason unrelated to its subject.
const SIZE: usize = 2 * SEGMENT_SLICE_SIZE;
/// Enough to FILL one segment (255 at the shipped geometry, 3 at the small
/// profile), like a model's weight matrices. Filling it is what makes the test
/// bite: with room left at the bump frontier, a reload fits even when the
/// adoption retired only one dead span, and the old behaviour would pass.
const N: usize = USABLE_SLICES / 2;
// Not under Miri: the test needs a thread's EXIT to abandon its segments, and
// Miri runs against the mock prim, whose thread-exit (TLS destructor) hooks
// never fire (`prim/mock.rs`: "TLS destructors do not fire"). There the
// loader's segments are never abandoned, nothing adopts them, and the premise
// never occurs; Miri reported an assertion, not undefined behaviour.