https://bz.apache.org/bugzilla/show_bug.cgi?id=61212

--- Comment #2 from Adrianas <abruzgu...@eisgroup.com> ---
We do have relativelly big spring based application with ~250mb of jars.

After migrating from tc 7 to tc 8 application boot time significantly
increased. Seems that most of the time is taken by a constant call to
java.util.jar.JarFile.getJarEntry. 

Looks like tc8 class/resource loader on each ClassLoader.loadClass(String)
iterates through all jars and asks each jar if resource exists (instead of
caching jar content once in memory).

tc 8 has the ability to read jar contens only once but to enable it we had to
extend org.apache.catalina.webresources.StandardRoot with custom
implementation.

After change total time spent on
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(String) dropped from
87sec to 39sec. It was 40+sec of time wasted on constant jar content check.

package org.apache.catalina.webresources;

import org.apache.catalina.LifecycleException;
import org.apache.catalina.WebResourceSet;

/**
 * Created by adi on 09/06/2017.
 */
public class CustomStandardRoot extends
org.apache.catalina.webresources.StandardRoot {

    @Override
    protected void startInternal() throws LifecycleException {
        super.startInternal();
        for (WebResourceSet webResourceSet : getClassResources()) {
            if (webResourceSet instanceof AbstractArchiveResourceSet) {
                // Load Jar Content into Memory
               
((AbstractArchiveResourceSet)webResourceSet).getArchiveEntries(false);
            }
        }
    }
}

and register custom implementation in TOMCAT_HOME/conf/context.xml 
<?xml version="1.0" encoding="UTF-8"?>
Context containerSciFilter="org.apache.tomcat.websocket.server.WsSci">
...
        <Resources cachingAllowed="true"
className="org.apache.catalina.webresources.CustomStandardRoot"/>      
...
</Context>

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to