G0: dich chinh - khong co drift bridge (run2 drained=True, recv=sent=10000), rut de xuat bu drift

This commit is contained in:
2026-08-28 12:15:27 +07:00
parent d78af9304f
commit d7dd626dd5
2 changed files with 49 additions and 24 deletions
+16
View File
@@ -69,6 +69,7 @@ def run(name, chain, n_blocks):
next_idx = 0
batch_dur = PERIOD * 4
batches = n_blocks // 4
pump_t0 = time.perf_counter()
for b in range(batches):
t0 = time.perf_counter()
for _ in range(4):
@@ -83,6 +84,19 @@ def run(name, chain, n_blocks):
dt = time.perf_counter() - t0
if dt < batch_dur:
time.sleep(batch_dur - dt)
# Drain phần còn lại (bridge xử lí nốt backlog) — nếu bridge theo kịp
# input, recv đủ = sent ngay sau pump; thiếu kéo dài = drift thật.
drain_t0 = time.perf_counter()
while len(recv_t) < len(send_t) and time.perf_counter() - drain_t0 < 2.0:
outs = sess.read_output()
base = len(recv_t)
for k in range(len(outs)):
recv_t.append((base + k, time.perf_counter()))
if not outs:
time.sleep(0.002)
pump_t1 = time.perf_counter()
stats["pump_rate"] = len(recv_t) / (pump_t1 - pump_t0)
stats["drained"] = len(recv_t) == len(send_t)
# round-trip per block
rt = []
for j, tr in recv_t:
@@ -135,6 +149,8 @@ def main():
st = run(name, chain, args.blocks)
results[name] = st
print("plugin_latency:", st.get("plugin_latency"))
print("pump_rate=%.3f blk/s drained=%s (bridge theo kip input: rate ~187.5 va drained=True)" %
(st.get("pump_rate", 0), st.get("drained")))
rt = st.get("roundtrip_ms", {})
print("roundtrip_ms n=%d mean=%.3f sd=%.3f min=%.3f p50=%.3f p99=%.3f max=%.3f" %
(rt.get("n", 0), rt.get("mean", 0), rt.get("sd", 0), rt.get("min", 0),