Bug 576736 - Run API analysis in a job
Summary: Run API analysis in a job
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: API Tools (show other bugs)
Version: 4.22   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: 4.23 M2   Edit
Assignee: Andrey Loskutov CLA
QA Contact:
URL:
Whiteboard:
Keywords: noteworthy
Depends on: 578243 578386
Blocks: 578093
  Show dependency tree
 
Reported: 2021-10-19 08:41 EDT by Andrey Loskutov CLA
Modified: 2022-03-30 09:29 EDT (History)
3 users (show)

See Also:


Attachments
new option added (disabled by default) (109.94 KB, image/png)
2022-01-11 04:36 EST, Andrey Loskutov CLA
no flags Details
In one of the attempts, things seemed to get stuck (13.14 KB, image/png)
2022-01-12 07:30 EST, Vikas Chandra CLA
no flags Details
Another error (103.87 KB, image/png)
2022-01-12 09:00 EST, Vikas Chandra CLA
no flags Details
pre and post gerrit 189673 (149.24 KB, image/png)
2022-01-15 06:17 EST, Vikas Chandra CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Loskutov CLA 2021-10-19 08:41:24 EDT
API analysis is great thing, but it costs time. I think the builder can run in parallel, after the Java builder, ideally it can "hide" analysis time if main build still runs for other projects.

I have POC, and it seems to work, the time for my clean workspace build reduces from ~2 minutes to ~1.5. I will push a patch for discussion.
Comment 1 Eclipse Genie CLA 2021-10-19 08:43:08 EDT
New Gerrit change created: https://git.eclipse.org/r/c/pde/eclipse.pde.ui/+/186655
Comment 3 Andrey Loskutov CLA 2022-01-11 04:36:10 EST
Created attachment 287808 [details]
new option added (disabled by default)
Comment 4 Mickael Istria CLA 2022-01-11 08:22:42 EST
IMO, this new option should be turned on by default, or even no option should be given.
Comment 5 Andrey Loskutov CLA 2022-01-11 08:25:47 EST
(In reply to Mickael Istria from comment #4)
> IMO, this new option should be turned on by default, or even no option
> should be given.

Consider current state as experimental. I will switch option next week, if no major issues with new code will be reported. Similar, if we will get no reports later we may hide it completely from UI or evem remove.
Comment 6 Mickael Istria CLA 2022-01-11 08:33:48 EST
(In reply to Andrey Loskutov from comment #5)
> Consider current state as experimental.

That's why I suggest forcing this experiment on from now on, to make sure people actually try it ;)
But I'm fine with your plan as it is now.
Comment 7 Eclipse Genie CLA 2022-01-11 13:04:54 EST
New Gerrit change created: https://git.eclipse.org/r/c/pde/eclipse.pde.ui/+/189484
Comment 8 Eclipse Genie CLA 2022-01-11 13:04:57 EST
New Gerrit change created: https://git.eclipse.org/r/c/pde/eclipse.pde.ui/+/189485
Comment 10 Niraj Modi CLA 2022-01-12 04:19:59 EST
Overall very nice, Thanks!

Possible improvements I notice:
1. In my test with workspace clean, when multiple jobs are spanned, it would be good if 'build' job stays on top(and not getting moved below as it started first)
2. Since we run multiple jobs(for API analysis) we can update test option as:
"Run API analysis builder as multiple jobs"
Comment 11 Vikas Chandra CLA 2022-01-12 07:30:11 EST
Created attachment 287822 [details]
In one of the attempts, things seemed to get stuck

Steps:

1) Take all pde plugins ( except test plugins and nested projects)
2) Set no baseline
3) Missing baseline ->Error
4) Set the option of "Run API analysis as a job" as on.
5) Clean->Build All


Note: When no baseline is set, API analysis still does analysis like API leaks ( for which it needs no baseline). Also it outputs "Missing baseline" problems in all API enabled projects.

