Skip to content

Fixed mid-round upload causing server hitch visible to STV spectators#52

Merged
F2 merged 4 commits into
F2:masterfrom
Arie:fix-midround-upload-lag
May 23, 2026
Merged

Fixed mid-round upload causing server hitch visible to STV spectators#52
F2 merged 4 commits into
F2:masterfrom
Arie:fix-midround-upload-lag

Conversation

@Arie

@Arie Arie commented May 23, 2026

Copy link
Copy Markdown
Contributor

Trying not to be "sloppy" here. Benchmarked the current code and this alternative to the mid-game log uploads that could cause end-of-round-lag to STV spectators. Benchmarked with realistic log sizes on the serveme docker image, showing the hitch with mid-game uploads, and the hitch being gone with this change:

The synchronous CopyFile during mid-game log uploads blocks the main thread for 60-100ms on typical log sizes, suspected to cause a visible hitch for STV spectators that spoils round endings.

Replaced with AnyHttp_CopyFile, which was already built for exactly this purpose, it spreads the file copy across multiple server frames. The log is still copied to a snapshot before uploading, so behavior is identical.

Only affects logstf_midgameupload 1 (the default). End-of-match uploads were already async.

Benchmark (native x86_64, 66.7 tick / 15ms budget)

Results of 3 benchmark runs on NVMe-based 14600k server.

Log size Before After
100KB 10-14 ms 0.0 ms
630KB 64-73 ms 0.0 ms
1MB 101-111 ms 0.0 ms

Arie and others added 4 commits May 23, 2026 17:27
Replaced the synchronous CopyFile with AnyHttp_CopyFile, which spreads
the copy across frames via RequestFrame. Same snapshot-then-upload
behavior, no main-thread stall. Only affected midgameupload (default);
end-of-match uploads already used async PutFile.

Benchmarked on native x86_64 (serveme/tf2-cloud-server, 66.7 tick):

                  Sync CopyFile    Direct PutFile    Async CopyFile
                  (old)            (no snapshot)     (chosen fix)
  100KB           10-14 ms         0.1 ms            0.0 ms
  300KB           31-43 ms         0.1 ms            0.0 ms
  630KB           64-73 ms         0.1 ms            0.0 ms
  1MB            101-111 ms        0.1 ms            0.0 ms

Direct PutFile skips the snapshot copy but risks inconsistent reads if
FlushLog fires mid-copy. Async CopyFile preserves the snapshot with
zero main-thread blocking.
@F2
F2 merged commit 22d6ce1 into F2:master May 23, 2026
2 checks passed
@F2

F2 commented May 23, 2026

Copy link
Copy Markdown
Owner

@Arie Thanks for fixing this! ❤️
And neat reuse of AnyHttp_CopyFile 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants