1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 06:45:43 +02:00
cdt/build/org.eclipse.cdt.managedbuilder.core
Marc-Andre Laperle 9e7b5beaa9 Bug 565553 - Improve performance of build command parsers with large number of files
Cache results of various path resolution algorithms.

Resolving paths is particularly slow while creating entries, see
AbstractLanguageSettingsOutputScanner.createResolvedPathEntry.

There are three main callees within that method that this patch addresses with
a caching approach:

* findContainerForLocationURI: First, this finds containers for a given URI in
the workspace using Eclipse resources API. Then a single container is
selected based on a preferred project. This can done repeatedly for include
paths, which are often similar for source files in a given project or source
folder. This first step is the expensive one and it only depends on one
argument (the URI) and a simple IResource[] return type, so the cache here is
done for this operation. Then the post-filtering is kept as is.

* findFileForLocationURI: Similar to the container case but for files. A
typical projet has much less file paths than folder paths in its options. One
more common option using file paths is -include. The same approach is applied
here as the previous point because there are performance gains but they are
smaller if you consider typical projet setup.

* findBestFitInWorkspace: When a path cannot be found, this makes an attempt to
find the parsed path relative to every folder of the workspace, by starting
first with the preferred project, then its referenced projects and then the
rest. Caching the result of findBestFitInWorkspace itself is too cumbersome
because the result depends on 3 variables (currentProject,
currentCfgDescription and parsedName) which would make a complex cache key.
Instead, caching the result of findPathInFolder at the project level is
sufficient, with little to no performance difference.

In all three cases, the class LRUCache is used in order to limit memory
consumption of the cache. A limit of 100 elements for each cache was chosen
based on experimentation with a few projects like LLVM and projets several
times bigger. A limit higher than necessary for small projects does not incur a
noticeable overhead for small projects and a limit too small for very large
projects merely diminishes the performance gains.

Using LLVM code base as a test, the time to parse options for all files:
Before: 68395ms, after: 5599ms

Change-Id: Ib997e9373087950f9ae6d93bbb1a5f265431c6bc
Signed-off-by: Marc-Andre Laperle <malaperle@gmail.com>
2020-08-03 12:47:18 -04:00
..
.settings Bug 540373: Update the compiler warnings/ignores 2018-11-24 10:55:06 +00:00
META-INF Bug 564272: Increment major version of org.eclipse.cdt.core to 7.0.0 2020-06-13 16:21:05 -04:00
schema Bug 550076 - Use PE64 parser by default 2019-09-09 15:56:07 -04:00
src/org/eclipse/cdt Bug 565553 - Improve performance of build command parsers with large number of files 2020-08-03 12:47:18 -04:00
.classpath Move the rest of the CDT plugins to java 8 2016-06-22 14:51:43 -04:00
.options Add missing buildModel tracing option 2015-10-22 15:24:47 -04:00
.project RESOLVED - bug 273636: changes to enable MBS on EFS projects 2009-04-28 12:02:33 +00:00
about.html Bug 540371: Update to EPLv2 using releng/scripts/change_to_eplv2.sh 2018-11-22 20:31:51 +00:00
build.properties Bug 540373: Cleanup: Remove trailing whitespace in properties files 2018-11-23 07:52:26 +00:00
plugin.properties Bug 548730 - Compilation database (CDB) language settings provider 2019-10-23 21:47:54 -04:00
plugin.xml Bug 548730 - Compilation database (CDB) language settings provider 2019-10-23 21:47:54 -04:00