Skip to content

IGNITE-21052 Improved measurement of first query planning time#2960

Merged
xtern merged 10 commits intoapache:mainfrom
gridgain:ignite-21052
Dec 22, 2023
Merged

IGNITE-21052 Improved measurement of first query planning time#2960
xtern merged 10 commits intoapache:mainfrom
gridgain:ignite-21052

Conversation

@xtern
Copy link
Contributor

@xtern xtern commented Dec 15, 2023

https://issues.apache.org/jira/browse/IGNITE-21052

Issue:
first query planning takes much longer time, mainly due to class loading.

We found that the most time was spent scanning the class path during initialization of RelMetadataQueryEx.
And this is redundant now, since from Calcite 1.28.0 there is no need to register all known RelNode subtypes (see CALCITE-4546 for details).

Also it was found that initialization of PlannerPhase enum loads 600+ classes, and this loading affects planning time.

So I decided:

  1. Remove redundant RelNode subtypes registration during initialization of RelMetadataQueryEx (on TeamCity it took up to 5 seconds)
  2. Load PlannerPhase related classes during static initialization of planner (on TeamCity it took up to 2 seconds).

After these changes I run unit tests on TC 30+ times without timeout: https://ci.ignite.apache.org/viewType.html?buildTypeId=ApacheIgnite3xGradle_Test_RunUnitTests&branch_ApacheIgnite3xGradle_Test=pull%2F2960&tab=buildTypeStatusDiv

I also analyzed over 10 runs and the (first) planning time now looks more stable, between 1800-2100ms.

@xtern xtern changed the title IGNITE-21052 IGNITE-21052 Improve query scheduling time measurement Dec 21, 2023
@xtern xtern changed the title IGNITE-21052 Improve query scheduling time measurement IGNITE-21052 Improved measurement of first query planning time Dec 21, 2023
@xtern xtern marked this pull request as ready for review December 21, 2023 08:47
import static java.util.stream.Collectors.toList;
import static org.apache.ignite.internal.util.IgniteUtils.igniteClassLoader;

import io.github.classgraph.ClassGraph;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we remove the dependency at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. It seems so. The dependency has been removed.

private RelOptCluster cluster;

static {
// Preload some classes to reduce first planning time.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the fact visible time of first planning will be the same.
I see tow options here:

  1. Move loading and initialization classes on earlier stage, during node startup. Due to java could do classpoading in parallel it shouldn't significant increase time of node start, but our very first parsing will be visible faster. For tests which could instantiate some of services himself we could keep initialization in two places.
  2. Just fix a coomet to show real life )

Copy link
Contributor Author

@xtern xtern Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I expanded the comment 😎 .

@lowka
Copy link
Contributor

lowka commented Dec 21, 2023

I have the same concerns as Yuri (point 1 in his comment). But I think it is out of scope of this PR.

@xtern xtern merged commit fef53d9 into apache:main Dec 22, 2023
@xtern xtern deleted the ignite-21052 branch December 22, 2023 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants