[cmake-developers] [CMake 0015201]: Xcode generator is unusably slow on large projects
Mantis Bug Tracker
mantis at public.kitware.com
Thu Oct 9 11:07:33 EDT 2014
The following issue has been SUBMITTED.
======================================================================
http://public.kitware.com/Bug/view.php?id=15201
======================================================================
Reported By: Simon
Assigned To:
======================================================================
Project: CMake
Issue ID: 15201
Category: CMake
Reproducibility: always
Severity: major
Priority: normal
Status: new
======================================================================
Date Submitted: 2014-10-09 11:07 EDT
Last Modified: 2014-10-09 11:07 EDT
======================================================================
Summary: Xcode generator is unusably slow on large projects
Description:
I am building a large project, over a thousand CMakeList.txt files resulting in
hundreds of Xcode projects being generated. This takes at least 6 times longer
than the same makefile generation.
I have profiled cmake 3.0.2 and found a significant bottleneck in
cmGlobalXCodeGenerator::FindXCodeTarget() because the objects are stored in a
vector and this vector has to be iterated over each time to find a target. This
is done thousands of times in the course of generating the Xcode project.
As a quick fix I did the following:
cmGlobalXCodeGenerator.h, added member var:
std::unordered_map<const cmTarget*, cmXCodeObject*> mXcodeObjectMap;
cmGlobalXCodeGenerator.cpp
void cmGlobalXCodeGenerator::ClearXCodeObjects()
added to end of method: mXcodeObjectMap.clear();
cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget)
Under call to target->SetTarget(...) added: mXcodeObjectMap[&cmtarget] = target;
cmGlobalXCodeGenerator::CreateXCodeTarget(...)
Under call to target->SetTarget(...) added: mXcodeObjectMap[&cmtarget] = target;
cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget const* t)
rewrote to:
cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget const* t)
{
if(!t)
{
return 0;
}
std::unordered_map<const cmTarget*, cmXCodeObject*>::iterator iter =
mXcodeObjectMap.find(t);
if (iter == mXcodeObjectMap.end())
{
return 0;
}
return iter->second;
}
So basically rather than constantly iterating through a vector for the Xcode
object with the right target, it now keeps an unordered map where the key is the
target pointer, and the object is the Xcode object. This reduces the lookup time
enormously.
With only this change the generation of the project I'm working on goes down
from well over an hour to around 10 mins, which puts it inline with the makefile
generator performance.
Steps to Reproduce:
Build a large set of projects.
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2014-10-09 11:07 Simon New Issue
======================================================================
More information about the cmake-developers
mailing list