Details
Description
While profiling QBS on clean build on a large project I noticed some performance problems:
1. A lot of time were spent in QtMocScanner::findIncludedMocCppFiles because of const char *->QString conversion. Wrapping them with QStringLiteral solved the problem. Another problem in the same function is calling ScanResultCache::Dependency::filePath function. It creates temporary strings to obtain full path to a file, when the only thing we need is to check whether it starts with "moc" and ends with ".cpp". Replacing it with fileName and checking that dirPath is empty results in much faster and maybe correct code. These changes resulted in speeding up dry run on clean build from 2 minutes to 1.
2. Function runScanner in qtmocscanner.cpp forgets to add to cache scan results if file couldn't be opened or it is empty. The problem is that during moc scan on a clean build there is no generated files (moc, ui), and it results in many cache misses (on our project i got around 1300000 misses and therefore file->open calls). After adding them to cache dry run sped up by another 2x to 30 sec.
Attachments
For Gerrit Dashboard: QBS-780 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
111054,4 | Prevent automatic casting from char* to QString. | 1.4 | qbs/qbs | Status: MERGED | +2 | 0 |
111328,2 | check included file name instead of file path in QtMocScanner | 1.4 | qbs/qbs | Status: MERGED | +2 | 0 |