Repository navigation
KSP2: reuse processor classloaders across modules within a build - #3210
Merged
Merged
Conversation
jaschdoc
self-requested a review
September 15, 2026 14:49
hfmehmed
force-pushed
the
perf/cache-processor-classloader
branch
from
September 15, 2026 15:48
eb3478d to
191ec00
Compare
jaschdoc
reviewed
Sep 16, 2026
jaschdoc
left a comment
Collaborator
There was a problem hiding this comment.
Mostly nits and questions. Looks like a nice optimization!
hfmehmed
force-pushed
the
perf/cache-processor-classloader
branch
from
September 16, 2026 14:19
191ec00 to
f1a75ea
Compare
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.
KspAAWorkerActionconstructs a freshURLClassLoaderover the processorclasspath for every module and closes it when that module finishes. The same
processor jars are therefore loaded and compiled once per module.
This PR adds an opt-in cache of processor classloaders keyed by the KSP classpath
plus the processor classpath. It lives alongside the existing isolated classloader
cache and is cleared by the same build service, so its lifetime is still bounded
by the build.
Results
Measured on the Metro 500-module Dagger/KSP benchmark, ABI-change scenario,
via
gradle-profilerwith 3 warm-ups and 6 measured iterations. The same ksp binary is used - one of them has a flag set to enable the cache and the other represents the baseline (current state)Overlap between the two states: NO - 24.55s difference between the slowest cache-ON build (59.97s) and the fastest cache-OFF build (84.52s).