Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing performance regression testing #14599

Closed
nrmancuso opened this issue Mar 3, 2024 · 15 comments
Closed

Parsing performance regression testing #14599

nrmancuso opened this issue Mar 3, 2024 · 15 comments
Assignees
Milestone

Comments

@nrmancuso
Copy link
Member

nrmancuso commented Mar 3, 2024

As discovered at #14566 (and elsewhere previously), parsing performance is a critical, user-facing metric that we should be consistently measuring and verifying. We have discussed this topic previously, but no action has been taken and we released a "bad" version to users.

A quick hack can be to time the execution of OpenJDK no-error CI tasks; however, this can end up bring pretty inconsistent due to the fact that we download the repo to be parsed during the report generation. Additionally, variables like the amount of resources allocated to the JVM, etc. play a role.

A slightly better approach would be to improve our AST regression testing to show checkstyle execution time as a difference between master and the feature branch (as a percentage), since this will be executed on the same machine, sequentially, and have identical resource allocation.

Probably the best approach would be to create a new script to time only checkstyle execution, and capture other metrics like memory usage, etc, without all the I/O involved with report generation.

For example, our generated report could tell us that parsing was 33% faster on the feature branch, used 10% less memory, etc.

@Lmh-java
Copy link
Contributor

Lmh-java commented Mar 29, 2024

@nrmancuso I would like to give it a shot. But, I want to discuss a few things about this to get more insights before everything starts.

I want to follow the best approach. Therefore, I will have to introduce a new test task and create a new script that benchmarks multiple metrics for checkstyle execution. I think it would be better if we also integrate this into the CI (just like how we use the "GitHub, generate report" command).

To benchmark, ideally, it would be beneficial for us to run Checkstyle on some large projects that take relatively longer execution time. Do you have some suggestions on which project should we use as the benchmark sample? Or do we want to do it over many different projects? (In this case, this will be a part of the original regression test)

Another question is, do you prefer to run this benchmark inside the original regression test procedure (change the original code), or run this benchmark in a completely isolated new script? IMO, it would be better to run the benchmark in a completely isolated procedure. For the following reasons:

  1. Easier to measure the metrics accurately.
  2. Easier to develop and maintain
  3. Developers can use these two functions separately

PS: if any of my understanding above is inaccurate, please correct me :)

@nrmancuso
Copy link
Member Author

To benchmark, ideally, it would be beneficial for us to run Checkstyle on some large projects that take relatively longer execution time. Do you have some suggestions on which project should we use as the benchmark sample? Or do we want to do it over many different projects? (In this case, this will be a part of the original regression test)

The latest openjdk has proven to be a good codebase to test on for both performance and memory consumption considerations.

@Lmh-java
Copy link
Contributor

I will start right now to build a new github action task for measuring both performance and memory consumption on openJDK.

@nrmancuso
Copy link
Member Author

nrmancuso commented Mar 30, 2024

I will start right now to build a new github action task for measuring both performance and memory consumption on openJDK.

I would suggest to map out your high level plan here to make sure we are all on the same page.

Also, it would be a good idea to create a POC in your own fork of checkstyle and share here to demonstrate what this solution will look like.

@Lmh-java
Copy link
Contributor

Lmh-java commented Mar 31, 2024

Draft Plan

Goal

Implement a new CI test task that benchmarks Checkstyle execution and compares the metrics between the new patch and the original version.

Usage

This benchmark task runs with other CIs when a PR is created or pushed.

Plan

Create a new GitHub action in .workflow, which will perform the following procedure.

  1. Git clone JDK repo as the benchmark target.
  2. Download the baseline file from our repo and parse it.
  3. Git clone Checkstyle from the patch branch, validate, and package.
  4. Run time to measure the execution time for the new patch (This process will be executed for multiple times and find the average).
  5. Compare the benchmark result with the baseline, calculate the % difference. If % difference is larger than a pre-defined threshold, exit with an error code.

PS: now we use time to only measure execution time for POC. Later on, we can change it to gnu time to also measure the RAM.

@Lmh-java
Copy link
Contributor

@nrmancuso this is a draft high-level plan, please take a look. I will be working on a sample in my forked repo for the following few days.

@romani
Copy link
Member

romani commented Apr 1, 2024

We just need use https://man7.org/linux/man-pages/man1/time.1.html over some command that runs parsing only (config with no modules under Treewalker, or single lightweight module)
In repository we will store baseline text file , with some value of real execution.
PR execution generate new value of real time from time tool
Two values compares, If execution in PR be above a % that we define, we exist with error code.

As soon as this basis prove of concept works well we can extend it to memory and any other parameters. This basis implementation should be able to catch regression if in some PR we revert performance optimization.

@Lmh-java
Copy link
Contributor

Lmh-java commented Apr 1, 2024

@romani I have updated my plan (#14599 (comment)). Please take a look. I will work on the POC in my local fork repo now.

@romani
Copy link
Member

romani commented Apr 1, 2024

Git clone JDK repo as the benchmark target.
Download the baseline file from our repo and parse it.
Git clone Checkstyle from the patch branch, validate, and package.

this is already done by all CI for you.
base line file should be in our repository in .ci folder.

Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 1, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 1, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 1, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 1, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 1, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 1, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 1, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 1, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 1, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 1, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 1, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 1, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 2, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 2, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 2, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 2, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 2, 2024
@Lmh-java
Copy link
Contributor

Lmh-java commented Apr 2, 2024

@romani Sure, I have created a PR #14754. Please take a look. :)

Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 4, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 4, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 4, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 4, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 4, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 4, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 4, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 4, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 5, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 20, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 21, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 22, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 22, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 22, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 22, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue Apr 28, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue May 1, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue May 1, 2024
Lmh-java added a commit to Lmh-java/checkstyle that referenced this issue May 1, 2024
@github-actions github-actions bot added this to the 10.16.1 milestone May 2, 2024
@nrmancuso
Copy link
Member Author

Closed via #14754

@nrmancuso
Copy link
Member Author

I see that we did not add memory stats, as I suggested above. Let's use this script in practice for awhile and see if we really need such features :)

@Lmh-java
Copy link
Contributor

Lmh-java commented May 3, 2024

I see that we did not add memory stats, as I suggested above. Let's use this script in practice for awhile and see if we really need such features :)

@nrmancuso Yes, we decided to go with bare minimum first. If we decide to implement a memory stats in the future, please feel free to let me know. I can do that quickly, since I have that feature in an early version of the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants