Skip to content

Speed up annotation processing during WAR deploy - #2856

Open
tandraschko wants to merge 1 commit into
apache:mainfrom
tandraschko:main
Open

Speed up annotation processing during WAR deploy#2856
tandraschko wants to merge 1 commit into
apache:mainfrom
tandraschko:main

Conversation

@tandraschko

Copy link
Copy Markdown
Member

Speed up annotation processing during WAR deploy

OpenEJBContextConfig.isIncluded() resolves the canonical path of the module
roots and of the web resource on every call, and Tomcat calls
processAnnotationsWebResource() once per web resource. On a WAR with a few
hundred classes under WEB-INF/classes that is thousands of filesystem
syscalls, most of them resolving the same handful of paths again and again.
Three changes, no behaviour change:

  • Memoise File.getCanonicalFile() and the URL to File conversion. Both
    mappings are stable for the lifetime of a deploy and the config instance is
    per context.
  • Return early from processAnnotationsWebResource() once every module has
    been processed. There is nothing left to match the resource against, and that
    branch never delegates to super, so resolving the resource is wasted work.
  • Reuse the path from FileResource.getCanonicalPath() instead of letting
    isIncluded() resolve the same, already canonical, path a second time.
    Measured on a synthetic WAR (40 jars, 513 classes in WEB-INF/classes) with
    tomee-embedded: isIncluded() accounted for 165 of 468 deploy-phase profiler
    samples before the change and 1 after, and deploy wall time dropped ~25%.
    Note this was measured on Windows, where getCanonicalPath() is considerably
    more expensive than on Linux, so expect a smaller gain there.

Also see apache/tomcat#1030

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant