* A vogl_trace_packet can have lots of memory associated with it, so they should not be copied or assigned if it can be avoided. In this case, the loading was using a single trace packet instance to load the data from disk, then the packet was being copied into its associated node in the API call tree. This assignment / copy was temporarily (and unnecessarily) doubling the size of the packet, requiring extra memory allocations, and generally just causing excessive overhead. Instead, allocate a separate vogl_trace_packet for each packet that needs to be loaded from disk, and pass that memory off the apiCallItem for management. This greatly improves load times and allows us to load traces that would previously fail due to memory limitations.
* Also move a few allocations over to using vogl_new and vogl_delete so that vogl can track the memory usage.
(cherry picked from commit
1bcaf8bd911c1b1604e59898c752506be1394c38)
class vogleditor_apiCallItem : public vogleditor_snapshotItem
{
public:
class vogleditor_apiCallItem : public vogleditor_snapshotItem
{
public:
- vogleditor_apiCallItem(vogleditor_frameItem* pFrame, vogl_trace_packet& tracePacket, const vogl_trace_gl_entrypoint_packet& glPacket)
+ vogleditor_apiCallItem(vogleditor_frameItem* pFrame, vogl_trace_packet* pTracePacket, const vogl_trace_gl_entrypoint_packet& glPacket)
: m_pParentFrame(pFrame),
m_glPacket(glPacket),
: m_pParentFrame(pFrame),
m_glPacket(glPacket),
- m_tracePacket(tracePacket),
+ m_pTracePacket(pTracePacket),
m_globalCallIndex(glPacket.m_call_counter),
m_begin_rdtsc(glPacket.m_packet_begin_rdtsc),
m_end_rdtsc(glPacket.m_packet_end_rdtsc),
m_globalCallIndex(glPacket.m_call_counter),
m_begin_rdtsc(glPacket.m_packet_begin_rdtsc),
m_end_rdtsc(glPacket.m_packet_end_rdtsc),
~vogleditor_apiCallItem()
{
~vogleditor_apiCallItem()
{
+ if (m_pTracePacket != NULL)
+ {
+ vogl_delete(m_pTracePacket);
+ m_pTracePacket = NULL;
+ }
}
inline vogleditor_frameItem* frame() const
}
inline vogleditor_frameItem* frame() const
vogl_trace_packet* getTracePacket()
{
vogl_trace_packet* getTracePacket()
{
}
inline uint64_t backtraceHashIndex() const
}
inline uint64_t backtraceHashIndex() const
private:
vogleditor_frameItem* m_pParentFrame;
const vogl_trace_gl_entrypoint_packet m_glPacket;
private:
vogleditor_frameItem* m_pParentFrame;
const vogl_trace_gl_entrypoint_packet m_glPacket;
- vogl_trace_packet m_tracePacket;
+ vogl_trace_packet* m_pTracePacket;
uint64_t m_globalCallIndex;
uint64_t m_begin_rdtsc;
uint64_t m_globalCallIndex;
uint64_t m_begin_rdtsc;
{
for (int i = 0; i < m_apiCallList.size(); i++)
{
{
for (int i = 0; i < m_apiCallList.size(); i++)
{
- delete m_apiCallList[i];
+ vogl_delete(m_apiCallList[i]);
m_apiCallList[i] = NULL;
}
m_apiCallList.clear();
m_apiCallList[i] = NULL;
}
m_apiCallList.clear();
m_trace_ctypes.init(pTrace_reader->get_sof_packet().m_pointer_sizes);
m_trace_ctypes.init(pTrace_reader->get_sof_packet().m_pointer_sizes);
- vogl_trace_packet trace_packet(&m_trace_ctypes);
-
for ( ; ; )
{
vogl_trace_file_reader::trace_file_reader_status_t read_status = pTrace_reader->read_next_packet();
for ( ; ; )
{
vogl_trace_file_reader::trace_file_reader_status_t read_status = pTrace_reader->read_next_packet();
if (pTrace_reader->get_packet_type() == cTSPTGLEntrypoint)
{
if (pTrace_reader->get_packet_type() == cTSPTGLEntrypoint)
{
- if (!trace_packet.deserialize(pTrace_reader->get_packet_buf().get_ptr(), pTrace_reader->get_packet_buf().size(), false))
+ vogl_trace_packet* pTrace_packet = vogl_new(vogl_trace_packet, &m_trace_ctypes);
+
+ if (!pTrace_packet->deserialize(pTrace_reader->get_packet_buf().get_ptr(), pTrace_reader->get_packet_buf().size(), false))
{
console::error("%s: Failed parsing GL entrypoint packet\n", VOGL_FUNCTION_NAME);
break;
{
console::error("%s: Failed parsing GL entrypoint packet\n", VOGL_FUNCTION_NAME);
break;
// Check if this is a state snapshot.
// This is entirely optional since the client is designed to dynamically get new snapshots
// if they don't exist.
// Check if this is a state snapshot.
// This is entirely optional since the client is designed to dynamically get new snapshots
// if they don't exist.
- GLuint cmd = trace_packet.get_param_value<GLuint>(0);
- GLuint size = trace_packet.get_param_value<GLuint>(1); VOGL_NOTE_UNUSED(size);
+ GLuint cmd = pTrace_packet->get_param_value<GLuint>(0);
+ GLuint size = pTrace_packet->get_param_value<GLuint>(1); VOGL_NOTE_UNUSED(size);
if (cmd == cITCRKeyValueMap)
{
if (cmd == cITCRKeyValueMap)
{
- key_value_map &kvm = trace_packet.get_key_value_map();
+ key_value_map &kvm = pTrace_packet->get_key_value_map();
dynamic_string cmd_type(kvm.get_string("command_type"));
if (cmd_type == "state_snapshot")
dynamic_string cmd_type(kvm.get_string("command_type"));
if (cmd_type == "state_snapshot")
// format parameters
funcCall.append("( ");
dynamic_string paramStr;
// format parameters
funcCall.append("( ");
dynamic_string paramStr;
- for (uint param_index = 0; param_index < trace_packet.total_params(); param_index++)
+ for (uint param_index = 0; param_index < pTrace_packet->total_params(); param_index++)
{
if (param_index != 0)
funcCall.append(", ");
paramStr.clear();
{
if (param_index != 0)
funcCall.append(", ");
paramStr.clear();
- trace_packet.pretty_print_param(paramStr, param_index, false);
+ pTrace_packet->pretty_print_param(paramStr, param_index, false);
funcCall.append(paramStr.c_str());
}
funcCall.append(" )");
funcCall.append(paramStr.c_str());
}
funcCall.append(" )");
- if (trace_packet.has_return_value())
+ if (pTrace_packet->has_return_value())
{
funcCall.append(" = ");
paramStr.clear();
{
funcCall.append(" = ");
paramStr.clear();
- trace_packet.pretty_print_return_value(paramStr, false);
+ pTrace_packet->pretty_print_return_value(paramStr, false);
funcCall.append(paramStr.c_str());
}
funcCall.append(paramStr.c_str());
}
if (pCurFrame == NULL)
{
pCurFrame = new vogleditor_frameItem(total_swaps);
if (pCurFrame == NULL)
{
pCurFrame = new vogleditor_frameItem(total_swaps);
- vogleditor_apiCallTreeItem* pNewFrameNode = new vogleditor_apiCallTreeItem(pCurFrame, pCurParent);
+ vogleditor_apiCallTreeItem* pNewFrameNode = vogl_new(vogleditor_apiCallTreeItem, pCurFrame, pCurParent);
pCurParent->appendChild(pNewFrameNode);
m_itemList.append(pNewFrameNode);
pCurParent->appendChild(pNewFrameNode);
m_itemList.append(pNewFrameNode);
}
// make item and node for the api call
}
// make item and node for the api call
- vogleditor_apiCallItem* pCallItem = new vogleditor_apiCallItem(pCurFrame, trace_packet, *pGL_packet);
+ vogleditor_apiCallItem* pCallItem = vogl_new(vogleditor_apiCallItem, pCurFrame, pTrace_packet, *pGL_packet);
pCurFrame->appendCall(pCallItem);
if (pPendingSnapshot != NULL)
pCurFrame->appendCall(pCallItem);
if (pPendingSnapshot != NULL)
pPendingSnapshot = NULL;
}
pPendingSnapshot = NULL;
}
- vogleditor_apiCallTreeItem* item = new vogleditor_apiCallTreeItem(funcCall, pCallItem, pCurParent);
+ vogleditor_apiCallTreeItem* item = vogl_new(vogleditor_apiCallTreeItem, funcCall, pCallItem, pCurParent);
pCurParent->appendChild(item);
m_itemList.append(item);
pCurParent->appendChild(item);
m_itemList.append(item);