-
Notifications
You must be signed in to change notification settings - Fork 72
Description
We've started running more tests of Room with KCT (each test is run w/ java compile testing, KCT/KAPT, KCT/ KSP) and saw a significant slow down in our tests.
Creating this issue to track that work to see if there are places where we can improve in the library.
I started profiling them and seems like most time is spent in KAPT. In fact, KSP path is almost equal to Java compile testing path whereas KAPT runs are ~5x slower.
Sample run for the same test:
And for whatever reasons, commonJvmArgs is taking a long time in KAPT's stubs and apt task but not in KSP. (specifically, parseCommandlineArguments)
When commonArguments
is invoked for KAPT:
When commonArguments
is invoked for KSP:
I've not yet debugged what is going on there.
Another penalty is the classgraph / jar searches.
Right now, each KotlinCompilation instances re-acquires the class graph and find jars but they could be cached since they won't change per process.
As a result, it dominates the time spent in tests. I'm taking a small test sample so this might also be already cached in ClassGraph side so it might be an amortized cost but in my small test sample, it spend 30% much time as running actual tests (where compilation happens)
org/gradle/api/internal/tasks/testing/junit/JUnitTestClassExecutor.runTestClass
[30] 28.43% 1,181 self: 0.00% 0 org/junit/runners/ParentRunner.run
vs
[4] 8.81% 366 self: 0.00% 0 nonapi/io/github/classgraph/concurrency/WorkQueue$1.call
Below are two profile outputs (html and interactive svg). FYI they are from different runs of the same task.
There is a lot of overhead from gradle there since i'm not running many tests in the batch so please don't pay attention on total time ratios.
profile.html.tar.gz
profile.svg.tar.gz
I'll try to share more and hopefully come up with some solutions.