Skip to content

Fix InMemoryCircularBuffer merge failure with large CircularMB#2439

Open
cincuranet wants to merge 1 commit into
microsoft:mainfrom
cincuranet:fix-buffer
Open

Fix InMemoryCircularBuffer merge failure with large CircularMB#2439
cincuranet wants to merge 1 commit into
microsoft:mainfrom
cincuranet:fix-buffer

Conversation

@cincuranet

Copy link
Copy Markdown
Collaborator

When collecting with /InMemoryCircularBuffer and /CircularMB:N where N is larger than ~256, PerfView collection succeeds but the subsequent KernelTraceControl merge fails (e.g. CreateMergedTraceFile returns 0x80280012), and the requested memory grows quadratically.

The buffering-mode branch of GetProperties overwrote properties->BufferSize with m_CircularBufferMB. BufferSize is a per-buffer size in KB, so a megabyte value was being written into a kilobyte field. This made each ETW buffer far larger than the OS maximum buffer size, which the relogger later chokes on during merge, and it contradicted the MinimumBuffers computation on the line above (which divides by the 64 KB quantum). It also corrupted the Attach round-trip that reconstructs buffer settings when stopping the session.

Remove the erroneous assignment so BufferSize stays at the per-buffer quantum (m_BufferQuantumKB) set earlier, matching the file-based and real-time paths. MinimumBuffers alone now sizes the in-memory pool, so (MinimumBuffers * BufferSize) == m_CircularBufferMB megabytes as intended.

When collecting with /InMemoryCircularBuffer and /CircularMB:N where N is
larger than ~256, PerfView collection succeeds but the subsequent
KernelTraceControl merge fails (e.g. CreateMergedTraceFile returns
0x80280012), and the requested memory grows quadratically.

The buffering-mode branch of GetProperties overwrote properties->BufferSize
with m_CircularBufferMB. BufferSize is a per-buffer size in KB, so a megabyte
value was being written into a kilobyte field. This made each ETW buffer far
larger than the OS maximum buffer size, which the relogger later chokes on
during merge, and it contradicted the MinimumBuffers computation on the line
above (which divides by the 64 KB quantum). It also corrupted the Attach
round-trip that reconstructs buffer settings when stopping the session.

Remove the erroneous assignment so BufferSize stays at the per-buffer
quantum (m_BufferQuantumKB) set earlier, matching the file-based and
real-time paths. MinimumBuffers alone now sizes the in-memory pool, so
(MinimumBuffers * BufferSize) == m_CircularBufferMB megabytes as intended.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@cincuranet cincuranet requested a review from a team as a code owner July 9, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant