diff options
author | Milian Wolff <milian.wolff@kdab.com> | 2017-04-10 16:52:58 +0200 |
---|---|---|
committer | Milian Wolff <milian.wolff@kdab.com> | 2017-04-12 13:32:22 +0000 |
commit | 60377d85e4a6542aca090716c0079af09a79cd9e (patch) | |
tree | a5bea1bd91c735e8541d738343f423bf227d7494 | |
parent | 90a663b1c30ae2f185c782966a49e90a1ce59820 (diff) |
Do not set app nor extra library paths by default
By default, both paths pointed to the current working directory.
When I use perfparser in a folder that has many (sub)directories and
files, it is excruciatingly slow:
145338.874552 task-clock (msec) # 0.997 CPUs utilized
13,353 context-switches # 0.092 K/sec
147 cpu-migrations # 0.001 K/sec
4,497 page-faults # 0.031 K/sec
557,953,349,806 cycles # 3.839 GHz
1,009,672,374,742 instructions # 1.81 insn per cycle
238,669,106,565 branches # 1642.156 M/sec
3,017,437,636 branch-misses # 1.26% of all branches
145.823501862 seconds time elapsed
This is on a SSD with an ext4 file system, but going through 104164
files for every mmap event is simply going to take its time.
This patch improves this situation by dropping the implicit recursive
lookup in the current working directory.
The performance impact is tremendous:
4425.928440 task-clock (msec) # 0.999 CPUs utilized
158 context-switches # 0.036 K/sec
1 cpu-migrations # 0.000 K/sec
3,299 page-faults # 0.745 K/sec
17,042,783,950 cycles # 3.851 GHz
36,178,866,218 instructions # 2.12 insn per cycle
8,448,978,802 branches # 1908.973 M/sec
63,738,579 branch-misses # 0.75% of all branches
4.432039578 seconds time elapsed
I.e. this patch makes this case more than 33 times faster.
Change-Id: I9a2c4e84ed739e1fc602be675bd01369b1c39f4c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r-- | app/main.cpp | 6 | ||||
-rw-r--r-- | app/perfsymboltable.cpp | 11 |
2 files changed, 10 insertions, 7 deletions
diff --git a/app/main.cpp b/app/main.cpp index fee9055..eebb684 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -121,15 +121,13 @@ int main(int argc, char *argv[]) QCommandLineOption extra(QLatin1String("extra"), QCoreApplication::translate( "main", "Look for additional libraries in <path> (default: .)."), - QLatin1String("path"), - QLatin1String(".")); + QLatin1String("path")); parser.addOption(extra); QCommandLineOption appPath(QLatin1String("app"), QCoreApplication::translate( "main", "Look for application binary in <path> (default: .)."), - QLatin1String("path"), - QLatin1String(".")); + QLatin1String("path")); parser.addOption(appPath); const auto defaultArch diff --git a/app/perfsymboltable.cpp b/app/perfsymboltable.cpp index a29cb30..c268426 100644 --- a/app/perfsymboltable.cpp +++ b/app/perfsymboltable.cpp @@ -170,6 +170,11 @@ static bool findInExtraPath(QFileInfo &path, const QString &fileName) return false; } +static QStringList splitPath(const QString &path) +{ + return path.split(QLatin1Char(':'), QString::SkipEmptyParts); +} + void PerfSymbolTable::registerElf(const PerfRecordMmap &mmap, const QByteArray &buildId, const QString &appPath, const QString &systemRoot, const QString &extraLibsPath, const QString &debugInfoPath) @@ -188,7 +193,7 @@ void PerfSymbolTable::registerElf(const PerfRecordMmap &mmap, const QByteArray & if (!buildId.isEmpty()) { const QString buildIdPath = QString::fromUtf8(mmap.filename() + '/' + buildId.toHex() + "/elf"); - foreach (const QString &extraPath, debugInfoPath.split(QLatin1Char(':'))) { + foreach (const QString &extraPath, splitPath(debugInfoPath)) { fullPath.setFile(extraPath); if (findInExtraPath(fullPath, buildIdPath)) { found = true; @@ -196,14 +201,14 @@ void PerfSymbolTable::registerElf(const PerfRecordMmap &mmap, const QByteArray & } } } - if (!found) { + if (!found && !appPath.isEmpty()) { // try to find the file in the app path fullPath.setFile(appPath); found = findInExtraPath(fullPath, fileInfo.fileName()); } if (!found) { // try to find the file in the extra libs path - foreach (const QString &extraPath, extraLibsPath.split(QLatin1Char(':'))) { + foreach (const QString &extraPath, splitPath(extraLibsPath)) { fullPath.setFile(extraPath); if (findInExtraPath(fullPath, fileInfo.fileName())) { found = true; |