Skip to content

Allow reading multiple data chunks per frame in a single-threaded HTTPRequest#120462

Open
NoNormalDev wants to merge 1 commit into
godotengine:masterfrom
NoNormalDev:httpsingle
Open

Allow reading multiple data chunks per frame in a single-threaded HTTPRequest#120462
NoNormalDev wants to merge 1 commit into
godotengine:masterfrom
NoNormalDev:httpsingle

Conversation

@NoNormalDev

Copy link
Copy Markdown
Contributor

Problem(s) solved by this PR

Additional information

When use_threads = false on a HTTPRequest, incoming data gets processed on the main thread. Right now, only one chunk gets read per frame, which means throughput is effectively capped at download_chunk_size * FPS, which can be problematic (see the linked issue for more details)

This PR lets multiple chunks be processed within a single frame.

I also added a read_time_limit property that limits how much time can be spent reading data per frame (this only matters when use_threads = false, it's not used otherwise). Without a limit like this, a fast connection could end up stalling the main for seconds even. At least one read still always happens per frame regardless of the limit.

Here is some data from a project running at 20 FPS, downloading a 16 MiB file on a simulated 10 MB/s network (localhost with a python server):

download_chunk_size 4 KB 65 KB 512 KB
4.7.stable 205 s 13 s 1.9 s
This PR 1.85 s 1.85 s 1.85 s

Author disclosure

I used Claude to discuss possible approaches, though honestly most of its suggestions were awful, and to review the changes for mistakes before pushing.
All the code is mine.

@NoNormalDev NoNormalDev requested review from a team as code owners June 19, 2026 19:58
@NoNormalDev NoNormalDev force-pushed the httpsingle branch 2 times, most recently from 12316ac to 73d0c73 Compare June 19, 2026 21:13
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.

HTTPRequest Non-Threaded Download Speeds are Limited by Framerate

1 participant