diff --git a/abs.sh b/abs.sh index 4b9e8af..c5b0abe 100755 --- a/abs.sh +++ b/abs.sh @@ -572,11 +572,11 @@ zh_reason() { reason="${reason//critical CPU bottleneck (component score /CPU 严重瓶颈(分项得分 }" reason="${reason//critical memory bottleneck (component score /内存严重瓶颈(分项得分 }" reason="${reason//critical disk bottleneck (component score /磁盘严重瓶颈(分项得分 }" - reason="${reason//critical fsync bottleneck (component score /fsync 严重瓶颈(分项得分 }" + reason="${reason//critical durable-write (fsync) bottleneck (component score /持久化写入(fsync)严重偏慢(分项得分 }" reason="${reason//CPU component is weak (component score /CPU 分项偏弱(得分 }" reason="${reason//memory component is weak (component score /内存分项偏弱(得分 }" reason="${reason//disk component is weak (component score /磁盘性能偏弱(得分 }" - reason="${reason//fsync component is weak (component score /持久化写入(fsync)偏慢,网络存储常见,数据库类负载受影响(得分 }" + reason="${reason//fsync component is weak (component score /持久化写入(fsync)偏慢,网络存储常见(得分 }" reason="${reason//low durable-write rate (common on network-replicated storage)/持久化写入速率偏低(网络复制存储常见)}" reason="${reason//OpenVZ\/container storage can be cache-inflated/OpenVZ\/容器磁盘数据可能受缓存影响}" reason="${reason//very high write\/fsync numbers; verify with --full before buying/写入\/fsync 数值异常高,购买前请用 --full 复测}" @@ -1278,7 +1278,8 @@ if component_scores: floor_name, floor_score = min(component_scores.items(), key=lambda item: item[1]) if floor_score < 250: verdict = 'AVOID' - reason = f'critical {floor_name} bottleneck (component score {round(floor_score)})' + floor_label = 'durable-write (fsync)' if floor_name == 'fsync' else floor_name + reason = f'critical {floor_label} bottleneck (component score {round(floor_score)})' elif floor_score < 500: if verdict == 'KEEP': verdict = 'MAYBE' diff --git a/docs/scoring.md b/docs/scoring.md index 123ad55..849de51 100644 --- a/docs/scoring.md +++ b/docs/scoring.md @@ -63,7 +63,8 @@ from a reference fleet: - `2000 writes/s` (fsync): durable-write rate where storage genuinely persists data vs. where flushes are absorbed by volatile cache. Network-replicated storage (e.g. Ceph) is typically well under; a low - fsync score means slow commits, not a faulty disk. + fsync score reflects slow durable writes, and by itself cannot tell a slow + disk from a faulty one. - `800/1200` verdict thresholds and the `0.40/0.15/0.30/0.15` weights: chosen to weight CPU and 4K QD1 disk (what makes a VPS *feel* slow) above memory bandwidth and fsync rate; not empirically optimized. diff --git a/tests/test_abs.py b/tests/test_abs.py index c3f9301..fd81f5f 100644 --- a/tests/test_abs.py +++ b/tests/test_abs.py @@ -129,7 +129,7 @@ def test_chinese_verdict_is_concise(self) -> None: [ "bash", "-c", - helpers + "\nzh_verdict 'MAYBE - disk component is weak (component score 288); weak durable-write/fsync'", + helpers + "\nzh_verdict 'MAYBE - disk component is weak (component score 288); low durable-write rate (common on network-replicated storage)'", ], text=True, capture_output=True, @@ -137,6 +137,69 @@ def test_chinese_verdict_is_concise(self) -> None: ) self.assertEqual(proc.stdout, "谨慎保留 — 磁盘性能偏弱") + def test_chinese_fsync_wording_is_mapped(self) -> None: + helpers = extract_between(self.source, "zh_reason() {", "\n}\n\nzh_result()") + "\n}\n" + match = re.search( + r"abs_verdict\(\) \{\n python3 - \"\$SCORE_TEXT\" \"\$RESULTS\" \"\$VM_TYPE\" \"\$T\" \"\$KV\" <<'PY'\n(.*?)\nPY\n\}", + self.source, + re.S, + ) + self.assertIsNotNone(match) + assert match is not None + code = match.group(1) + why = "low durable-write rate (common on network-replicated storage)" + + def zh(call: str) -> str: + proc = subprocess.run( + ["bash", "-c", helpers + "\n" + call], + text=True, + capture_output=True, + check=True, + ) + return proc.stdout + + # Feed the real English verdict into zh_verdict so a change to the + # English wording without the matching Chinese mapping is caught. + cases = [ + ( + 300, + f"MAYBE - fsync component is weak (component score 387); {why}", + "谨慎保留 — 持久化写入(fsync)偏慢,网络存储常见", + ), + ( + 50, + f"AVOID - critical durable-write (fsync) bottleneck (component score 158); {why}", + "不建议保留 — 持久化写入(fsync)严重偏慢", + ), + ] + for fsync, english, chinese in cases: + with self.subTest(fsync=fsync): + with tempfile.NamedTemporaryFile("w", encoding="utf-8") as results: + results.write( + "Metric\tResult\n" + "CPU single thread\t1200 events/s\n" + "CPU all threads (1)\t1200 events/s\n" + "Memory read (1 threads)\t30000 MiB/sec\n" + "Memory write (1 threads)\t20000 MiB/sec\n" + "Disk random read 4K QD1\t10000 IOPS\n" + "Disk random write 4K QD1\t5000 IOPS\n" + f"Disk durable write 4K fsync\t{fsync} writes/s\n" + ) + results.flush() + proc = subprocess.run( + ["python3", "-c", code, "FULL 1300 (local only)", results.name, "kvm"], + text=True, + capture_output=True, + check=True, + ) + verdict = proc.stdout.strip() + self.assertEqual(verdict, english) + self.assertEqual(zh(f"zh_verdict '{verdict}'"), chinese) + + # zh_verdict drops everything after "; ", so the why mapping is only + # reachable through zh_reason directly. + self.assertEqual(zh(f"zh_reason '{why}'"), "持久化写入速率偏低(网络复制存储常见)") + def test_dependency_tools_status_is_clear(self) -> None: metric = extract_between(self.source, "zh_metric() {", "\n}\n\nzh_components()") + "\n}\n" result = extract_between(self.source, "zh_result() {", "\n}\n\nadd()") + "\n}\n"