From 58b8d5b291422a0c12db590eefbad6efe96cc6de Mon Sep 17 00:00:00 2001 From: eunhhu Date: Mon, 5 Oct 2026 09:29:23 +0100 Subject: Design 022: stored lists as arrays with a bucket index fitted to the keys searched, narrow columns, a JIT with registers and loop guards, read ahead; criteria first --- research/experiments/038-past-c/roundtrip.py | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 research/experiments/038-past-c/roundtrip.py (limited to 'research/experiments/038-past-c/roundtrip.py') diff --git a/research/experiments/038-past-c/roundtrip.py b/research/experiments/038-past-c/roundtrip.py new file mode 100644 index 0000000..53bc251 --- /dev/null +++ b/research/experiments/038-past-c/roundtrip.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +"""What HTTP adds to an event (docs/design/022): pure-serve (store in RAM, +cores 0-2) with a module, a write that does almost nothing (POST +/inputs/size of 033's graph.aup) and a read (GET /views/far), each 2,000 +times from one connection; the medians in microseconds. + +roundtrip.py PURE_SERVE MODULE (run the client apart: taskset -c 3)""" +import http.client +import json +import statistics +import subprocess +import sys +import tempfile +import time + +serve, module = sys.argv[1], sys.argv[2] +with tempfile.TemporaryDirectory() as work: + host = subprocess.Popen(['taskset', '-c', '0-2', serve, '--module', module, '--store', work + '/store', '--port', '0'], + stdout=subprocess.PIPE, stderr=subprocess.PIPE) + port = json.loads(host.stdout.readline())['port'] + connection = http.client.HTTPConnection('127.0.0.1', port, timeout=60) + + def request(method, path): + connection.request(method, path, b'', {'Content-Length': '0'}) + answer = connection.getresponse() + answer.read() + assert answer.status == 200, (path, answer.status) + + out = {} + for name, (method, path) in {'write_us': ('POST', '/inputs/size?nodes=100000'), 'read_us': ('GET', '/views/far')}.items(): + took = [] + for _ in range(2000): + began = time.perf_counter() + request(method, path) + took.append((time.perf_counter() - began) * 1e6) + out[name] = round(statistics.median(took), 1) + host.terminate() + host.communicate(timeout=30) + print(json.dumps(out)) -- cgit v1.2.3