Fixed mid-round upload causing server hitch visible to STV spectators#52
Merged
Conversation
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
approved these changes
May 23, 2026
Owner
|
@Arie Thanks for fixing this! ❤️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
CopyFileduring 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.