Skip to content

device_memory_report: emit allocation events before their counter updates - #49

Open
jimblacklercorp wants to merge 2 commits into
mainfrom
emit-allocation-events-before-counters
Open

jimblacklercorp wants to merge 2 commits into
mainfrom
emit-allocation-events-before-counters

Conversation

@jimblacklercorp

@jimblacklercorp jimblacklercorp commented Oct 15, 2026 •

Copy link
Copy Markdown

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 (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.
  • 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.

@jimblacklercorp
jimblacklercorp force-pushed the emit-allocation-events-before-counters branch from 2052134 to 6fd5dee Compare October 15, 2026 18:59
@jimblacklercorp
jimblacklercorp changed the base branch from push-kkrqmvkompvk to main October 15, 2026 18:59
…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
jimblacklercorp force-pushed the emit-allocation-events-before-counters branch from 6fd5dee to b0c719d Compare October 15, 2026 19:10
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.

1 participant