Speed up annotation processing during WAR deploy - #2856
Open
tandraschko wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Speed up annotation processing during WAR deploy
OpenEJBContextConfig.isIncluded()resolves the canonical path of the moduleroots and of the web resource on every call, and Tomcat calls
processAnnotationsWebResource()once per web resource. On a WAR with a fewhundred classes under
WEB-INF/classesthat is thousands of filesystemsyscalls, most of them resolving the same handful of paths again and again.
Three changes, no behaviour change:
File.getCanonicalFile()and the URL toFileconversion. Bothmappings are stable for the lifetime of a deploy and the config instance is
per context.
processAnnotationsWebResource()once every module hasbeen processed. There is nothing left to match the resource against, and that
branch never delegates to
super, so resolving the resource is wasted work.FileResource.getCanonicalPath()instead of lettingisIncluded()resolve the same, already canonical, path a second time.Measured on a synthetic WAR (40 jars, 513 classes in
WEB-INF/classes) withtomee-embedded:isIncluded()accounted for 165 of 468 deploy-phase profilersamples before the change and 1 after, and deploy wall time dropped ~25%.
Note this was measured on Windows, where
getCanonicalPath()is considerablymore expensive than on Linux, so expect a smaller gain there.
Also see apache/tomcat#1030