diff options
| author | eunhhu <[email protected]> | 2026-09-30 13:52:30 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-30 13:52:30 +0100 |
| commit | 68dca986ee7ff7d729a15565e2e07127d5b5d1a4 (patch) | |
| tree | 89e50c693af9594c26320c56e37ee7f0f9b95d6a /research/experiments/024-finding-items/micro.py | |
| parent | dacc3cf3e1e7fe6554575cefdb4ac6d7a19a61c6 (diff) | |
| download | pure-68dca986ee7ff7d729a15565e2e07127d5b5d1a4.tar.gz pure-68dca986ee7ff7d729a15565e2e07127d5b5d1a4.zip | |
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.
Diffstat (limited to 'research/experiments/024-finding-items/micro.py')
| -rw-r--r-- | research/experiments/024-finding-items/micro.py | 26 |
1 files changed, 26 insertions, 0 deletions
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()) |
