Repository navigation
Reduce Async FrameBuffer memory usage with PackedWrappedBuffer and static offsets - #109
Open
JasperGeurtz wants to merge 6 commits into
Open
JasperGeurtz wants to merge 6 commits into
JasperGeurtz wants to merge 6 commits into
Conversation
JasperGeurtz
force-pushed
the
packed-frame-buffer
branch
8 times, most recently
from
November 7, 2026 15:51
10dd342 to
236efdd
Compare
added 5 commits
November 8, 2026 10:31
…atic offsets (#90) - Add PackedWrappedBuffer with pre-shifted slice views (slice2, slice3, slice4) so all BWAPI field offsets remain static compile-time constants with zero runtime branches - Keep original WrappedBuffer pure, only adding a package-private view constructor - Auto-generate AsyncClientData and slice-routed struct views (AsyncPosition, AsyncEvent, AsyncCommand, AsyncUnitCommand) via DumpToClient - Preserve unsafe async handoffs across live and packed buffers for both in-flight reads and retained struct views - Add unit and synchronization tests covering memory reduction, static/dynamic routing, and unsafe async handoffs
JasperGeurtz
force-pushed
the
packed-frame-buffer
branch
from
November 8, 2026 10:03
236efdd to
a259143
Compare
This branch has not been deployed
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.
#90
FrameBuffermemory from 33.0 MB to 4.08 MB per slot (-88%, saving ~290 MB for 10 slots) (Reduce Async FrameBuffer memory usage #90):groundHeight,isWalkable,isBuildable,regions) directly to the main shared memory buffer viaAsyncClientData.strings,shapes,commands,unitCommands) fromFrameBuffer(flushed directly toliveGameDataviaSideEffectQueue).PackedWrappedBuffer(4.08 MB) using pre-shiftedslice2andslice3buffer views so generatedAsyncClientDatamethods use compile-time BWAPI offsets for both unpackedliveDataand packedFrameBufferslots with zero runtime branches.units,events, andeventStringsper frame:maxUnitCount(viainitialUnitCountandUnitDiscoverevents) and skip copying the unused tails ofunits[10000],events[10000], andeventStrings[1000].asyncUnsafethread-safe on on-time frames:liveDataontoframeBuffer.peek()until the frame actually times out (remainingNanos <= 0) and control is about to return to StarCraft, avoiding mid-frame buffer swaps when the bot finishes on time.lockWrite,synchronized framesBuffered(),unsafeReadReadyLock, andlastBotThrowLockontoframeBuffer.lockSize(andvolatile lastBotThrow), and stopsignalAll()when clearingunsafeReadReady = false.SideEffectQueue:queueandflushQueueunder the monitor and apply side effects toliveGameDataoutside the lock so the bot thread is not blocked onenqueue()during shared-memory flushes.