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
diff --git a/build.zig.zon b/build.zig.zon
index 4d5d767..8f9ed2f 100644
--- a/build.zig.zon
+++ b/build.zig.zon
@@ -20,7 +20,7 @@
.url = "https://tangled.org/zzstoatzz.io/pg.zig/archive/4b09649.tar.gz",
.hash = "pg-0.0.0-Wp_7gcbvBgDuPhh4lgIFe0-ssEsmW1ixXAYPQnNKWxrL",
},
- .zkv = .{ .path = "../../zzstoatzz.io/zkv-maintenance" },
+ .zkv = .{ .path = "../../zzstoatzz.io/zkv-read-prefix" },
},
.paths = .{
"build.zig",
diff --git a/scripts/zkv/read_cost.py b/scripts/zkv/read_cost.py
index 25fc832..e62d22a 100644
--- a/scripts/zkv/read_cost.py
+++ b/scripts/zkv/read_cost.py
@@ -1,16 +1,28 @@
import csv,hashlib,io,json,subprocess,tempfile,platform,sys
from pathlib import Path
+import re
root=Path(__file__).resolve().parents[2]
out=Path(sys.argv[2]).resolve()
out.mkdir(parents=True,exist_ok=False)
binary=Path(sys.argv[1]).resolve()
meta={'platform':platform.platform(),'binary_sha256':hashlib.sha256(binary.read_bytes()).hexdigest(),'source_revision':subprocess.check_output(['git','rev-parse','HEAD'],cwd=root,text=True).strip(),'source_files':{str(p.relative_to(root)):hashlib.sha256(p.read_bytes()).hexdigest() for p in [root/'build.zig',root/'build.zig.zon',*sorted((root/'src').rglob('*.zig'))]}}
+dependency = re.search(r'\.zkv = \.\{ \.path = "([^"]+)"', (root / 'build.zig.zon').read_text())
+assert dependency is not None
+core = (root / dependency.group(1)).resolve()
+meta['core_revision'] = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=core, text=True).strip()
+meta['core_files'] = {
+ str(p.relative_to(core)): hashlib.sha256(p.read_bytes()).hexdigest()
+ for p in sorted((core / 'src').rglob('*.zig'))
+}
+(out / 'core.diff').write_bytes(subprocess.check_output(['git', 'diff', 'HEAD'], cwd=core))
(out/'source.diff').write_bytes(subprocess.check_output(['git','diff'],cwd=root))
with tempfile.TemporaryDirectory(prefix='zlay-read-cost-') as td:
result=subprocess.run([str(binary),td],check=True,text=True,capture_output=True,timeout=90)
(out/'results.csv').write_text(result.stdout)
(out/'run.log').write_text(result.stderr)
rows=list(csv.DictReader(io.StringIO(result.stdout)))
+for repo, files in ((root, meta['source_files']), (core, meta['core_files'])):
+ assert all(hashlib.sha256((repo / path).read_bytes()).hexdigest() == value for path, value in files.items()), 'source changed during probe'
assert len(rows)==32 and all(r['verified_pairs']=='8448' for r in rows)
(out/'environment.json').write_text(json.dumps(meta,indent=2)+'\n')
import statistics