When I tried to recreate, this didn't reoccur.
Comment 12 Andrey Loskutov CLA 2022-01-12 07:41:10 EST
(In reply to Vikas Chandra from comment #11)
> Created attachment 287822 [details]
> In one of the attempts, things seemed to get stuck

Please next time create jstack thread dump from Eclipse. Could be a deadlock but could be some error happened - btw, any errors in the log?
Comment 13 Vikas Chandra CLA 2022-01-12 07:47:27 EST
(In reply to Andrey Loskutov from comment #12)
> (In reply to Vikas Chandra from comment #11)
> > Created attachment 287822 [details]
> > In one of the attempts, things seemed to get stuck
> 
> Please next time create jstack thread dump from Eclipse. Could be a deadlock
> but could be some error happened - btw, any errors in the log?

Nothing in the error log !
Comment 14 Vikas Chandra CLA 2022-01-12 09:00:01 EST
Created attachment 287824 [details]
Another error

I re-launched eclipse into workspace with PDE plugins. "Run API analysis as job" option was on.
Comment 15 Vikas Chandra CLA 2022-01-12 09:01:04 EST
!MESSAGE File not found: C:\Users\VIKASCHANDRA\git\eclipse.pde.ui\ds\org.eclipse.pde.ds.ui\bin\org\eclipse\pde\internal\ds\ui\wizards\DSFileWizardPage$2.class.
!STACK 0
java.lang.Exception: File not found: C:\Users\VIKASCHANDRA\git\eclipse.pde.ui\ds\org.eclipse.pde.ds.ui\bin\org\eclipse\pde\internal\ds\ui\wizards\DSFileWizardPage$2.class.
	at org.eclipse.core.internal.resources.ResourceException.provideStackTrace(ResourceException.java:42)
	at org.eclipse.core.internal.resources.ResourceException.<init>(ResourceException.java:38)
	at org.eclipse.core.internal.localstore.FileSystemResourceManager.read(FileSystemResourceManager.java:835)
	at org.eclipse.core.internal.resources.File.getContents(File.java:275)
	at org.eclipse.pde.api.tools.internal.model.ResourceApiTypeRoot.getContents(ResourceApiTypeRoot.java:62)
	at org.eclipse.pde.api.tools.internal.model.AbstractApiTypeRoot.getStructure(AbstractApiTypeRoot.java:62)
Comment 16 Andrey Loskutov CLA 2022-01-12 09:12:16 EST
(In reply to Niraj Modi from comment #10)
> Possible improvements I notice:
> 1. In my test with workspace clean, when multiple jobs are spanned, it would
> be good if 'build' job stays on top(and not getting moved below as it
> started first)

I *guess* this is because of the "A" in the job name that gets this entry sorted before the "B" in the build job. What about "Performing API Analysis" instead of "API Analysis Builder"?

> 2. Since we run multiple jobs(for API analysis) we can update test option as:
> "Run API analysis builder as multiple jobs"

What about this:

"Run API analysis parallel to the build job" ?
Comment 17 Andrey Loskutov CLA 2022-01-12 09:24:32 EST
(In reply to Vikas Chandra from comment #15)
> !MESSAGE File not found:
> C:\Users\VIKASCHANDRA\git\eclipse.pde.ui\ds\org.eclipse.pde.ds.
> ui\bin\org\eclipse\pde\internal\ds\ui\wizards\DSFileWizardPage$2.class.

This is most likely because we don't hold workspace lock anymore while API build is runnning, and once the JDT build decides to build project again *while* previously started API analysis is still running, we might see this.

I didn't wanted to take workspace lock for a simple reason - I believe JDT build still uses workspace root as build rule, so all API jobs would need to run *after* the main build for all projects is done (so we would not use idling CPU cores) *and* they will still block the IDE if running. I wonder if we check for that and restart the job on such errors? Schouldn't happen very often, and because they would still not hold workspace locks, they should not be blocking for other tasks.
Comment 18 Vikas Chandra CLA 2022-01-12 10:44:01 EST
(In reply to Andrey Loskutov from comment #16)
> (In reply to Niraj Modi from comment #10)
> > Possible improvements I notice:
> > 1. In my test with workspace clean, when multiple jobs are spanned, it would
> > be good if 'build' job stays on top(and not getting moved below as it
> > started first)
> 
> I *guess* this is because of the "A" in the job name that gets this entry
> sorted before the "B" in the build job. What about "Performing API Analysis"
> instead of "API Analysis Builder"?
> 
> > 2. Since we run multiple jobs(for API analysis) we can update test option as:
> > "Run API analysis builder as multiple jobs"
> 
> What about this:
> 
> "Run API analysis parallel to the build job" ?

May be it is better if we club all API analysis jobs in a single group during display in progress view? May be setProgressGroup can help. But as of now, it is not that important. Just a name change in preference could suffice as of now.
Comment 19 Eclipse Genie CLA 2022-01-12 11:26:11 EST
New Gerrit change created: https://git.eclipse.org/r/c/pde/eclipse.pde.ui/+/189550
Comment 20 Eclipse Genie CLA 2022-01-12 11:26:13 EST
New Gerrit change created: https://git.eclipse.org/r/c/pde/eclipse.pde.ui/+/189551
Comment 23 Eclipse Genie CLA 2022-01-12 14:11:27 EST
New Gerrit change created: https://git.eclipse.org/r/c/pde/eclipse.pde.ui/+/189559
Comment 25 Andrey Loskutov CLA 2022-01-13 03:08:21 EST
(In reply to Andrey Loskutov from comment #16)
> (In reply to Niraj Modi from comment #10)
> > Possible improvements I notice:
> > 1. In my test with workspace clean, when multiple jobs are spanned, it would
> > be good if 'build' job stays on top(and not getting moved below as it
> > started first)
> 
> I *guess* this is because of the "A" in the job name that gets this entry
> sorted before the "B" in the build job.

Nope. Changed the job name, but still the "build" job doesn't stay on top. Must be something else there, I don't see a way how Progress view can be instructed to keep the "build" entry pinned on top.

(In reply to Vikas Chandra from comment #18)
> May be it is better if we club all API analysis jobs in a single group
> during display in progress view? May be setProgressGroup can help.

Because the project builder code doesn't know anything outside the project scope of the build (how many other jobs are triggered on which projects), there is no simple solution for that - a job group should be created / updated on one central place. One could probably add some global "Analysis" job group in PDE UI plugin that could be reused by all analysis jobs for all builds.
Comment 26 Eclipse Genie CLA 2022-01-13 09:30:55 EST
New Gerrit change created: https://git.eclipse.org/r/c/pde/eclipse.pde.ui/+/189596
Comment 27 Vikas Chandra CLA 2022-01-13 09:36:07 EST
(In reply to Eclipse Genie from comment #26)
> New Gerrit change created:
> https://git.eclipse.org/r/c/pde/eclipse.pde.ui/+/189596

Ensuring ApiAnalysisJob to have a priority of DECORATE ensures that build is always on top. 

Snippet from doc
" Decoration jobs generally compute extra information that the user may be interested in seeing"

This looks good for API analysis.

@Andrey what do you think?
Comment 28 Andrey Loskutov CLA 2022-01-13 09:45:34 EST
(In reply to Vikas Chandra from comment #27)
> This looks good for API analysis.
> 
> @Andrey what do you think?

Sure, great idea, I was not aware the entries were sorted by priority, and the low prio is absolutely OK here.
Comment 30 Andrey Loskutov CLA 2022-01-13 11:01:39 EST
Just found a new issue with the jobs - livelock in OverflowingLRUCache, see bug 578204.
Comment 31 Eclipse Genie CLA 2022-01-15 06:13:45 EST
New Gerrit change created: https://git.eclipse.org/r/c/pde/eclipse.pde.ui/+/189673
Comment 32 Vikas Chandra CLA 2022-01-15 06:17:12 EST
Created attachment 287840 [details]
pre and post gerrit 189673
Comment 34 Eclipse Genie CLA 2022-01-15 06:51:13 EST
New Gerrit change created: https://git.eclipse.org/r/c/pde/eclipse.pde.ui/+/189674
Comment 37 Vikas Chandra CLA 2022-01-20 06:40:31 EST
If this preference has to stay for few releases, we can consider clubbing the 2 API analysis preference in a group ( similar to Test plug-in detection)
Comment 38 Vikas Chandra CLA 2022-01-24 11:55:08 EST
Andrey, can this be resolved? We probably need a N&N item for this.
Comment 39 Eclipse Genie CLA 2022-01-26 12:28:05 EST
New Gerrit change created: https://git.eclipse.org/r/c/www.eclipse.org/eclipse/news/+/190055
Comment 41 Andrey Loskutov CLA 2022-01-26 13:25:13 EST
(In reply to Vikas Chandra from comment #38)
> Andrey, can this be resolved? 

I've just pushed a fix for bug 578386, will see tomorrow if there are more issues or regressions and resolve otherwise.

> We probably need a N&N item for this.

Done