#577: the file tier's unbuffered choice (true = the file cache keeps its reads, so they stay buffered)
| 18 | |
| 19 | // #577: the file tier's unbuffered choice (true = the file cache keeps its reads, so they stay buffered) |
| 20 | int file_cache_keeps_cases() { |
| 21 | using strata::platform::file_cache_keeps; |
| 22 | struct Case { const char* what; double avail, arena, read; bool keeps; }; |
| 23 | const double experts = 71.7; // UD-Q4_K_XL's routed experts |
| 24 | const Case cases[] = { |
| 25 | // the reporter's 96 GB PC (83.0 GiB available at start): 0.1.38 passed the budget asked for and every |
| 26 | // shard's bytes (103.7 GiB) and went unbuffered |
| 27 | {"96 GB, 0.1.38's inputs (budget 72, all shards)", 83.0, 72.0, 103.7, false}, |
| 28 | {"96 GB, budget 72, before the copy (arena = all experts)", 83.0, experts, 0.0, true}, |
| 29 | {"96 GB, budget 72, copy built (48.94 resident)", 83.0 - 48.94, 0.0, experts - 48.94, true}, |
| 30 | {"96 GB, budget 40, before the copy", 83.0, 40.0, experts - 40.0, true}, |
| 31 | {"96 GB, budget 40, copy built", 83.0 - 40.0, 0.0, experts - 40.0, true}, |
| 32 | // #357/#362's low-RAM PCs stay unbuffered |
| 33 | {"64 GB, budget 40, before the copy", 55.0, 40.0, experts - 40.0, false}, |
| 34 | {"64 GB, budget 40, copy built", 15.0, 0.0, experts - 40.0, false}, |
| 35 | {"32 GB, budget 16, before the copy", 26.0, 16.0, experts - 16.0, false}, |
| 36 | {"32 GB, budget 16, copy built", 10.0, 0.0, experts - 16.0, false}, |
| 37 | {"32 GB, Q2_0 pack (34 GiB experts), budget 8", 26.0, 8.0, 34.0 - 8.0, false}, |
| 38 | {"nothing available", 0.0, 0.0, 1.0, false}, |
| 39 | {"arena larger than the RAM", 10.0, 20.0, 0.0, true}, |
| 40 | }; |
| 41 | int fail = 0; |
| 42 | for (const Case& c : cases) { |
| 43 | const bool got = file_cache_keeps(gib(c.avail), gib(c.arena), gib(c.read)); |
| 44 | std::printf("file_cache_keeps %-58s -> %s%s\n", c.what, got ? "buffered" : "unbuffered", |
| 45 | got == c.keeps ? "" : " <-- WRONG"); |
| 46 | fail |= got != c.keeps; |
| 47 | } |
| 48 | // #1194, the Linux file tier: a skewed read set, so a twentieth of it (at least 1.5 GiB) is room enough |
| 49 | const Case linux_cases[] = { |
| 50 | {"#1194: 31 GB + 12 GB GPU, budget 18 built (6.4 avail, 13.6 read)", 6.4, 0.0, 13.6, true}, |
| 51 | {"#1194: before the copy (avail 25, arena 18, read 13.6)", 25.0, 18.0, 13.6, true}, |
| 52 | {"32 GB cgroup, budget 18, copy built (12.1 avail, 22 read)", 12.1, 0.0, 22.0, true}, |
| 53 | {"32 GB cgroup, budget 24, copy built (3.8 avail, 16 read)", 3.8, 0.0, 16.0, true}, |
| 54 | {"20 GB cgroup, budget 12, copy built (4.7 avail, 28 read)", 4.7, 0.0, 28.0, true}, |
| 55 | {"12 GB cgroup, budget 6, copy built (3.5 avail, 34 read)", 3.5, 0.0, 34.0, true}, |
| 56 | {"no room beside the margin (1 avail, 47 read)", 1.0, 0.0, 47.0, false}, |
| 57 | {"room under the 1.5 GiB floor (2.4 avail, 47 read)", 2.4, 0.0, 47.0, false}, |
| 58 | {"room a twentieth of the reads (3.4 avail, 47 read)", 3.4, 0.0, 47.0, true}, |
| 59 | {"room just under that (3.3 avail, 47 read)", 3.3, 0.0, 47.0, false}, |
| 60 | {"a big read set needs its twentieth (4 avail, 200 read)", 4.0, 0.0, 200.0, false}, |
| 61 | {"a big read set with that room (12 avail, 200 read)", 12.0, 0.0, 200.0, true}, |
| 62 | {"read less than the floor (2.5 avail, 1 read)", 2.5, 0.0, 1.0, true}, |
| 63 | {"nothing available", 0.0, 0.0, 1.0, false}, |
| 64 | {"arena larger than the RAM", 10.0, 20.0, 5.0, false}, |
| 65 | }; |
| 66 | for (const Case& c : linux_cases) { |
| 67 | const bool got = file_cache_keeps(gib(c.avail), gib(c.arena), gib(c.read), 1ull << 30, 0.05, 3ull << 29); |
| 68 | std::printf("file_cache_keeps (Linux file tier) %-52s -> %s%s\n", c.what, got ? "buffered" : "unbuffered", |
| 69 | got == c.keeps ? "" : " <-- WRONG"); |
| 70 | fail |= got != c.keeps; |
| 71 | } |
| 72 | return fail; |
| 73 | } |
| 74 | } // namespace |
| 75 | |
| 76 | // #3237: the drive probe's decision |
no test coverage detected