Repository navigation
Offscreen host: skip drawing held turns and pace submitted frames - #7
Merged
Merged
Conversation
…e frames tecs.host.iterate now reports a turn the paused application held as `held` instead of `continue`: a frame that runs advances app.frame, so a turn that finished with it unchanged is one `pause` held. The window keeps treating it as a frame. The headless loop no longer extracts and renders a held turn unless a screenshot is pending, an image command or a model upload arrived, or nothing was drawn yet; with nothing to do it sleeps 250 us. A paused --offscreen host used to redraw the unchanged frame every turn, unpaced, spinning a core and flooding the GPU. Frames that do run now keep at most two in flight (Graphics::pace_frame waits for the frame before last). Without it the loop submitted as fast as it extracted, and on a GPU shared by several hosts the backlog and its staging memory grew to about 1 GB per host and the hosts slowed each other down. --frames N still counts frames that ran and were drawn; held turns, including ones drawn for a screenshot, do not count. --screenshot at exit draws once more if a held turn went undrawn since the last draw, since a debug tool may have edited the world between frames.
mtdowling
approved these changes
Oct 15, 2026
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.
A paused
--offscreenhost (MCPclock_pausewith no grantedclock_stepframes) used to extract and render the unchanged held world every turn, with no sleep. It spun at up to 200% CPU, and with nothing pacing submissions the GPU backlog grew each host to about 1 GB. Test hosts running side by side slowed each other down: a 179-case harness suite took 50 s at 2 hosts but 200–320 s at 4–8.tecs.host.iteratereports a held turn asheld, detected by an unchangedapp.frame. The windowed host treats it as a frame, as before.Graphics::pace_frame).--frames Ncounts frames that ran.--screenshotat exit redraws if the world may have changed while held.Measured on an M2 Pro, release build, same 179-case suite:
Peak RSS is about 100 MB per host (was up to 1.1 GB); an idle paused host uses ~7% CPU (was 200%). The single-host cost is the two-frame limit. Verdicts, saves, screenshots and screen models are byte-identical between the two hosts.
Tests: a new
hosttestcase (held, step, quit on a held turn),nupp check --strict,nupp test,cargo test -p tecs-winit-host, clippy, fmt.Compatibility: a component built from this tree needs a host built from it, because an older host rejects the
heldstate. GPU particles no longer advance while the clock is held (they stepped once per render).