Bug 437896 - Caching installable units of maven artifacts to avoid expensive re-calculation of MD5 hashes
Summary: Caching installable units of maven artifacts to avoid expensive re-calculatio...
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Tycho (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 461851
Blocks:
  Show dependency tree
 
Reported: 2014-06-23 03:59 EDT by Gábor Lipták CLA
Modified: 2021-04-28 16:51 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gábor Lipták CLA 2014-06-23 03:59:09 EDT
Sorry if I do not use the correct terms sometimes, I am not quite familiar with the P2 dependency management when it comes to programming it.

I work on a project having more than 100 eclipse plugins. I was annoyed by the speed of the "Computing target platform..." part of the build, so I have profiled it once with JProfiler. I have figured out, that if multiple eclipse plugins depend on the same maven artifact, then for this artifact multiple "installable unit" is created, which means multiple MD5 hash caculations, which can be expensive if the artifact is big.

I have implemented a caching of such "installable units", since it is not really likely, that such artifact changes during a build. Please take a look at my changeset at https://github.com/liptga/org.eclipse.tycho/commit/949eb12af118bef05a11920a8084881bdd9ac0df .

If you consider the changes usable, I am ready to contribute those changes as a private person. Please tell me what to do to be able to submit this officially.
Comment 1 Jan Sievers CLA 2014-06-25 04:35:48 EDT
any chance you were using an older tycho version? there was an MD5 performance bug 405716 in p2 which I fixed in Kepler.
Comment 2 Gábor Lipták CLA 2014-06-25 04:46:57 EDT
Originally the improvement was implemented for 0.17.0. Now I have been granted to contribute it as a private person, so I merged it to master.

I took a look at the bug you linked. It might be a non relevant fix anymore, but we could test the performance difference somehow. If some artifacts are big, and inside a reactor multiple projects have them as dependency, it may still make a difference.
Comment 3 Jan Sievers CLA 2014-06-25 04:56:08 EDT
If you have a sample project that still shows a noticeable performance improvement using 0.21.0-SNAPSHOT, we can consider the patch.
Comment 4 Gábor Lipták CLA 2014-06-25 05:06:44 EDT
I will try to make up some...
Comment 5 Gábor Lipták CLA 2014-09-17 06:36:37 EDT
So, I have compared my patched version with the original 0.20.0 version. We have 252 projects, and most of them have dependencies on normal maven artefacts. This comes from our concept, that we have API bundles, which are shared between frontend (RAP) and backend. Those API bundles are the maven artefacts.

If I compare a full "clean install" with using 6 threads for parallel building, then:

- without my patch, so without caching: 4:24
- with caching: 3:47

If I just make a clean with 6 threads (so that basicly nothing happens after calculating dependencies):

- without my patch, so without caching: 1:26
- with caching: 55 seconds

So it seems to make actually a quite big difference in our case. Calculating dependencies became almost 33% faster.

Please apply the patch :)
Comment 6 Jan Sievers CLA 2014-09-17 07:46:41 EDT
(In reply to Gábor Lipták from comment #5)
> If I compare a full "clean install" with using 6 threads for parallel
> building, then:

parallel build is not supported as of now, see bug 380169. Not sure if it helps to use parallel build here if we want to know whether the patch speeds up things. I think parallel build is a different concern.

what I was looking for is a sample project that is public, i.e. everybody has access to it and can compare performance building it with and without your patch. You can either attach a sample project here or e.g. publish one on github or similar.

Tobias, can you comment on https://github.com/liptga/org.eclipse.tycho/commit/949eb12af118bef05a11920a8084881bdd9ac0df ?

>So, I have compared my patched version with the original 0.20.0 version. We 
>have 252 projects, and most of them have dependencies on normal maven >artefacts.

Do you mean you use pomDependencies=consider? Again, a sample project would really help here otherwise it's guesswork for us to reproduce your particular scenario.
Comment 7 Tobias Oberlies CLA 2014-09-17 08:02:59 EDT
(In reply to comment #6)
> Tobias, can you comment on
> https://github.com/liptga/org.eclipse.tycho/commit/949eb12af118bef05a11920a8084881bdd9ac0df
> ?
In principal, caching the results of the pom dependency artifact publishing could make sense. Before I do a closer review, I'd like to ask you to first check the conditions of the Contributor License Agreements [1], and if the change meets the requirements of the CLA, to propose it in Gerrit [2]

[1] https://wiki.eclipse.org/CLA
[2] http://wiki.eclipse.org/Tycho/Contributor_Guide
Comment 8 Gábor Lipták CLA 2014-09-17 08:20:44 EDT
Hmm. Actually the "clean only" test was single threaded. I also think that the calculation of dependencies is always single threaded. On the other hand we use multiple threads for building, since after the single threaded calculation of dependencies it still makes a huge difference to run tests parallel and compile parallel. We do not have any problem with Tycho and parallel builds.

As for setting, in GUI projects we have this setting for Tycho platform:
<plugin>
	<groupId>org.eclipse.tycho</groupId>
	<artifactId>target-platform-configuration</artifactId>
	<version>0.20.777</version>
	<configuration>
		<appArgLine>-nl en</appArgLine>
		<pomDependencies>consider</pomDependencies>
		<dependency-resolution>
			<optionalDependencies>ignore</optionalDependencies>
		</dependency-resolution>
		<environments>
			<environment>
				<os>win32</os>
				<ws>win32</ws>
				<arch>x86</arch>
			</environment>
			<environment>
				<os>win32</os>
				<ws>win32</ws>
				<arch>x86_64</arch>
			</environment>
			<environment>
				<os>linux</os>
				<ws>gtk</ws>
				<arch>x86</arch>
			</environment>
			<environment>
				<os>linux</os>
				<ws>gtk</ws>
				<arch>x86_64</arch>
			</environment>
		</environments>
	</configuration>
</plugin>

So we consider pom dependencies. As far as I understand and I have seen, tycho does not use direct dependencies but only the transitive dependencies. Thats why we have a "gui dependencies" pom project, which has a dependency on all API projects. Then the GUI projects have this "gui-dependencies" as dependency. So we have something like this in our dependency tree:

GUI Project
+gui dependencies
++API project1
++API project2
++API project3

This kind of approach can explain why we have a lot of maven artifacts as dependencies for each GUI project.
Comment 9 Jan Sievers CLA 2014-09-17 08:23:12 EDT
(In reply to Gábor Lipták from comment #8)
> We do not have any problem with Tycho and
> parallel builds.

the fact that you didn't notice race conditions does not mean something is thread-safe :) just saying
Comment 10 Gábor Lipták CLA 2014-09-17 08:29:19 EDT
I have read the CLA, and I have no problem with it. How should I accept it? There is no accept button here : https://www.eclipse.org/legal/CLA.php :)
Comment 11 Gábor Lipták CLA 2014-09-17 08:30:11 EDT
I know. Till now no problems and the performance gain is impressive. So I live with it. As soon as I find some problem, it will be reported :)

(In reply to Jan Sievers from comment #9)
> (In reply to Gábor Lipták from comment #8)
> > We do not have any problem with Tycho and
> > parallel builds.
> 
> the fact that you didn't notice race conditions does not mean something is
> thread-safe :) just saying
Comment 12 Jan Sievers CLA 2014-09-17 08:42:49 EDT
(In reply to Gábor Lipták from comment #10)
> I have read the CLA, and I have no problem with it. How should I accept it?
> There is no accept button here : https://www.eclipse.org/legal/CLA.php :)

https://wiki.eclipse.org/Development_Resources/Contributing_via_Git#Eclipse_Foundation_Contributor_License_Agreement

I also updated https://wiki.eclipse.org/Tycho/Contributor_Guide#Legal_Paperwork  to provide the link
Comment 13 Gábor Lipták CLA 2014-09-17 08:53:36 EDT
CLA is ready. What is next? Should I push the changes to gerrit? I have not used gerrit ever. Could you just pull my changeset from GitHub?
Comment 14 Tobias Oberlies CLA 2014-09-18 06:31:00 EDT
(In reply to comment #13)
> CLA is ready. What is next? Should I push the changes to gerrit? I have not used
> gerrit ever. Could you just pull my changeset from GitHub?

Pushing a change to Gerrit is not hard [1] and it saves us from manually verifying the CLA and running the tests. So please propose your change in this way.

[1] https://wiki.eclipse.org/Tycho/Contributor_Guide#Pushing_to_Gerrit
Comment 15 Gábor Lipták CLA 2014-09-22 05:57:11 EDT
After a bit of suffering with ChangeID and Signing I guess I pushed the changeset. Please take a look at that. Rebased the changeset on current master.
Comment 16 Jan Sievers CLA 2014-09-22 06:57:40 EDT
proposed change is
https://git.eclipse.org/r/#/c/33660/
Comment 17 Gábor Lipták CLA 2015-02-17 03:24:45 EST
Hi Tobias,

I applied your suggestions. Caching is now moved to a separate "service" class, and the cache key is now based only the information delivered by the IArtifactFacade.

Proposed change: https://git.eclipse.org/r/#/c/42006/

It is based on the master from yesterday.

Regards,

Gábor
Comment 18 Gábor Lipták CLA 2015-02-17 04:42:49 EST
Hmm. There is a test failure on your Hudson server. It has built locally fine. I will take a look at that.
Comment 19 Gábor Lipták CLA 2015-02-25 06:35:10 EST
There is a problem in integration tests. I will check it as soon as I have some time.
Comment 20 Tobias Oberlies CLA 2015-03-11 04:41:22 EDT
Gabor, when looking at your change, I wondered why you were caching installable units when you wanted to avoid the MD5 computation. The MD5 sums are not stored in the installable units, but in the artifact descriptors, i.e. the entries in the artifact repository. Of course, when you skip the publishing altogether (due to a cache hit), there is obviously also no artifact repository entry written and hence no MD5 sum computed.

However this is also the issue with the proposed patch: The cache prevents side effects on the object returned by TargetPlatformBundlePublisher(Service).getArtifactRepoOfPublishedBundles. To solve this problem, we'd need to have this method always use the same object for the entire reactor instead of returning a separate instance per reactor project (which would be semantically also correct).

With such a global PublishedBundlesArtifactRepository instance however, there would then be a simpler solution to avoid the MD5 computation. I've proposed this solution here: https://git.eclipse.org/r/#/c/43595/
It doesn't quite work yet, i.e. it doesn't avoid the MD5 re-computation
* because the PublishedBundlesArtifactRepository instance is not global yet, and
* there is a small p2 bug which still would need to be fixed: bug 461851

I'd prefer that we try this simpler solution first, and only if this doesn't solve the performance issue, go for the more complicated bundles publisher cache solution.
Comment 21 Gábor Lipták CLA 2015-03-11 04:52:19 EDT
Tobias,

My proposed solution was simply driven by profiling. I have just found the slow parts and tried to find a point in the code to improve it. Since I do not know Tycho and Maven codebase obviously it is quite difficult for me to understand the architecture (which objects are singletons and so on). 

If you think so, of course we can wait for the other things to be fixed. Meanwhile we can park this ticket.

Regards,

Gábor
Comment 22 Tobias Oberlies CLA 2015-03-11 05:13:39 EDT
The linked p2 bug won't be fixed unless we from the Tycho project fix it. But this shouldn't be a problem because I'm also committer on the p2 project.

So if you want, you could have a look at the p2 bug and see if you can provide a patch. Otherwise, I'll probably also look into this eventually.
Comment 23 Mickael Istria CLA 2021-04-08 18:10:42 EDT
Eclipse Tycho is moving away from this bugs.eclipse.org issue tracker to https://github.com/eclipse/tycho/issues/ instead. If this issue is relevant to you, your action is required.
0. Verify this issue is still happening with latest Tycho 2.4.0-SNAPSHOT
  if issue has disappeared, please change status of this issue to "CLOSED WORKFORME" with some details about your testing environment and how you did verify the issue; and you're done
  if issue is still present when latest release:
* Create a new issue at https://github.com/eclipse/tycho/issues/
  ** Use as title in GitHub the title of this Bugzilla ticket (may include the bug number or not, at your own convenience)
  ** In the GitHub description, start with a link to this bugzilla ticket
  ** Optionally add new content to the description if it can helps towards resolution
  ** Submit GitHub issue
* Update bugzilla ticket
  ** Add to "See also" property (up right column) the link to the newly created GitHub issue
  ** Add a comment "Migrated to <link-to-newly-created-GitHub-issue>"
  ** Set status as CLOSED MOVED
  ** Submit

All issues that remain open will be automatically closed next week or so. Then the Bugzilla component for Tycho will be archived and made read-only.