[PR #63] [MERGED] SMP: the audit log syncs only after a tick that wrote to it (-2.8 ms MSPT) #72

Closed
opened 2026-11-03 04:03:00 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon-mods/pull/63
Author: @ludovic111
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @levzzz5154

Base: main ← Head: fix/smp-audit-sync


📝 Commits (1)

  • 5aacb47 SMP: the audit log syncs only after a tick that wrote to it

📊 Changes

1 file changed (+17 additions, -4 deletions)

View changed files

📝 native/smp/mixins/smp/smp_store.rs (+17 -4)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

What

The SMP's audit log was sync_data'd at the end of every server tick, even when nothing had been appended. It now syncs only after a tick that wrote to it, and when the world closes; a quiet tick makes no system call. The durability is the same: a line is still written before its change, and synced at the end of that tick.

This fix was meant to ride in #57 and #58, but they were merged just before it was pushed, so main still has the per-tick fsync.

Cost per tick (55 bots)

tools/server_bench.py --servers horizon --bots 55 --behaviour walk --warmup 30 --seconds 120 on the Mac mini (M4 Pro, shared and noisy), Horizon f533c3a, fast profile. Same commit and profile both sides: the stock engine (SMP off) against the engine built with this mod (SMP on, 55 accounts opened). The pairs ran in alternating order, each in fresh scratch homes.

Pair SMP MSPT P95 P99 RSS MB
1 (before the fix) off 6.18 7.13 8.17 1492
1 (before the fix) on 8.95 11.42 16.17 1461
2 on 6.09 7.10 7.78 1470
2 off 6.14 7.20 8.15 1468
3 off 6.02 7.04 7.90 1475
3 on 6.17 7.26 8.12 1485

Pair 1 found a real cost: the audit log was sync_data'd at the end of every tick, even with nothing appended, about +2.8 ms. It now syncs only after a tick that wrote to it (commit "the audit log syncs only after a tick that wrote to it", in #57). After the fix, SMP on averages 6.13 ms against 6.08 ms off: +0.05 ms, within the run-to-run spread (0.12 ms). Chunks sent per second were the same (557 on both sides). The bots don't run SMP commands, so this measures the quiet tick the server pays all the time; a command costs only on the tick it runs.

Pair 1 is main's code: SMP on cost about +2.8 ms MSPT (P99 16.2 against 8.2 ms). Pairs 2 and 3 are this fix: SMP on averaged 6.13 ms against 6.08 ms off, within the run-to-run spread.

License

MIT, original.

Checks

cargo fmt --check, cargo clippy --all-targets --locked -- -D warnings, cargo test --locked (25 passed). The full native.py proof smp passed with this change (two real clients on a dedicated server: economy, market, trades, coinflip).

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon-mods/pull/63 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix/smp-audit-sync` --- ### 📝 Commits (1) - [`5aacb47`](https://github.com/horizon-rust/horizon-mods/commit/5aacb47cd4a00802543240ac6ecf092e842fc24f) SMP: the audit log syncs only after a tick that wrote to it ### 📊 Changes **1 file changed** (+17 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `native/smp/mixins/smp/smp_store.rs` (+17 -4) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What The SMP's audit log was `sync_data`'d at the end of **every** server tick, even when nothing had been appended. It now syncs only after a tick that wrote to it, and when the world closes; a quiet tick makes no system call. The durability is the same: a line is still written before its change, and synced at the end of that tick. This fix was meant to ride in #57 and #58, but they were merged just before it was pushed, so main still has the per-tick fsync. ## Cost per tick (55 bots) `tools/server_bench.py --servers horizon --bots 55 --behaviour walk --warmup 30 --seconds 120` on the Mac mini (M4 Pro, shared and noisy), Horizon f533c3a, `fast` profile. Same commit and profile both sides: the stock engine (SMP off) against the engine built with this mod (SMP on, 55 accounts opened). The pairs ran in alternating order, each in fresh scratch homes. | Pair | SMP | MSPT | P95 | P99 | RSS MB | |---|---|---|---|---|---| | 1 (before the fix) | off | 6.18 | 7.13 | 8.17 | 1492 | | 1 (before the fix) | on | **8.95** | 11.42 | 16.17 | 1461 | | 2 | on | 6.09 | 7.10 | 7.78 | 1470 | | 2 | off | 6.14 | 7.20 | 8.15 | 1468 | | 3 | off | 6.02 | 7.04 | 7.90 | 1475 | | 3 | on | 6.17 | 7.26 | 8.12 | 1485 | Pair 1 found a real cost: the audit log was `sync_data`'d at the end of every tick, even with nothing appended, about +2.8 ms. It now syncs only after a tick that wrote to it (commit "the audit log syncs only after a tick that wrote to it", in #57). After the fix, SMP on averages 6.13 ms against 6.08 ms off: +0.05 ms, within the run-to-run spread (0.12 ms). Chunks sent per second were the same (557 on both sides). The bots don't run SMP commands, so this measures the quiet tick the server pays all the time; a command costs only on the tick it runs. Pair 1 is main's code: SMP on cost about +2.8 ms MSPT (P99 16.2 against 8.2 ms). Pairs 2 and 3 are this fix: SMP on averaged 6.13 ms against 6.08 ms off, within the run-to-run spread. ## License MIT, original. ## Checks `cargo fmt --check`, `cargo clippy --all-targets --locked -- -D warnings`, `cargo test --locked` (25 passed). The full `native.py proof smp` passed with this change (two real clients on a dedicated server: economy, market, trades, coinflip). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:03:00 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon-mods#72
No description provided.