From 68dca986ee7ff7d729a15565e2e07127d5b5d1a4 Mon Sep 17 00:00:00 2001 From: eunhhu Date: Wed, 30 Sep 2026 13:52:30 +0100 Subject: Say that prefetching items did not pay, and why (109) Fetching a found item's cells, a leaf's keys and each level's keys ahead made finding and reading items 20% faster on 100,000 items in a micro benchmark, but TPC-C's clean pairs moved 1% at most and finding alone got 48% slower, so it is not in. The owner's finding samples were the descent, not the fields: a write right after a read copies the leaf whole anyway, and what costs is walking structures larger than the caches at random. --- research/experiments/024-finding-items/micro.py | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 research/experiments/024-finding-items/micro.py (limited to 'research/experiments/024-finding-items/micro.py') diff --git a/research/experiments/024-finding-items/micro.py b/research/experiments/024-finding-items/micro.py new file mode 100644 index 0000000..1e80a9e --- /dev/null +++ b/research/experiments/024-finding-items/micro.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +"""bench-seek before and after prefetch.patch, taking turns five times, lists of 100,000 and 400,000 items: +the median ns of each way and the spread (slowest over fastest), and the load average when it began and ended. + + micro.py DIRECTORY (holding bench-before and bench-after)""" +import os +import statistics +import subprocess +import sys +from pathlib import Path + +here = Path(sys.argv[1]) +ways = ['seek', 'seek+3 reads', 'seek+3 reads+3 changes', 'same, a share each 30'] +print('load average at the start:', os.getloadavg()) +for items in (100000, 400000): + runs = {'before': [], 'after': []} + for _ in range(5): + for version in runs: + out = subprocess.run([here / f'bench-{version}', str(items), '1500000'], capture_output=True, text=True, + check=True).stdout.splitlines()[:4] + runs[version].append([float(line.split()[-2]) for line in out]) + for version, measured in runs.items(): + medians = [statistics.median(m[i] for m in measured) for i in range(4)] + spreads = [max(m[i] for m in measured) / min(m[i] for m in measured) for i in range(4)] + print(f'{items:>7} {version:<6} ' + ' '.join(f'{w}: {m:.1f} ns (x{s:.2f})' for w, m, s in zip(ways, medians, spreads))) +print('load average at the end:', os.getloadavg()) -- cgit v1.2.3