improve startup perf#1030
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.
What
A set of internal, behavior-preserving optimizations that reduce web application
deployment/startup time. There are no changes to defaults, configuration,
public API, parsing output, or threading model — outputs are identical; only
redundant work and allocations are removed.
Changes
Annotation / JAR scanning (
ContextConfig)@HandlesTypestypes by name (class-file descriptor form forannotations, binary name for classes) so matching a scanned class is an O(1)
lookup instead of a linear scan of all handled types plus a per-annotation
string conversion.
META-INF/resources/during theannotation scan (which already iterates every entry), so
processResourceJARsno longer re-opens and re-scans each JAR.
web.xmlfreshness withFile.lastModified()forfile:URIs instead of opening aURLConnection.Collections.singletonfor the per-fragment annotation merge.Mapper (
Mapper/ batch registration)a single merge per mapping category instead of reallocating the array once per
mapping (previously O(n²)). Verified equivalent to the old sequential
insertMapbehaviour (sorted order, existing-wins dedup, wildcardnesting)over 300k randomized cases.
Web resources
JarWarResourceSet: build theMETA-INFbloom filter once when the entriesare read rather than rebuilding it on every resource lookup.
AbstractSingleArchiveResourceSet: pre-size the entry map from the JAR entrycount.
StandardRoot: hoist a loop invariant inlistResources;Collections.addAllinstead of
Arrays.asListwrapper.Misc internal
StandardJarScanner: hoist loop-invariantgetJarFileURL()/toURI()out of themanifest
Class-Pathloop;Collections.addAllfor the class-path URLs.Digester.updateAttributes: resolve the class loader once per call.FragmentJarScannerCallback: single map lookup for duplicate detection.StandardContext.mergeParameters: iterateentrySet()directly.LifecycleBase.fireLifecycleEvent: skip allocating the event when there are nolisteners.
AbstractProtocol.init: compute the (built/quoted) name once.MbeansDescriptorsIntrospectionSource:Setmembership test instead of alinear array scan.
Correctness
All changes preserve observable behaviour. The
Mapperchange was fuzz-checkedagainst the original sequential implementation (identical arrays and nesting).
TestContextConfigAnnotationis updated to build the new derived index (mirroringthe normal
processClassesflow). Please run at leastTestMapper*,TestContextConfig*, and the webresources tests.Performance
Measured on a build from source (JDK 25), median of 8 start/stop cycles, same
webapp set both sides. The gains scale with application size:
~560 ms → ~483 ms (~14%).
Changelog entries are included.
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com