Bug 288545 - [Scanner Discovery] Runs way too often
Summary: [Scanner Discovery] Runs way too often
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-build (show other bugs)
Version: 6.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: cdt-build-inbox@eclipse.org CLA
QA Contact: Elena Laskavaia CLA
URL:
Whiteboard:
Keywords:
Depends on: 306708
Blocks:
  Show dependency tree
 
Reported: 2009-09-03 15:20 EDT by Andrew Gvozdev CLA
Modified: 2020-09-04 15:12 EDT (History)
1 user (show)

See Also:


Attachments
patch that improves the number of invocations on project creation (1.62 KB, patch)
2009-11-25 20:15 EST, Chris Recoskie CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Gvozdev CLA 2009-09-03 15:20:13 EDT
Scanner discovery to fetch compiler specs is run 6 times when Hello World project is created (well, with autobuild enabled but anyway). 2 times would be understandable (one for C and one for C++) although no *.c files are in the project. Then it runs again and again when the project is built during regular cycle. I change compiler on a given project very rare if ever and don't want unnecessary delays which are noticeable. Anyway, it is not possible to remove/replace the specs it collected on the first run.
Comment 1 Chris Recoskie CLA 2009-11-09 10:47:00 EST
I have run into this as well.  The problem is all the more compounded when the scanner discovery builds are running remotely.

I will be poking into this in the next week or two.  Have you found out anything interesting yet?
Comment 2 Andrew Gvozdev CLA 2009-11-09 10:57:40 EST
I am frying bigger fish bug 290631 which is redesign of scanner discovery. Having good progress so far. I will probably look at this issue in order not to repeat that mistake at the same time frame but not for legacy stuff. Feel free to take the bug if you have to fix it for older release.
Comment 3 Andrew Gvozdev CLA 2009-11-09 11:04:36 EST
One thing I noticed is that project model is asking for scanner discovery data when .cproject is persisted which triggers scanner discovery build.
Comment 4 Chris Recoskie CLA 2009-11-25 20:15:08 EST
Created attachment 153143 [details]
patch that improves the number of invocations on project creation

The attached patch reduces the number of invocations on project creation to 2 (from about 6).  There was a problem where the discovered data was immediately deleted after creating it, causing it to be recreated again.  I have simply removed the delete.  I am committing this patch to cdt_5_0

The number of invocations on project open is unchanged.

As far as the opening behaviour, what I see is that there are three scanner info context created for my project.  The build system walks the input types of the toolchain and adds a context for each one, a context consisting of a pair of tool and content type.  In the typical case, this means one for the C sources content type, one for the C++ sources content type (both paired with the compiler).  There is a third context that get created, not paired with a tool, but associated with the project root folder.  I am not sure if it is really supposed to be there or not.

Anyway, the scanner discovery builder will build the scanner info for every context that it has.  This means that as intended, there should be three builds.  However, after all three contexts are built, they are built again when something else tries to read the discovered data.

I am not fully sure why the second build happens.  At that point the data should be cached and just looked up.

I have a theory that the caching may be broken due to incorrect nested implementations of equals() and hashcode() in the build model.  The context objects refer to build objects such as the toolchain, and if at any point in the hierarchy of objects that are referred by that in the nested equals() and hashcode() calls doesn't come out the way it should, then that will break the caching, as the cache is just a hashmap.  This would explain the second build, as the system thinks there is no info for the context, and creates it again.

I took a stab at implementing equals() and hashcode() for the contexts, but it didn't seem to help.  I'm not sure if there were problems in equals() and hashcode() for other nested objects that was screwing things up though.  I will try to dig some more when I get time.
Comment 5 Andrew Gvozdev CLA 2010-03-22 23:21:27 EDT
I fixed another side of the puzzle in bug 306708. I think you can port that idea to 5.0 by checking and filtering out all events except FULL_BUILD in ScannerConfigBuilder.build() which overrides IncrementalProjectBuilder.build().
I still think that it is being called too often, and I tend to think that spawning scanner discovery build inside setProjectDescription() is plain wrong.