feat(db2-keys): GB-scale bench modes, unmeasured
- hreadall/hreadkeys: the same resident A/B as wread_*, but ~2 KB per row so a GB of data is reachable in a few hundred thousand inserts - the insert path is fsync-bound at roughly 2 000 rows/s, so row COUNT is the expensive axis and row SIZE is nearly free — 20k rows already produce 38 MB - NOT RUN: the GB-scale measurement was called off. These modes are committed working and typechecking so the leg can be run later without rebuilding it, not because a result exists Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> (cherry picked from commit abc276ac39dd45a1052b6ae24d25aedb9eea3e1e)
This commit is contained in:
parent
882c1f7d24
commit
6fc5b4b7d4
1 changed files with 78 additions and 0 deletions
|
|
@ -659,6 +659,76 @@ fn replayseed_mode(n: Int, m: Int) -> Int {
|
|||
-- but with Text columns, which is the only shape where dropping a payload
|
||||
-- frees anything: an Int's value is its inline slot word, a Text's is a
|
||||
-- separate allocation.
|
||||
-- databasev2 2 task 7, the GB-scale leg. Same A/B as wread_*, but each row
|
||||
-- carries ~2 KB of Text so a realistic data volume is reachable in a few
|
||||
-- hundred thousand inserts rather than millions — the insert path is
|
||||
-- fsync-bound at roughly 2 000 rows/s, so row COUNT is the expensive axis and
|
||||
-- row SIZE is nearly free.
|
||||
--
|
||||
-- This is the shape the mode actually claims: data far larger than the cap,
|
||||
-- with only the id map, the indexes and the (never-released) slabs resident.
|
||||
fn heavy_pad() -> Text {
|
||||
let p = "0123456789abcdef0123456789abcdef";
|
||||
let out = "";
|
||||
let i = 0;
|
||||
while i < 20 { out = out .. p; i = i + 1; }
|
||||
return out;
|
||||
}
|
||||
|
||||
fn hread_all(n: Int, r: Int) -> Int {
|
||||
let pad = heavy_pad();
|
||||
let i = 1;
|
||||
while i <= n {
|
||||
insert WideA { k: i, a: "a${i}${pad}", b: "b${i}${pad}", note: "n${i}${pad}" };
|
||||
i = i + 1;
|
||||
}
|
||||
print("hreadfilled ${n} ${self_rss_kb()}");
|
||||
let h: map<Int, Int> = {};
|
||||
let hits = 0;
|
||||
let t0 = time.ticks();
|
||||
let j = 0;
|
||||
while j < r {
|
||||
let key = 1 + (j * 2654435761) % n;
|
||||
let o0 = time.ticks();
|
||||
for row in from x in WideA where x.k == key take 1 select x {
|
||||
if len(row.a) > 0 { hits = hits + 1; }
|
||||
}
|
||||
hist_add(h, time.ticks() - o0);
|
||||
j = j + 1;
|
||||
}
|
||||
let el = time.ticks() - t0;
|
||||
report("hreadall", r, el, h);
|
||||
print("hreadallrss ${self_rss_kb()} ${hits}");
|
||||
return 0;
|
||||
}
|
||||
|
||||
fn hread_keys(n: Int, r: Int) -> Int {
|
||||
let pad = heavy_pad();
|
||||
let i = 1;
|
||||
while i <= n {
|
||||
insert WideK { k: i, a: "a${i}${pad}", b: "b${i}${pad}", note: "n${i}${pad}" };
|
||||
i = i + 1;
|
||||
}
|
||||
print("hreadfilled ${n} ${self_rss_kb()}");
|
||||
let h: map<Int, Int> = {};
|
||||
let hits = 0;
|
||||
let t0 = time.ticks();
|
||||
let j = 0;
|
||||
while j < r {
|
||||
let key = 1 + (j * 2654435761) % n;
|
||||
let o0 = time.ticks();
|
||||
for row in from x in WideK where x.k == key take 1 select x {
|
||||
if len(row.a) > 0 { hits = hits + 1; }
|
||||
}
|
||||
hist_add(h, time.ticks() - o0);
|
||||
j = j + 1;
|
||||
}
|
||||
let el = time.ticks() - t0;
|
||||
report("hreadkeys", r, el, h);
|
||||
print("hreadkeysrss ${self_rss_kb()} ${hits}");
|
||||
return 0;
|
||||
}
|
||||
|
||||
fn wread_all(n: Int, r: Int) -> Int {
|
||||
let pad = "0123456789abcdef0123456789abcdef";
|
||||
let i = 1;
|
||||
|
|
@ -938,6 +1008,14 @@ fn main(args: multi Text) -> Int {
|
|||
}
|
||||
return replayseed_mode(n, mm);
|
||||
}
|
||||
if args[0] == "hreadall" or args[0] == "hreadkeys" {
|
||||
if len(args) < 3 { print_err("usage: hreadall|hreadkeys N R"); return 2; }
|
||||
let hn = parse_int(args[1]);
|
||||
let hr = parse_int(args[2]);
|
||||
if hn == nil or hr == nil { print_err("db-bench: N and R must be positive"); return 2; }
|
||||
if args[0] == "hreadall" { return hread_all(hn, hr); }
|
||||
return hread_keys(hn, hr);
|
||||
}
|
||||
if args[0] == "wreadall" or args[0] == "wreadkeys" {
|
||||
if len(args) < 3 { print_err("usage: wreadall|wreadkeys N R"); return 2; }
|
||||
let wn = parse_int(args[1]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue