Repository navigation
device_memory_report: emit allocation events before their counter updates - #49
Open
jimblacklercorp wants to merge 2 commits into
Open
jimblacklercorp wants to merge 2 commits into
jimblacklercorp wants to merge 2 commits into
Conversation
jimblacklercorp
force-pushed
the
emit-allocation-events-before-counters
branch
from
October 15, 2026 18:59
2052134 to
6fd5dee
Compare
…ates Every change to tracked memory emitted its TRACE_COUNTER updates before the VulkanMemoryAllocation instant event describing it, and the session start dump wrote all counters before replaying allocations, bindings and names. A consumer resolving allocation state at a counter sample's timestamp therefore missed the event that produced the sample. Emit each VulkanMemoryAllocation event ahead of the counter updates the same change causes: - BindResourceMemory and RemoveResourceBinding emit BIND / DESTROY before adjusting the usage and unbound counters. - RemoveAllocationTracking emits the DESTROY of each binding and then the DESTROY of the freed allocation itself before subtracting the bindings' usage bytes and the allocation's unbound bytes, replacing the DESTROY its three callers emitted after the counters had already changed. - OnMemoryReportEvent and OnAllocateMemory emit CREATE before updating the unbound counter, resolving the driver cluster name up front via a new ResolveClusterName helper and passing it through to UpdateAllocationUnboundCounter. - ReattributeDriverAllocations emits its DESTROY + CREATE pair before moving the unbound bytes to the new cluster's counter. - DumpCurrentCountersAndAllocations writes counters after the allocations, bindings and names.
A MemoryAllocation entry with total_size == 0 is a placeholder created ahead of its allocation (for example by SetAllocationMemoryProperties, BindResourceMemory, or OnAllocateMemory on a callback-enabled device) that has never emitted a CREATE event. Guard the slab DESTROY emission in RemoveAllocationTracking on allocation.total_size > 0 so freeing an unmaterialized placeholder still cleans up any pre-bound resources and erases the entry without emitting an unmatched 0-byte DESTROY event.
jimblacklercorp
force-pushed
the
emit-allocation-events-before-counters
branch
from
October 15, 2026 19:10
6fd5dee to
b0c719d
Compare
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.
Every change to tracked memory emitted its TRACE_COUNTER updates before
the VulkanMemoryAllocation instant event describing it, and the session
start dump wrote all counters before replaying allocations, bindings and
names. A consumer resolving allocation state at a counter sample's
timestamp therefore missed the event that produced the sample.
Emit each VulkanMemoryAllocation event ahead of the counter updates the
same change causes:
before adjusting the usage and unbound counters.
the DESTROY of the freed allocation itself (when total_size > 0)
before subtracting the bindings' usage bytes and the allocation's
unbound bytes, replacing the DESTROY its three callers emitted after
the counters had already changed.
the unbound counter, resolving the driver cluster name up front via a
new ResolveClusterName helper and passing it through to
UpdateAllocationUnboundCounter.
moving the unbound bytes to the new cluster's counter.
allocations, bindings and names.