User forums > Using Code::Blocks

changes between r7459 and r7460 slow down project load

<< < (2/4) > >>

cbnewbie:
I attached parts of a log file where just the number of loaded files per project and your ProjectDirTraverser output is listed. As you can see traversing is terribly slow...

I am using manually patched "svn build rev 7520 (2011-10-22 10:29:36) gcc 4.4.3 Linux/unicode - 64 bit"

Jenna:

--- Quote from: cbnewbie on October 28, 2011, 01:15:32 pm ---I attached parts of a log file where just the number of loaded files per project and your ProjectDirTraverser output is listed. As you can see traversing is terribly slow...

I am using manually patched "svn build rev 7520 (2011-10-22 10:29:36) gcc 4.4.3 Linux/unicode - 64 bit"


--- End quote ---
Can you provide a test project, where it is so slow.

I also added a counter for files and dirs touched by the traverser and this is my output for the linux kernel 2.6.35 with a project-file deep in the source tree (just for testing):

--- Quote ---33115 files loaded
Done loading project in 4460ms
Project's base path: /home/jens/kernel-tmp.2.6.35/linux-source-2.6.35/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/test-kernel-deep/
We call ProjectDirTraverser 1 times
ProjectDirTraverse searched in 1998 Dirs and found 33117 files
traversing took 539 ms

--- End quote ---

CodeCompletion is disabled and I use a patch to enhance load-speed, but it does not affect the traverser, just the project loading time decreases a lot.

Jenna:
Here is the patch I used:

--- Code: ---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()));
             }
         }
     }
--- End code ---

oBFusCATed:

--- Code: ---...Once...
We call ProjectDirTraverser 1 times
traversing took 578 ms
.... Many more...
We call ProjectDirTraverser 1 times
traversing took 146 ms

--- End code ---
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.

oBFusCATed:

--- Code: ---... 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

--- End code ---
This is the same workspace, after I've dropped the caches with

--- Code: ---sync && echo 3 > /proc/sys/vm/drop_caches

--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version