Bug 568299 - rebuildRequested flag should cancel following build configs execution
Summary: rebuildRequested flag should cancel following build configs execution
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 3.8.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.21 M1   Edit
Assignee: Andrey Loskutov CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2020-10-27 08:18 EDT by Andrey Loskutov CLA
Modified: 2022-03-04 05:47 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Loskutov CLA 2020-10-27 08:18:20 EDT
AS IS: The code in org.eclipse.core.internal.events.BuildManager.basicBuildLoop(IBuildConfiguration[], IBuildConfiguration[], int, MultiStatus, IProgressMonitor) loops over all known build configs independently if a previous build config has requested a rebuild via org.eclipse.core.resources.IncrementalProjectBuilder.needRebuild() (that would then change rebuildRequested to true and restart the build loop).

We see in our build that projects with many builders (== many build configs) after one of the builders detects a case for a rebuild and we actually want to skip the remaining, the remaining builders still run even if they better would wait for preceding builders to be re-triggered, so at the end they run twice instead of running only once.

To be more concrete: we have projects that are setup to invoke those builders in this order:

java builder
custom builder
xtext builder

So if custom builder detects some broken project config (e.g. missing library or wrong JRE version setting etc), it fixes the config and set rebuildRequested flag via needRebuild().

At that point Xtext builder tries to build something before java builder (which is affected by the config change) has a chance to rebuild the project. Of course that ends up in either extra Xtext build efforts for nothing.

TO BE: the proposal would be to check for rebuildRequested inside the loop, before triggering basicBuild() on single config, and continue with the outer loop. So if one builder requests rebuild, following aren't executed before all predecessors re-triggered again.

The code change seem to be trivial, so I wonder if there was a good reason NOT to implement it as proposed from very beginning. Unfortunately I haven't found any hint in the code...

I will push a gerrit to show what I mean shortly, may be we will see tests failing after that that would explain "why it is like it is".
Comment 1 Eclipse Genie CLA 2020-10-27 08:52:22 EDT
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.resources/+/171345
Comment 2 Andrey Loskutov CLA 2020-10-27 12:01:27 EDT
(In reply to Eclipse Genie from comment #1)
> New Gerrit change created:
> https://git.eclipse.org/r/c/platform/eclipse.platform.resources/+/171345

Surprisingly, that succeeded, means, no one tried to play with multiple build configs or at least to validate current behavior. This doesn't mean the patch is valid, I just want to document current state here.

What I would propose now is to introduce a new system property and change the patch accordingly to exit inner loop earlier if the flag is set.

We could test it with the SDK build then and collect empirical evidence if there are builders around (Xtext?) that don't expect such "fast" inner build loop.
Comment 4 Eclipse Genie CLA 2021-06-01 04:39:46 EDT
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.resources/+/181209
Comment 6 Eclipse Genie CLA 2021-06-14 05:25:45 EDT
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.resources/+/181910
Comment 7 Eclipse Genie CLA 2021-06-15 03:07:50 EDT
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.resources/+/181960