Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-dev] [jetty-users] Maven Jetty Plugin Slow with Java8

Hi there,

i've opened a ticket to webjars to exclude the irrelevant content from the webjar. But until then I need some solution and according to you guys the problem is not in jetty. Can you give me some guidance where it might be?
Also I don't think the problem is in the jar itself. On my machine unzipping took less than 6 seconds:

petar@petar-ThinkPad-X1-Carbon:~/.m2/repository/org/webjars/extjs/5.1.0$ date
сб апр 18 16:17:16 EEST 2015
petar@petar-ThinkPad-X1-Carbon:~/.m2/repository/org/webjars/extjs/5.1.0$ $JAVA_HOME/bin/jar -xf extjs-5.1.0.jar
petar@petar-ThinkPad-X1-Carbon:~/.m2/repository/org/webjars/extjs/5.1.0$ date
сб апр 18 16:17:22 EEST 2015
petar@petar-ThinkPad-X1-Carbon:~/.m2/repository/org/webjars/extjs/5.1.0$

Thank you for your effort.




2015-04-18 15:00 GMT+03:00 Petar Tahchiev <paranoiabla@xxxxxxxxx>:
I do understand that this is all according to the specification, but is there any way to exclude the jar from being scanned? It's really just an 85MB webjar with _javascript_ and css...

2015-04-17 1:50 GMT+03:00 Joakim Erdfelt <joakim@xxxxxxxxxxx>:
Jetty 9.1.3 isn't using Servlet 3.1, that's still on Servlet 3.0

While Servlet 3.0 introduced support for META-INF/resources/, it was a poor part of the spec until Servlet 3.1.
Jetty technically had support for META-INF/resources/ since Jetty 8, but it was based on the early poor spec, and was kept as simple as possible.
The Servlet 3.1 changes in Jetty 9.2 fixed our support to be more correct with the updated clarifications on META-INF/resources/

In your Java7 and Jetty 9.1.3 version, those resources are served in the most convoluted and inefficient way you can imagine.
For each request of content in META-INF/resources/, the content is uncompressed from a twice deep (nested) JarFile reference (every time).


--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts

On Thu, Apr 16, 2015 at 3:42 PM, Petar Tahchiev <paranoiabla@xxxxxxxxx> wrote:
Thanks for the response.

I'll give it a try.The really interesting thing is that this was working perfectly fine on Java7 and jetty 9.1.3.v20140225 (in fact some of my colleagues are still using that and I've told them not to make a git pull before i fix this).

2015-04-17 1:34 GMT+03:00 Joakim Erdfelt <joakim@xxxxxxxxxxx>:
Its something with the extjs-5.1.0.jar  if you eliminate that as a dependency, then the startup / scan is near instantaneous.
Wonder if that's a bad jar file?
Or if java's java.util.jar.JarFile has issues with the the extjs-5.1.0.jar?

Out of curiosity, why are you including an 81MB jar file full of META-INF/resources/ provided _javascript_ examples in the classpath of your WAR?
Its not like anything can make use of that as it is.

What I haven't tested is the new servlet 3.1 META-INF/resources/ logic.
That requires us to unpack the JAR files in WEB-INF/lib that have META-INF/resources/ into a temporary directory.

Using command line ...

$ jar -xf extjs-5.1.0.jar 

that takes 3 minutes on my machine. (way way too long)
I'm suspicious of that file now.

OK, how about you unpack that jar into your src/main/webapp (stripping the META-INF/resources/ prefixes) during your build instead.
The dependency plugin might be able to handle that (during the generate-resources phase).
Tho the stripping of the prefix might need a secondary step with the assembly plugin (or careful manipulation of the maven-resources-plugin configuration, or <resources> entries)

That will give you the same end result, but without the negative impact of how META-INF/resources/ works during startup


--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts

On Thu, Apr 16, 2015 at 3:14 PM, Joakim Erdfelt <joakim@xxxxxxxxxxx> wrote:
The scanning can be improved.
Here's my results (with debug logging turned on)

2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar in 74ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.1/taglibs-standard-impl-1.2.1.jar in 92ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/Code/git/jetty-slow-startup/target/classes/ in 29ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.4.5/jackson-annotations-2.4.5.jar in 66ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar in 188ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar in 13ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.4.5/jackson-databind-2.4.5.jar in 384ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.4.5/jackson-core-2.4.5.jar in 92ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/.m2/repository/org/springframework/security/spring-security-taglibs/3.2.7.RELEASE/spring-security-taglibs-3.2.7.RELEASE.jar in 20ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/.m2/repository/org/springframework/security/spring-security-acl/3.2.7.RELEASE/spring-security-acl-3.2.7.RELEASE.jar in 68ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/.m2/repository/org/springframework/spring-jdbc/4.1.6.RELEASE/spring-jdbc-4.1.6.RELEASE.jar in 205ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/.m2/repository/org/springframework/spring-tx/4.1.6.RELEASE/spring-tx-4.1.6.RELEASE.jar in 147ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/.m2/repository/org/springframework/security/spring-security-core/3.2.7.RELEASE/spring-security-core-3.2.7.RELEASE.jar in 223ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/.m2/repository/org/springframework/spring-aop/4.1.6.RELEASE/spring-aop-4.1.6.RELEASE.jar in 131ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/.m2/repository/org/springframework/spring-beans/4.1.6.RELEASE/spring-beans-4.1.6.RELEASE.jar in 272ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/.m2/repository/org/springframework/spring-_expression_/4.1.6.RELEASE/spring-_expression_-4.1.6.RELEASE.jar in 99ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/.m2/repository/org/springframework/security/spring-security-web/3.2.7.RELEASE/spring-security-web-3.2.7.RELEASE.jar in 149ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar in 4ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/.m2/repository/org/springframework/security/spring-security-config/3.2.7.RELEASE/spring-security-config-3.2.7.RELEASE.jar in 140ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/.m2/repository/org/springframework/spring-webmvc/4.1.6.RELEASE/spring-webmvc-4.1.6.RELEASE.jar in 211ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/.m2/repository/org/springframework/spring-web/4.1.6.RELEASE/spring-web-4.1.6.RELEASE.jar in 180ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/.m2/repository/org/springframework/spring-context/4.1.6.RELEASE/spring-context-4.1.6.RELEASE.jar in 243ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/.m2/repository/org/springframework/spring-core/4.1.6.RELEASE/spring-core-4.1.6.RELEASE.jar in 188ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned file:/Users/joakim/.m2/repository/org/webjars/extjs/5.1.0/extjs-5.1.0.jar in 1981ms
2015-04-16 15:05:11.418:DBUG:oeja.AnnotationConfiguration:main: Scanned 2 container path jars, 21 WEB-INF/lib jars, 1 WEB-INF/classes dirs in 2321ms for context o.e.j.m.p.JettyWebAppContext@57fbc06f{/backend,[file:/Users/joakim/Code/git/jetty-slow-startup/src/main/webapp/, jar:file:/Users/joakim/.m2/repository/org/webjars/extjs/5.1.0/extjs-5.1.0.jar!/META-INF/resources],STARTING}{file:/Users/joakim/Code/git/jetty-slow-startup/src/main/webapp/}

This is on OSX, using Java 8u31.
The extjs-5.1.0.jar only took a scant 2 seconds to scan.
The scan ignored most (if not all) of that jar's contents anyway (no *.class files).
Overall, the scan took 2321ms

The startup, on the other hand, took longer.   About 4 minutes.
The problem is likely somewhere else.  Not sure yet.
I haven't turned on the logging for the spring bytecode scanning yet to know if that's where the time is going.
This environment has a mix of logging infrastructure (commons logging, java.util.logging, jetty logging, log4j, slf4j, and logkit), setting it up takes a bit of time (using slf4j to capture it all and route down to a single logging impl).


--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts

On Thu, Apr 16, 2015 at 2:27 PM, Jesse McConnell <jesse.mcconnell@xxxxxxxxx> wrote:
I just wanted to chime in and say that this behavior is not something
that Jetty is arbitrarily doing, it is mandated by the servlet
specification.
--
jesse mcconnell
jesse.mcconnell@xxxxxxxxx


On Thu, Apr 16, 2015 at 3:33 PM, Petar Tahchiev <paranoiabla@xxxxxxxxx> wrote:
> Guys I have created a github repository that demonstrates the problem:
>
> https://github.com/paranoiabla/jetty-slow-startup
>
> Just run mvn clean install or mvn jetty:run and you see it hangs.
>
> I'd really appreciate some help here.
>
> 2015-04-16 22:48 GMT+03:00 Petar Tahchiev <paranoiabla@xxxxxxxxx>:
>>
>> Hello all,
>>
>> I just found out what's happening - I have spring-web jar in my classpath,
>> which has a non empty @HandlesTypes annotation so the annotation scanning is
>> happening. My parent pom also includes ext-js webjar:
>>
>>         <!-- _javascript_ -->
>>         <dependency>
>>             <groupId>org.webjars</groupId>
>>             <artifactId>extjs</artifactId>
>>             <version>${extjs.webjars.version}</version>
>>         </dependency>
>>
>>
>> which (believe it or not) is almost 85MB. If I exclude this dependency
>> from the pom.xml then jetty starts again for 8 seconds. If I leave it in the
>> pom.xml then jetty starts for more than 15 minutes.
>>
>> Please let me know how can I exclude the extjs webjar from annotation
>> scanning.
>>
>> Thanks
>>
>> 2015-04-16 15:16 GMT+03:00 Jan Bartel <janb@xxxxxxxxxxx>:
>>>
>>> If any of your libs contain a servletcontainerinitializer that has a non
>>> empty HandlesTypes annotation on it then scanning will be done any way.
>>> Enable debug for org.eclipse.jetty.annotations and you'll see which one it
>>> is.
>>>
>>> Jan
>>>
>>> On 16/04/2015 8:39 am, "Petar Tahchiev" <paranoiabla@xxxxxxxxx> wrote:
>>>>
>>>> Hi there,
>>>>
>>>> I tried adding metadata-complete="true" and also
>>>>
>>>>     <Call name="setAttribute">
>>>>
>>>> <Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg>
>>>>         <Arg></Arg>
>>>>     </Call>
>>>>
>>>> to my jetty-env.xml but had no effect - the same amount of time :(
>>>>
>>>> 2015-04-16 1:35 GMT+03:00 Simone Bordet <sbordet@xxxxxxxxxxx>:
>>>>>
>>>>> Hi,
>>>>>
>>>>> On Wed, Apr 15, 2015 at 9:57 PM, Petar Tahchiev <paranoiabla@xxxxxxxxx>
>>>>> wrote:
>>>>> > Hi,
>>>>> >
>>>>> > I tried 9.2.10.v20150310 and it takes more than 10 minutes!!!! With
>>>>> > Java7
>>>>> > and version 9.1.3.v20140225 it takes 8 seconds! I also think it's
>>>>> > annotation
>>>>> > scanning. Here's the threaddump:
>>>>>
>>>>> So it is annotation scanning.
>>>>> Do you need it ?
>>>>>
>>>>> What's the value for "metadata-complete" attribute in your web.xml ?
>>>>>
>>>>> Read also:
>>>>> https://www.eclipse.org/jetty/documentation/current/using-annotations.html
>>>>>
>>>>> --
>>>>> Simone Bordet
>>>>> ----
>>>>> http://cometd.org
>>>>> http://webtide.com
>>>>> http://intalio.com
>>>>> Developer advice, training, services and support
>>>>> from the Jetty & CometD experts.
>>>>> Intalio, the modern way to build business applications.
>>>>> _______________________________________________
>>>>> jetty-dev mailing list
>>>>> jetty-dev@xxxxxxxxxxx
>>>>> To change your delivery options, retrieve your password, or unsubscribe
>>>>> from this list, visit
>>>>> https://dev.eclipse.org/mailman/listinfo/jetty-dev
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Regards, Petar!
>>>> Karlovo, Bulgaria.
>>>> ---
>>>> Public PGP Key at:
>>>> https://keyserver1.pgp.com/vkd/DownloadKey.event?keyid=0x19658550C3110611
>>>> Key Fingerprint: A369 A7EE 61BC 93A3 CDFF  55A5 1965 8550 C311 0611
>>>>
>>>> _______________________________________________
>>>> jetty-dev mailing list
>>>> jetty-dev@xxxxxxxxxxx
>>>> To change your delivery options, retrieve your password, or unsubscribe
>>>> from this list, visit
>>>> https://dev.eclipse.org/mailman/listinfo/jetty-dev
>>>
>>>
>>> _______________________________________________
>>> jetty-dev mailing list
>>> jetty-dev@xxxxxxxxxxx
>>> To change your delivery options, retrieve your password, or unsubscribe
>>> from this list, visit
>>> https://dev.eclipse.org/mailman/listinfo/jetty-dev
>>
>>
>>
>>
>> --
>> Regards, Petar!
>> Karlovo, Bulgaria.
>> ---
>> Public PGP Key at:
>> https://keyserver1.pgp.com/vkd/DownloadKey.event?keyid=0x19658550C3110611
>> Key Fingerprint: A369 A7EE 61BC 93A3 CDFF  55A5 1965 8550 C311 0611
>
>
>
>
> --
> Regards, Petar!
> Karlovo, Bulgaria.
> ---
> Public PGP Key at:
> https://keyserver1.pgp.com/vkd/DownloadKey.event?keyid=0x19658550C3110611
> Key Fingerprint: A369 A7EE 61BC 93A3 CDFF  55A5 1965 8550 C311 0611
>
> _______________________________________________
> jetty-dev mailing list
> jetty-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from
> this list, visit
> https://dev.eclipse.org/mailman/listinfo/jetty-dev
_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-dev



_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-dev



--
Regards, Petar!
Karlovo, Bulgaria.
---
Public PGP Key at: https://keyserver1.pgp.com/vkd/DownloadKey.event?keyid=0x19658550C3110611
Key Fingerprint: A369 A7EE 61BC 93A3 CDFF  55A5 1965 8550 C311 0611

_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-dev


_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-dev



--
Regards, Petar!
Karlovo, Bulgaria.
---
Public PGP Key at: https://keyserver1.pgp.com/vkd/DownloadKey.event?keyid=0x19658550C3110611
Key Fingerprint: A369 A7EE 61BC 93A3 CDFF  55A5 1965 8550 C311 0611



--
Regards, Petar!
Karlovo, Bulgaria.
---
Public PGP Key at: https://keyserver1.pgp.com/vkd/DownloadKey.event?keyid=0x19658550C3110611
Key Fingerprint: A369 A7EE 61BC 93A3 CDFF  55A5 1965 8550 C311 0611

Back to the top