batch-groups: decode and give way between the pieces of a prompt read (#2050, opt-in STRATA_PIPED_READ_PIECE), on top of #2326's concurrent read

Squash of SuperDistance's three commits of PR #2050 (decode between the pieces of a read on the pipelined groups, the
piece lines counting the rows the slots decoded meanwhile, the stall watchdog staying on for a read in pieces),
applied after #2326 here: the BYIELD give-way is #2326's give_way lambda, the concurrent block runs first and the
piece path serves a read that STRATA_PIPED_CONCURRENT leaves to it (pictures, configurations where it is off).

Co-authored-by: SuperDistance <43229543+SuperDistance@users.noreply.github.com>
This commit is contained in:
Niko1221andSuperDistance committed 2026-10-14 12:26:10 +02:00
1 parent 073d079d27
commit 5d6bf8d414
4 files changed
+214 -2

No files matched your search

+26
View File
@@ -8,6 +8,9 @@
using strata::program::batch_read_piece;
using strata::program::concurrent_read_off;
using strata::program::ConcurrentReadSetup;
using strata::program::piped_decode_budget_ms;
using strata::program::piped_read_lead_in;
using strata::program::piped_read_piece;
static int fails = 0;
#define CHECK(c) do { if (!(c)) { std::printf("FAIL %s:%d %s\n", __FILE__, __LINE__, #c); ++fails; } } while (0)
@@ -54,6 +57,29 @@ int main() {
for (size_t j = i; j < std::size(each); ++j) s.*each[j] = true;
CHECK(same(concurrent_read_off(s), named[i]));
}
// piped_read_piece (#1906): off -> one run; whole chunks, at least one, at most 32
CHECK(piped_read_piece(0, 8192) == 0);
CHECK(piped_read_piece(-5, 8192) == 0);
CHECK(piped_read_piece(32768, 8192) == 32768);
CHECK(piped_read_piece(20000, 8192) == 16384); // rounded down to whole chunks
CHECK(piped_read_piece(4096, 8192) == 8192); // never below one chunk
CHECK(piped_read_piece(1 << 30, 8192) == 32 * 8192);
CHECK(piped_read_piece(5000, 0) == 32); // chunk 0 guarded as 1 (and the cap applies)
for (int64_t c : {1024, 2048, 6144, 8192})
for (int64_t p : {1, 1000, 9000, 50000, 300000}) CHECK(piped_read_piece(p, c) % c == 0); // the header's rule
// piped_decode_budget_ms: share x piece, capped, floored; negatives are 0
CHECK(piped_decode_budget_ms(2000.0, 2.0, 400.0, 0.0) == 400.0);
CHECK(piped_decode_budget_ms(2000.0, 0.35, 3000.0, 0.0) == 700.0);
CHECK(piped_decode_budget_ms(2000.0, 0.0, 400.0, 150.0) == 150.0);
CHECK(piped_decode_budget_ms(2000.0, 2.0, 0.0, 0.0) == 4000.0); // no cap
CHECK(piped_decode_budget_ms(-5.0, -1.0, 400.0, -3.0) == 0.0);
// piped_read_lead_in: on, beside decoding slots, within 1000 ms + the budget of the previous piecewise read's end
CHECK(piped_read_lead_in(true, true, 0.0, 400.0));
CHECK(piped_read_lead_in(true, true, 1400.0, 400.0));
CHECK(!piped_read_lead_in(true, true, 1401.0, 400.0));
CHECK(!piped_read_lead_in(true, true, -1.0, 400.0));
CHECK(!piped_read_lead_in(false, true, 0.0, 400.0));
CHECK(!piped_read_lead_in(true, false, 0.0, 400.0));
if (fails == 0) std::printf("batch_read_test: ok\n");
return fails == 0 ? 0 : 1;
}