Read classes takes up to minutes each time
Description
Even for a simple project with 5 classes, read classes phase take up to 10 seconds each time.
To Reproduce
- Install UnitTestBot plugin built from main in IntelliJ IDEA - this one was used
- Open
UTBotJavaproject - Generate tests for
ArrayQuickSort - Check how long
Generate tests: read classesis displayed in progress bar
Expected behavior
It is expected that 5-10 simplest classes will be read in 0.5-1 seconds.
Actual behavior
Generate tests: read classes is displayed for 6 seconds each time.
Screenshots, logs
Environment
IntelliJ IDEA version - Ultimate 2023.2 Project - Gradle JDK - 17 OS - Windows 10 Pro CPU - 13% usage Memory - 70%
Additional context
In TwoAnimals Spring-based project - for 1 class - it takes 10 seconds each time.
@Vassiliy-Kudryashov please investigate. May be we have changed something in Soot loading recently, so scanning dependencies is now longer that before. Also I suggest to rename read classes to scanning dependencies.
@Vassiliy-Kudryashov Could you please check. With the latest updates on main it takes minutes sometimes.
Either "Generate tests: read classes" or "Initialization" now takes 25 seconds, up to minutes each time. It's a performance regression issue.
Here is the comparison of test generation on the same project, same class (also checked in another project): On July's build (2023.7.4725) - issue is present (25 sec) On June's build (2023.6.4492) - issue is present (16 sec), a bit less critical On May's build (2023.5.4440) - issue is present (16 sec) On March release (2023.3) - issue is present (11 sec), there is no Spring support yet
@Markoutte Could you please check the reason and whether the generation pre-phase can be speed up?
Well, confusing message was replaced with "Generate tests: starting engine", real investigation of time consumption should be provided later. @Markoutte, please take look at that.
Either "Generate tests: read classes" or "Initialization" now takes 25 seconds, up to minutes each time. It's a performance regression issue.
Here is the comparison of test generation on the same project, same class (also checked in another project): On July's build (2023.7.4725) - issue is present (25 sec) On June's build (2023.6.4492) - issue is present (16 sec), a bit less critical On May's build (2023.5.4440) - issue is present (16 sec) On March release (2023.3) - issue is present (11 sec), there is no Spring support yet
@Markoutte Could you please check the reason and whether the generation pre-phase can be speed up?
I profiled this part and generally the Soot initialization consumes all the time. Even for a small project it loads nearly 10K classes. You can see the results of profiling below. I found 2 major problems:
- There's a many
isRegularFilechecks inside the Soot, that are not as fast as it can be, but we cannot do anything with it. - There're many communications using Rd from the for-loop when initializing Soot. I tried to fix it in this PR: #2565