Lab3: fair track-1 database reset, WAL metrics, rolling and clean-clone tooling

This commit is contained in:
Ivan Melnikov
2026-12-02 19:03:24 +03:00
parent c19d092b63
commit 922a38b2cf
10 changed files with 870 additions and 238 deletions
+14 -7
View File
@@ -41,6 +41,7 @@ BASELINE_IMAGE = 'mtusi-messenger-lab3-melnikov:track-baseline'
DURATION = 20
WARMUP = 5
CONCURRENCY = 32
TRACK_DB = 'messenger_track'
def now():
@@ -68,17 +69,21 @@ def config(replicas, cpu_per, mem_per, cpu_total, mem_total, image, label):
def run_one(label, cfg, revision, raw_dir, run_dir):
# Every configuration starts from the same freshly migrated database. The
# track database is separate from the stand's main DB and is dropped at the
# end, so the comparison is not biased by 20 minutes of accumulated data.
M.set_stack_profile(cfg['image'], revision, cfg['replicas'], cfg['api_cpu_per_replica'],
cfg['api_mem_per_replica'], cfg['gomemlimit'])
cfg['api_mem_per_replica'], cfg['gomemlimit'],
database=TRACK_DB, reset_database_first=True)
time.sleep(2) # let HAProxy's resolver drop a removed backend
before = M.snapshot()
before = M.snapshot(database=TRACK_DB)
activity_samples = []
sampler_stop = threading.Event()
def sample_activity():
while not sampler_stop.is_set():
try:
activity_samples.append(M.db_activity_sample())
activity_samples.append(M.db_activity_sample(database=TRACK_DB))
except Exception:
pass
sampler_stop.wait(0.5)
@@ -96,7 +101,7 @@ def run_one(label, cfg, revision, raw_dir, run_dir):
wall_end_utc = M.iso()
sampler_stop.set()
sampler.join(timeout=5)
after = M.snapshot()
after = M.snapshot(database=TRACK_DB)
elapsed = wall_end - wall_start
record = M.summarize_run(label, cfg, before, after, elapsed, load)
record['wall_window'] = {'started_at': wall_start_utc, 'finished_at': wall_end_utc,
@@ -213,6 +218,7 @@ def main():
'concurrency': CONCURRENCY,
'loadgen': 'cmd/loadgen (Go, HTTP acknowledgement throughput)',
},
'dataset_policy': 'before every measured run the dedicated messenger_track database is dropped, recreated and migrated; each run starts with 0 synthetic messages and grows only during its 5s warmup + 20s measurement. The main messenger database is untouched.',
'vm_capacity_note': 'Colima VM has 2 vCPU / 2 GiB; all API processes, PostgreSQL, Valkey and HAProxy share one kernel and one Docker host. The experiment proves process-level scaling limits, not node-level HA.',
'limits': {
'postgres_cpu': 0.7, 'postgres_mem': '512M',
@@ -227,7 +233,6 @@ def main():
M.set_stack_profile(args.final_image, revision, 2, 0.4, '256M', '240MiB', recreate_state=True)
if not M.wait_ready(120):
raise RuntimeError('stack not ready')
fixed = []
for rep in range(reps):
for replicas, cpu, mem, gomem in ((1, 0.8, '512M', '480MiB'),
@@ -257,8 +262,10 @@ def main():
cfg['revision'] = revision if name == 'optimized' else revision + '+baseline-image'
improvement.append(run_one(label, cfg, revision, raw_dir, run_dir))
# Leave the stand in the documented default profile and final image.
M.set_stack_profile(args.final_image, revision, 2, 0.4, '256M', '240MiB')
# Leave the stand in the documented default profile and main database,
# then remove the dedicated experiment database.
M.set_stack_profile(args.final_image, revision, 2, 0.4, '256M', '240MiB', database='messenger')
M.drop_database(TRACK_DB)
time.sleep(2)
summary = {