JBoss Developer: Message List - Improving the MavenDependency PerformanceMost recent forum messageshttps://developer.jboss.org/community/shrinkwrap/dev?view=discussionsJive Engage2013-02-06T17:40:05Z2013-02-06T17:40:05ZenRe: Improving the MavenDependency PerformanceMichal Matloka/people/mmatlokado-not-reply@jboss.com2013-02-06T17:40:05Z2013-02-06T17:40:05Z<!-- [DocumentBodyStart:b0852bfb-eecc-447c-b7ec-489daa1fc17a] --><div class="jive-rendered-content"><p>I've performed a few optimizations of ClasspathWorkspaceReader. </p><ul><li>Already mentioned reuse of DocumentBuilder and XPath</li><li>XPath query compilation to XPathExpression</li><li>Retrieved from classpath artifacts caching</li><li>Reduction of number of disk operations (every classpath entry for every retrieved artifact performed disk isFile/isDirectory operations + same thing for found pom files) </li></ul><p style="min-height: 8pt; height: 8pt; padding: 0px;">&nbsp;</p><p>I've performed tests basing on forge core\javaee-impl\pom.xml (136 retrieved dependencies). Before changes on my PC running</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&nbsp;</p><blockquote class="jive-quote"><p> Maven.resolver().loadPomFromFile(pom).importRuntimeDependencies().asFile();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&nbsp;</p></blockquote><p>took about 32s. After mentioned optimizations ~1,5s.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&nbsp;</p><p><span>Code is available here: </span><a class="jive-link-external-small" href="https://github.com/shrinkwrap/resolver/pull/35" target="_blank">https://github.com/shrinkwrap/resolver/pull/35</a></p></div><!-- [DocumentBodyEnd:b0852bfb-eecc-447c-b7ec-489daa1fc17a] --><img src='/beacon?t=1427839956860' />2013-02-06T17:40:05Z2 years 2 months ago0Re: Improving the MavenDependency PerformanceLukáš Fryč/people/lfrycdo-not-reply@jboss.com2012-06-21T11:02:42Z2012-06-21T10:39:07Z<!-- [DocumentBodyStart:3ceb83e0-85ea-496c-86ef-9bcd929bf4c6] --><div class="jive-rendered-content"><blockquote class="jive-quote"><p>Vineet Reynolds wrote:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&nbsp;</p><p>Also, if we would solve this with a cache, we need to ensure that the cache would be re-used across tests, since it would help immensely when multiple @Deployments in different tests use the same Maven artifact.</p></blockquote><p>This is <strong>good point </strong>- and good use case for <strong>arquillian core</strong> - I use caching in form of serialized objects in Drone reusable webdriver sessions - when it would be part of core, all projects can cache through unified interface.</p></div><!-- [DocumentBodyEnd:3ceb83e0-85ea-496c-86ef-9bcd929bf4c6] -->2012-06-21T10:39:07Z2 years 9 months ago0Re: Improving the MavenDependency PerformanceAslak Knutsen/people/aslakdo-not-reply@jboss.com2012-05-28T14:14:22Z2012-05-28T14:14:22Z<!-- [DocumentBodyStart:b151e501-9dfd-4944-8e77-f5745e621f80] --><div class="jive-rendered-content"><p>Another possible optimalization that came to mind is, in the case where you're not resolving trasitive deps:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&nbsp;</p><p>We could start by by-passing the Aether lib all togather(not even initialize anything from it) and do a simple check if the artifact exist in the local repo, if it does simply return that File. If it doesn't exist, or you're resolving transitive deps, fall back to use Aether. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&nbsp;</p><p>In theory we would only need to run Aether the first time you depend on a non existing Artifact to have it download, all the following runs on the same machine will simple just resolve GAV to File via Path concats.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&nbsp;</p><p>To speed up transitive deps, we could cache the resolved GAVs for a specific Artifact combination. No cache hit, fall back to Aether, cache hit found, do a simple GAV to File resolve. </p></div><!-- [DocumentBodyEnd:b151e501-9dfd-4944-8e77-f5745e621f80] -->2012-05-28T14:14:22Z2 years 10 months ago0Re: Improving the MavenDependency PerformanceKarel Piwko/people/kpiwkodo-not-reply@jboss.com2012-04-22T11:00:58Z2012-04-22T11:00:58Z<!-- [DocumentBodyStart:0f2d67ed-ada7-4fde-998c-66e1da92270f] --><div class="jive-rendered-content"><p>To be tracked as <a class="jive-link-external-small" href="https://issues.jboss.org/browse/SHRINKRES-37" rel="nofollow">https://issues.jboss.org/browse/SHRINKRES-37</a></p></div><!-- [DocumentBodyEnd:0f2d67ed-ada7-4fde-998c-66e1da92270f] -->2012-04-22T11:00:58Z2 years 11 months ago10Re: Improving the MavenDependency PerformanceVineet Reynolds/people/vineet.reynoldsdo-not-reply@jboss.com2012-04-20T17:33:45Z2012-04-20T17:33:45Z<!-- [DocumentBodyStart:80d3174b-78a9-4036-a503-34455a602bbf] --><div class="jive-rendered-content"><p>I wasn't sure if this came out correctly in the above observations - using a class-member DocumentBuildFactory and XPathFactory, and compiled XPath expressions did not improve performance as much as I liked. This is more so because XPath expression evaluation is expensive, and when repeated across large number of invocations, the use of a compiled expression does not help a lot. Now, given that most of these lookups are duplicates, we need to find some way to cache the results, or we need to prevent the invocations with the duplicate artifacts.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&nbsp;</p><p>Also, if we would solve this with a cache, we need to ensure that the cache would be re-used across tests, since it would help immensely when multiple @Deployments in different tests use the same Maven artifact.</p></div><!-- [DocumentBodyEnd:80d3174b-78a9-4036-a503-34455a602bbf] -->2012-04-20T17:33:45Z2 years 11 months ago10Improving the MavenDependency PerformanceAndrew Rubinger/people/alrubingerdo-not-reply@jboss.com2012-04-20T15:43:47Z2012-04-20T15:43:47Z<!-- [DocumentBodyStart:751f4d5d-92e9-4432-a677-59547c400df0] --><div class="jive-rendered-content"><p>The following observation was kicked off by <a class="jiveTT-hover-user jive-link-profile-small" data-containerId="-1" data-containerType="-1" data-objectId="89652" data-objectType="3" href="https://developer.jboss.org/people/vineet.reynolds">Vineet Reynolds</a>:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&nbsp;</p><blockquote class="jive-quote"><p>&nbsp;&nbsp;&nbsp; I've spent sometime profiling a "slow" test of mine in a project that uses Seam Security. The deployment is created using the Maven Dependency resolver (2.0.0.-alpha-1), and it looks like there is scope for improving the performance of this resolver, given that creation of the deployment takes up roughly 20 seconds (wall clock time) in a test that lasts ~40 seconds.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&nbsp;</p><p>&nbsp;&nbsp;&nbsp; The hotspot appears to be ClasspathWorkspaceReader which is not only invoked multiple times (1779 in my test), but also features heavily in the "own time" stats (216s spent in this method out of 217s contributed to overall execution time by this method; I've sampled every method invocation, so the profiled times are slower). The DefaultArtifact constructor is also invoked 1.4k+ times, but doesn't contribute heavily to the consumed time (800ms or so). I haven't got any more useful information regarding the cause, since the profiler hasn't picked up anything, but I suspect it is due to the method-local DocumentBuilderFactory and XPathFactory instances being created. But, I think you would know Aether better than me, so I'd like to have your inputs in improving this class before I submit a pull request.</p></blockquote><p>...additionally:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&nbsp;</p><blockquote class="jive-quote"><p>By the way, I did manage to improve the performance a bit -&nbsp; the XPath query evaluation did take some time, but then the WorkspaceReader is being hit 1.7k times, so it didn't help much - wall clock time for the tests reduced from 38s to 34s. I logged the info about the artifacts being requested, and it turns out that there are duplicates among the parameters, so we need some form of a cache to improve performance. Maybe not a cache that we should manage, but one of Aether - which is why I think I need more feedback here.</p></blockquote><p style="min-height: 8pt; height: 8pt; padding: 0px;">&nbsp;</p><p>S,</p><p>ALR</p></div><!-- [DocumentBodyEnd:751f4d5d-92e9-4432-a677-59547c400df0] -->2012-04-20T15:43:47Z2 years 11 months ago50