After installing several svn versions I found out that for versions until r7459 the time for loading project files is amazingly fast, but from version r4760 on there is a huge delay in loading them. What did change in codeblocks and how can I disable this feature?
Did you mean: r7460?
But I can't find any reason why r7460 will be slow than 7459.
What's changed in r7460 looks like:
Index: trunk/src/sdk/cbproject.cpp
===================================================================
--- trunk/src/sdk/cbproject.cpp (revision 7459)
+++ trunk/src/sdk/cbproject.cpp (revision 7460)
@@ -72,7 +72,7 @@
virtual wxDirTraverseResult OnDir(const wxString& dirname)
{
- return wxDIR_IGNORE;
+ return wxDIR_CONTINUE;
}
bool IsValidPath() { return m_IsValidPath; }
@@ -380,7 +380,7 @@
if (dir.IsOpened())
{
ProjectDirTraverser traverser;
- dir.Traverse(traverser, wxEmptyString, wxDIR_FILES);
+ dir.Traverse(traverser, wxEmptyString, wxDIR_DIRS | wxDIR_FILES);
if (traverser.IsValidPath())
base = tmpbaseF;
}
I can confirm that loading large projects is very slow.
Not here, but it might depend onthe place where your project file is located.
The ProjectDirTraverser is only called from inside CalculateTopLevelPath, and that should not happen so often.
Can you apply the following patch and start C::B with "-d" parameter, and have alook ath the "Code::Blocks Debug".
You should see how often the traverser is called and how long it needed.
You can also try what happens if the CodeCompletion-plugin is disabled.
diff --git a/src/sdk/cbproject.cpp b/src/sdk/cbproject.cpp
index c50a046..ec7d528 100644
--- a/src/sdk/cbproject.cpp
+++ b/src/sdk/cbproject.cpp
@@ -348,6 +348,7 @@ void cbProject::CalculateCommonTopLevelPath()
wxFileName base = GetBasePath() + sep;
Manager::Get()->GetLogManager()->DebugLog(_T("Project's base path: ") + base.GetFullPath());
+ int traverser_count = 0;
// this loop takes ~30ms for 1000 project files
// it's as fast as it can get, considered that it used to take ~1200ms ;)
// don't even bother making it faster - you can't :)
@@ -381,10 +382,13 @@ void cbProject::CalculateCommonTopLevelPath()
wxDir dir(tmpbaseF.GetPath());
if (dir.IsOpened())
{
+ Manager::Get()->GetLogManager()->DebugLogError(F(_("We call ProjectDirTraverser %d times"), ++traverser_count));
+ wxStopWatch sw;
ProjectDirTraverser traverser;
dir.Traverse(traverser, wxEmptyString, wxDIR_DIRS | wxDIR_FILES);
if (traverser.IsValidPath())
base = tmpbaseF;
+ Manager::Get()->GetLogManager()->DebugLogError(F(_("traversing took %d ms"), (int)sw.Time()));
}
}
}
Here is the patch I used:
diff --git a/src/sdk/cbproject.cpp b/src/sdk/cbproject.cpp
index fbf109a..dafb4cc 100644
--- a/src/sdk/cbproject.cpp
+++ b/src/sdk/cbproject.cpp
@@ -58,11 +58,12 @@ namespace compatibility { typedef TernaryCondTypedef<wxMinimumVersion<2,5>::eval
class ProjectDirTraverser : public wxDirTraverser
{
public:
- ProjectDirTraverser() : m_IsValidPath(false)
+ ProjectDirTraverser() : m_IsValidPath(false) , countFiles(0), countDirs(0)
{}
virtual wxDirTraverseResult OnFile(const wxString& filename)
{
+ ++countFiles;
const FileType ft = FileTypeOf(filename);
if (ft == ftCodeBlocksProject || ft == ftCodeBlocksWorkspace)
{
@@ -74,13 +75,20 @@ public:
virtual wxDirTraverseResult OnDir(const wxString& dirname)
{
+ ++countDirs;
return wxDIR_CONTINUE;
}
- bool IsValidPath() { return m_IsValidPath; }
+ bool IsValidPath()
+ {
+ Manager::Get()->GetLogManager()->DebugLogError(F(_("ProjectDirTraverse searched in %d Dirs and found %d files"), countDirs, countFiles));
+ return m_IsValidPath;
+ }
private:
bool m_IsValidPath;
+ int countFiles;
+ int countDirs;
};
// class constructor
@@ -351,6 +359,7 @@ void cbProject::CalculateCommonTopLevelPath()
wxFileName base = GetBasePath() + sep;
Manager::Get()->GetLogManager()->DebugLog(_T("Project's base path: ") + base.GetFullPath());
+ int traverser_count = 0;
// this loop takes ~30ms for 1000 project files
// it's as fast as it can get, considered that it used to take ~1200ms ;)
// don't even bother making it faster - you can't :)
@@ -385,10 +394,13 @@ void cbProject::CalculateCommonTopLevelPath()
wxDir dir(tmpbaseF.GetPath());
if (dir.IsOpened())
{
+ Manager::Get()->GetLogManager()->DebugLogError(F(_("We call ProjectDirTraverser %d times"), ++traverser_count));
+ wxStopWatch sw;
ProjectDirTraverser traverser;
dir.Traverse(traverser, wxEmptyString, wxDIR_DIRS | wxDIR_FILES);
if (traverser.IsValidPath())
base = tmpbaseF;
+ Manager::Get()->GetLogManager()->DebugLogError(F(_("traversing took %d ms"), (int)sw.Time()));
}
}
}
...Once...
We call ProjectDirTraverser 1 times
traversing took 578 ms
.... Many more...
We call ProjectDirTraverser 1 times
traversing took 146 ms
This is what I get, but this is the second time I load the workspace.
Jens: Do you know a way I can revoke the caches? This is on linux.
... once for the first projects in the workspace...
We call ProjectDirTraverser 1 times
traversing took 20608 ms
.... Many more...
We call ProjectDirTraverser 1 times
traversing took 146 ms
This is the same workspace, after I've dropped the caches with
sync && echo 3 > /proc/sys/vm/drop_caches