User forums > Using Code::Blocks

Bug Report: [#18755] C::B hangs for 20 seconds while opening large project...

<< < (17/20) > >>

rickg22:
OK guys, I found another bottleneck in project loading!


--- Code: ---ProjectFile* cbProject::AddFile(int targetIndex, const wxString& filename, bool compile, bool link, unsigned short int /*weight*/)
{
...
if (!wxFileExists(fullFilename))
pf->SetFileState(fvsMissing);
else if (!wxFile::Access(fullFilename.c_str(), wxFile::write)) // readonly
pf->SetFileState(fvsReadOnly);

--- End code ---

In other words, C::B checks for the existence of ALL the project files on load! Just to set the little "broken" or readonly flags on the project tree.  Imagine doing this for a ten-thousand-files java project where you only got to modify the configuration -_-.

I changed it to this:


--- Code: ---namespace cbProjectAuxVariables {
bool check_for_existence_of_files = true;
};

...

ProjectFile* cbProject::AddFile(int targetIndex, const wxString& filename, bool compile, bool link, unsigned short int /*weight*/)
{
...

// Check for the file's status if the User chose to in the Environment settings dialog;
// or if the file is being added manually and not as part of the project loading.
    if(!m_CurrentlyLoading || cbProjectAuxVariables::check_for_existence_of_files) {
if (!wxFileExists(fullFilename))
pf->SetFileState(fvsMissing);
else if (!wxFile::Access(fullFilename.c_str(), wxFile::write)) // readonly
pf->SetFileState(fvsReadOnly);
    }


--- End code ---

cbProjectAuxVariables::check_for_existence_of_files is modified on project load by checking a new Environment setting:


--- Code: ---<object class="sizeritem">
<object class="wxCheckBox" name="chkMissingFilesOnLoad">
<label>Check for missing files on project load</label>
<tooltip>When checked, Code::Blocks will check that all the project files exist,&#x0A;and update their status on the Project Tree.&#x0A;Useful at times, but slower for very large projects.</tooltip>
<checked>1</checked>
</object>
<flag>wxTOP|wxLEFT|wxEXPAND|wxALIGN_LEFT|wxALIGN_TOP</flag>
<border>8</border>
</object>

--- End code ---

And here's the result, with my previous patch and the file checking on load disabled:


--- Code: ---1927 files loaded
Done loading project in 365ms
Project's base path: C:\htdocs\SIG\SGPG\
C:\projects\cb\src\sdk\cbproject.cpp::void cbProject::CalculateCommonTopLevelPath():539  took : 50 ms
Project's common toplevel path: C:\htdocs\SIG\SGPG\
C:\projects\cb\src\sdk\cbproject.cpp::void cbProject::CalculateCommonTopLevelPath():579  took : 130 ms
C:\projects\cb\src\sdk\cbproject.cpp::void cbProject::CalculateCommonTopLevelPath():580: Num Files: 1927; Num Cache Misses: 0

--- End code ---

(Total project loading time: 2.50s)  8) ;D 8) ;D 8)

I'm attaching the full patch, including my previous changes. Enjoy.

[attachment deleted by admin]

dmoore:

--- Quote from: rickg22 on November 03, 2012, 03:33:25 pm ---Hmm... maybe that code will make my patch redundant, but I like having a separate cache for relative paths. It could become useful later, and it does separate all the path checking.

--- End quote ---

Even if we do use the cache, it would make sense to use the logic to create the path (and add it to the cache) when there are cache missses to reduce the number of MakeRelativeTo calls.

dmoore:

--- Quote from: rickg22 on November 03, 2012, 03:40:04 pm ---OK guys, I found another bottleneck in project loading!

--- End quote ---

Another good catch. But instead of having an environment setting, why not make this a project setting and/or offer an annoying dialog for projects with a file count above a certain size to disable the check for the project? In general, I would think that if you have one big project open and some smaller ones open, you would still want the checks on the smaller projects.

rickg22:
Actually, I was thinking on moving the whole file checking stuff to an event triggered by opening a node in the project tree. In the meantime, I think that having a user-modifiable setting will suffice. Users accustomed to having small projects won't bother changing the setting (which defaults to 'always check'), and users accustomed to large projects are free to trade between load speed and file checking.

We could also add a treshold number to define small and large projects (i.e. 100, 200 files?). In any case, at least now we have a choice. We can refine it later in further commits.

rickg22:

--- Quote from: dmoore on November 03, 2012, 06:31:22 pm ---
Even if we do use the cache, it would make sense to use the logic to create the path (and add it to the cache) when there are cache missses to reduce the number of MakeRelativeTo calls.

--- End quote ---

Yes, that's exactly what the cache does. Everytime it doesn't find a path, it creates it in memory and adds it to the list; (with the exception of files outside the base path i.e. the Common Top Level Path, because otherwise we could run in the risk of adding a parent path to the whole tree; actually, I think that extra check is unnecessary; we could cache external paths without problem, but we'd need to do some tests after disabling that check.)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version