diff options
author | Milian Wolff <milian.wolff@kdab.com> | 2022-06-28 14:04:07 +0200 |
---|---|---|
committer | Milian Wolff <milian.wolff@kdab.com> | 2022-06-29 15:42:54 +0000 |
commit | 96b145c998d60d4c563abea0442c1549e263c3da (patch) | |
tree | 99a0fec254177185346bfa977ffcbdba2ef19cc5 | |
parent | 53cd4872a092f4619d2a383d6dc39086d3ce9a34 (diff) |
Cache whether the perf-$pid.map file exists
When we parse perf data files with many processes, we would
continuously query whether the perf map file exists. QFile::exists
does not cache the result internally. In our scenario, it's enough
to just check the existence once and then be done with it. This
removes many stat syscalls for complex perf data files.
Change-Id: I452ea476cdcd7ac8ba3307c44f5fb70d17e73f10
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r-- | app/perfsymboltable.cpp | 3 | ||||
-rw-r--r-- | app/perfsymboltable.h | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/app/perfsymboltable.cpp b/app/perfsymboltable.cpp index f025670..ee6d9a6 100644 --- a/app/perfsymboltable.cpp +++ b/app/perfsymboltable.cpp @@ -37,6 +37,7 @@ PerfSymbolTable::PerfSymbolTable(qint32 pid, Dwfl_Callbacks *callbacks, PerfUnwind *parent) : m_perfMapFile(QDir::tempPath() + QDir::separator() + QString::fromLatin1("perf-%1.map").arg(pid)), + m_hasPerfMap(m_perfMapFile.exists()), m_cacheIsDirty(false), m_unwind(parent), m_callbacks(callbacks), @@ -775,7 +776,7 @@ QByteArray PerfSymbolTable::symbolFromPerfMap(quint64 ip, GElf_Off *offset) cons void PerfSymbolTable::updatePerfMap() { - if (!m_perfMapFile.exists()) + if (!m_hasPerfMap) return; if (!m_perfMapFile.isOpen()) diff --git a/app/perfsymboltable.h b/app/perfsymboltable.h index 0367560..366c9f5 100644 --- a/app/perfsymboltable.h +++ b/app/perfsymboltable.h @@ -108,6 +108,7 @@ private: QFile m_perfMapFile; QVector<PerfMapSymbol> m_perfMap; + bool m_hasPerfMap; bool m_cacheIsDirty; PerfUnwind *m_unwind; |