wallace added inline comments.
================ Comment at: lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp:121-126 + size_t total = sizeof(m_raw_trace_size); + + for (const IntelPTInstruction &ins : m_instructions) + total += ins.GetMemoryUsage(); + + return total; ---------------- wallace wrote: > you might be able to do something like > > // As calculating the size used by error instructions is very difficult, > because errors > // are dynamic objects, we just discard them from our calculations because > errors > // are supposed to be rare and not really contribute much to the total > memory usage. > size_t non_error_instructions = count(m_instructions.begin(), > m_instructions.end(), [](const IntelPTInstruction& insn) {!insn.IsError();}); > > return IntelPTInstruction::GetNonErrorMemoryUsage() * > non_error_instructions + GetRawTraceSize(); > > notice that we need the actual `GetRawTraceSize()` and not > `sizeof(m_raw_trace_size)`, because the latter will always give you 8 bytes > on an x86_64 machine, regardless of how much data it is actually consuming. sorry, it should be return IntelPTInstruction::GetNonErrorMemoryUsage() * non_error_instructions + GetRawTraceSize() + sizeof(DecodedThread); notice the `sizeof(DecodedThread)` portion that accounts for the the m_thread_sp. The actual storage of the Thread * is somewhere else, and DecodedThread is just keeping a reference to it, so sizeof() is enough for this. ================ Comment at: lldb/source/Plugins/Trace/intel-pt/DecodedThread.h:172-173 + private: lldb::ThreadSP m_thread_sp; std::vector<IntelPTInstruction> m_instructions; ---------------- Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D122093/new/ https://reviews.llvm.org/D122093 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits