We use TraceEvent to gather process-level event counters. I noticed in a recent trace that about 12% of our process memory allocations are due to resizing when we call DynamicTraceEventData.PayloadValue(int32)
In particular, the system.private.corelib.il!System.Collections.Generic.List`1[System.Collections.Generic.KeyValuePair`2[System.__Canon, System.__Canon]].AddWithResize(System.__Canon) and system.private.corelib.il!System.Collections.Generic.List`1[System.Collections.Generic.KeyValuePair`2[System.__Canon, System.__Canon]].set_Capacity(int32) frames caused by list resizing.
Is there anything preventing us from adding a constructor to StructValue that lets us specify an initial size and avoid all the reallocations when resizing the internal m_values list?
We use TraceEvent to gather process-level event counters. I noticed in a recent trace that about 12% of our process memory allocations are due to resizing when we call
DynamicTraceEventData.PayloadValue(int32)
In particular, the
system.private.corelib.il!System.Collections.Generic.List`1[System.Collections.Generic.KeyValuePair`2[System.__Canon, System.__Canon]].AddWithResize(System.__Canon)
andsystem.private.corelib.il!System.Collections.Generic.List`1[System.Collections.Generic.KeyValuePair`2[System.__Canon, System.__Canon]].set_Capacity(int32)
frames caused by list resizing.I noticed in the code that when
GetPayloadValueAt(...)
is called a StructValue is created and we go through a loop addingi
KeyValuePairs corresponding toclassInfo.FieldFetches.Length
. https://github.com/microsoft/perfview/blob/4685da655131acb73441f71ec19ea79ffa300ffa/src/TraceEvent/DynamicTraceEventParser.cs#L606C17-L612C18Is there anything preventing us from adding a constructor to StructValue that lets us specify an initial size and avoid all the reallocations when resizing the internal
m_values
list?