UTBotJava icon indicating copy to clipboard operation
UTBotJava copied to clipboard

Read classes takes up to minutes each time

Open alisevych opened this issue 2 years ago • 5 comments

Description

Even for a simple project with 5 classes, read classes phase take up to 10 seconds each time.

To Reproduce

  1. Install UnitTestBot plugin built from main in IntelliJ IDEA - this one was used
  2. Open UTBotJava project
  3. Generate tests for ArrayQuickSort
  4. Check how long Generate tests: read classes is 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

image

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.

alisevych avatar Aug 15 '23 15:08 alisevych

@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.

EgorkaKulikov avatar Aug 17 '23 05:08 EgorkaKulikov

@Vassiliy-Kudryashov Could you please check. With the latest updates on main it takes minutes sometimes.

alisevych avatar Aug 21 '23 13:08 alisevych

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?

alisevych avatar Aug 23 '23 07:08 alisevych

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.

Vassiliy-Kudryashov avatar Aug 23 '23 08:08 Vassiliy-Kudryashov

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:

  1. There's a many isRegularFile checks inside the Soot, that are not as fast as it can be, but we cannot do anything with it.
  2. There're many communications using Rd from the for-loop when initializing Soot. I tried to fix it in this PR: #2565

image

Markoutte avatar Aug 29 '23 06:08 Markoutte