Repository navigation
Reduce Async FrameBuffer memory usage with PackedWrappedBuffer and static offsets - #109
Open
JasperGeurtz wants to merge 7 commits into
Open
JasperGeurtz wants to merge 7 commits into
JasperGeurtz wants to merge 7 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
Contributor
|
Looks mostly good but I think it needs |
JasperGeurtz
force-pushed
the
packed-frame-buffer
branch
from
November 16, 2026 22:12
95478a8 to
80e2a50
Compare
Contributor
|
I approve of swapping the pointer early as a probably-good-enough way to avoid reading from future frame data without incurring the performance costs of |
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%) (Reduce Async FrameBuffer memory usage #90):groundHeight,isWalkable,isBuildable,regions) directly to the main shared memory buffer viaClientDataAsync.strings,shapes,commands,unitCommands) fromFrameBuffer(flushed directly toliveGameDataviaSideEffectQueue).PackedWrappedBuffer(4.08 MB) using pre-shiftedslice2andslice3buffer views onWrappedBufferso generatedClientDataAsyncmethods 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].asyncUnsafebuffer handoffs on a single reference withoutvolatileread overhead:finalslice2andslice3views directly toWrappedBuffer(thison unpacked buffers, shifted views onPackedWrappedBuffer) with astoreFence()insetBuffer, so all dynamic slices switch through the singleClientData.bufferreference without penalizing getter reads withvolatile.liveDataontoframeBuffer.peek()(and clearunsafeReadReady) immediately afterenqueueFrame()completes (~0.05–0.35 ms), giving any JIT-cached buffer reference the remaining ~39.7+ ms whileliveDatais still frozen to transition before control returns to StarCraft.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.