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

Long runtime classpaths slow down unit test execution #19480

Closed
rsalvador opened this issue Sep 11, 2023 · 4 comments
Closed

Long runtime classpaths slow down unit test execution #19480

rsalvador opened this issue Sep 11, 2023 · 4 comments
Labels
team-Performance Issues for Performance teams type: bug untriaged

Comments

@rsalvador
Copy link
Contributor

Description of the bug:

The classpath pre-processing loop in java_stub_template.txt is inefficient for very long classpaths and slows down unit test execution. The slowdown is in this loop in java_stub_template.txt:

for classpaths with ~250,000 and ~700,000 entries the loop takes 28 and 50 seconds, respectively, on an intel MacBook.

Which category does this issue belong to?

Performance

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Run a unit test with a very long runtime classpath.

Which operating system are you running Bazel on?

OSX

What is the output of bazel info release?

release 6.1.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

Performance regression seems to have been introduced in d0ee889

Have you found anything relevant by searching the web?

No

Any other information, logs, or outputs that you want to share?

No response

@Pavank1992 Pavank1992 added the team-Performance Issues for Performance teams label Sep 11, 2023
bazel-io pushed a commit to bazel-io/bazel that referenced this issue Sep 11, 2023
The classpath pre-processing in this `java_stub_template.txt` loop: https://github.com/bazelbuild/bazel/blob/fcfcb929366dd3faac9643302b19c88bcf871ec6/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt#L309 is slow for long classpaths. For example for classpaths with ~250,000 and ~700,000 entries the loop takes 28 and 50 seconds, respectively, on an intel MacBook. This change reduce the times to 1 second or less.

Fixes bazelbuild#19480

Closes bazelbuild#19481.

PiperOrigin-RevId: 564491123
Change-Id: Id4be898c3f800d5390dd8bf997535a5e71a76ba3
@cushon
Copy link
Contributor

cushon commented Sep 12, 2023

This is part of the logic that generates a separate jar file as a way to configure classpath that are too long to pass on the command line.

@rsalvador I'm curious which JDK you're using, is it newer than JDK 8? The long term plan here is to replace this logic in the stub template with an @argument file: #6354

(I'm also not sure why the stub template generates this every time it's executed, instead of having Bazel create a separate action that generates the separate jar file once; that came up in #19036.)

@rsalvador
Copy link
Contributor Author

@rsalvador I'm curious which JDK you're using, is it newer than JDK 8? The long term plan here is to replace this logic in the stub template with an @argument file: #6354

@cushon using JDK 11: OpenJDK 64-Bit Server VM (build 11.0.19+7-LTS, mixed mode) by Azul Systems, Inc.

iancha1992 pushed a commit that referenced this issue Sep 12, 2023
…19491)

The classpath pre-processing in this `java_stub_template.txt` loop:
https://github.com/bazelbuild/bazel/blob/fcfcb929366dd3faac9643302b19c88bcf871ec6/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt#L309
is slow for long classpaths. For example for classpaths with ~250,000
and ~700,000 entries the loop takes 28 and 50 seconds, respectively, on
an intel MacBook. This change reduce the times to 1 second or less.

Fixes #19480

Closes #19481.

Commit
4e8f0bd

PiperOrigin-RevId: 564491123
Change-Id: Id4be898c3f800d5390dd8bf997535a5e71a76ba3

Co-authored-by: Roman Salvador <[email protected]>
SalmaSamy pushed a commit that referenced this issue Sep 13, 2023
…19491)

The classpath pre-processing in this `java_stub_template.txt` loop:
https://github.com/bazelbuild/bazel/blob/fcfcb929366dd3faac9643302b19c88bcf871ec6/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt#L309
is slow for long classpaths. For example for classpaths with ~250,000
and ~700,000 entries the loop takes 28 and 50 seconds, respectively, on
an intel MacBook. This change reduce the times to 1 second or less.

Fixes #19480

Closes #19481.

Commit
4e8f0bd

PiperOrigin-RevId: 564491123
Change-Id: Id4be898c3f800d5390dd8bf997535a5e71a76ba3

Co-authored-by: Roman Salvador <[email protected]>
@iancha1992
Copy link
Member

A fix for this issue has been included in Bazel 6.4.0 RC1. Please test out the release candidate and report any issues as soon as possible. Thanks!

@rsalvador
Copy link
Contributor Author

@iancha1992 verified that the generated test script executables include the fix and that the test execution is faster than with 6.3.2 for a sample test (35 seconds with 6.3.2 vs 12 seconds with 6.4.0rc1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Performance Issues for Performance teams type: bug untriaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants