You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2017/07/19 15:39:50 UTC
svn commit: r1802403 - in /tomcat/trunk:
java/org/apache/catalina/webresources/CachedResource.java
java/org/apache/catalina/webresources/StandardRoot.java
webapps/docs/changelog.xml webapps/docs/config/host.xml
Author: markt
Date: Wed Jul 19 15:39:49 2017
New Revision: 1802403
URL: http://svn.apache.org/viewvc?rev=1802403&view=rev
Log:
Performance improvements for service loader look-ups (and look-ups of other class loader resources) when the web application is deployed in a packed WAR file.
Modified:
tomcat/trunk/java/org/apache/catalina/webresources/CachedResource.java
tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java
tomcat/trunk/webapps/docs/changelog.xml
tomcat/trunk/webapps/docs/config/host.xml
Modified: tomcat/trunk/java/org/apache/catalina/webresources/CachedResource.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/webresources/CachedResource.java?rev=1802403&r1=1802402&r2=1802403&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/webresources/CachedResource.java (original)
+++ tomcat/trunk/java/org/apache/catalina/webresources/CachedResource.java Wed Jul 19 15:39:49 2017
@@ -92,23 +92,26 @@ public class CachedResource implements W
return true;
}
- WebResource webResourceInternal = root.getResourceInternal(
- webAppPath, useClassLoaderResources);
- if (!webResource.exists() && webResourceInternal.exists()) {
- return false;
- }
+ // Assume resources inside WARs will not change
+ if (!root.isPackedWarFile()) {
+ WebResource webResourceInternal = root.getResourceInternal(
+ webAppPath, useClassLoaderResources);
+ if (!webResource.exists() && webResourceInternal.exists()) {
+ return false;
+ }
- // If modified date or length change - resource has changed / been
- // removed etc.
- if (webResource.getLastModified() != getLastModified() ||
- webResource.getContentLength() != getContentLength()) {
- return false;
- }
+ // If modified date or length change - resource has changed / been
+ // removed etc.
+ if (webResource.getLastModified() != getLastModified() ||
+ webResource.getContentLength() != getContentLength()) {
+ return false;
+ }
- // Has a resource been inserted / removed in a different resource set
- if (webResource.getLastModified() != webResourceInternal.getLastModified() ||
- webResource.getContentLength() != webResourceInternal.getContentLength()) {
- return false;
+ // Has a resource been inserted / removed in a different resource set
+ if (webResource.getLastModified() != webResourceInternal.getLastModified() ||
+ webResource.getContentLength() != webResourceInternal.getContentLength()) {
+ return false;
+ }
}
nextCheck = ttl + now;
@@ -133,9 +136,15 @@ public class CachedResource implements W
return true;
}
- // At this point, always expire the entry as re-populating it is likely
- // to be as expensive as validating it.
- return false;
+ // Assume resources inside WARs will not change
+ if (root.isPackedWarFile()) {
+ nextCheck = ttl + now;
+ return true;
+ } else {
+ // At this point, always expire the entry and re-populating it is
+ // likely to be as expensive as validating it.
+ return false;
+ }
}
protected long getNextCheck() {
Modified: tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java?rev=1802403&r1=1802402&r2=1802403&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java (original)
+++ tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java Wed Jul 19 15:39:49 2017
@@ -642,6 +642,18 @@ public class StandardRoot extends Lifecy
return result;
}
+
+
+ /*
+ * Returns true if and only if all the resources for this web application
+ * are provided via a packed WAR file. It is used to optimise cache
+ * validation in this case on the basis that the WAR file will not change.
+ */
+ protected boolean isPackedWarFile() {
+ return main instanceof WarResourceSet && preResources.isEmpty() && postResources.isEmpty();
+ }
+
+
// ----------------------------------------------------------- JMX Lifecycle
@Override
protected String getDomainInternal() {
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1802403&r1=1802402&r2=1802403&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Wed Jul 19 15:39:49 2017
@@ -45,6 +45,15 @@
issues do not "pop up" wrt. others).
-->
<section name="Tomcat 9.0.0.M25 (markt)" rtext="in development">
+ <subsection name="Catalina">
+ <changelog>
+ <fix>
+ Performance improvements for service loader look-ups (and look-ups of
+ other class loader resources) when the web application is deployed in a
+ packed WAR file. (markt)
+ </fix>
+ </changelog>
+ </subsection>
</section>
<section name="Tomcat 9.0.0.M24 (markt)" rtext="release in progress">
<subsection name="Catalina">
Modified: tomcat/trunk/webapps/docs/config/host.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/host.xml?rev=1802403&r1=1802402&r2=1802403&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/host.xml (original)
+++ tomcat/trunk/webapps/docs/config/host.xml Wed Jul 19 15:39:49 2017
@@ -295,6 +295,10 @@
is not running. Any such change will trigger the deletion of the
expanded directory and the deployment of the updated WAR file when
Tomcat next starts.</p>
+ <p>Note: Running with this option set to <code>false</code> will incur
+ a performance penalty. To avoid a significant performance penalty, the
+ web application should be configured such that class scanning for
+ Servlet 3.0+ pluggability features is not required.</p>
</attribute>
<attribute name="workDir" required="false">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org