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

Set minimum heap size for native Turbine to 512 MB #20360

Closed
wants to merge 1 commit into from

Conversation

fmeum
Copy link
Collaborator

@fmeum fmeum commented Nov 29, 2023

No description provided.

@fmeum fmeum requested a review from a team as a code owner November 29, 2023 17:15
@fmeum fmeum requested review from cushon and removed request for a team November 29, 2023 17:16
@github-actions github-actions bot added team-Rules-Java Issues for Java rules awaiting-review PR is awaiting review from an assigned reviewer labels Nov 29, 2023
@fmeum
Copy link
Collaborator Author

fmeum commented Nov 29, 2023

@cushon I found a minimum heap size of 512 MB to give a very nice speedup on my local machine (can only test on Linux right now unfortunately). Do you happen to know how you ended up with the 3 GB minimum for Google? Do you think that the benchmark I am using is reasonable?

@cushon
Copy link
Contributor

cushon commented Nov 29, 2023

@cushon I found a minimum heap size of 512 MB to give a very nice speedup on my local machine (can only test on Linux right now unfortunately). Do you happen to know how you ended up with the 3 GB minimum for Google? Do you think that the benchmark I am using is reasonable?

This all looks reasonable to me.

I tuned it in early 2022, and at the time we were giving JavaBuilder 3g of heap, so I tried the same for turbine. I don't remember if I collected measurements for smaller values, and for Google builds I wasn't really focused on the local resource estimate.

The benchmark seems like a good measure of average performance. The heap sizing we're using for JavaBuilder at Google gets dragged up by a handful of pathological examples that include very large generated files, etc. I have a TODO to allow tuning jvm flags for JavaBuilder for individual targets, to allow setting smaller defaults and then tuning for those outlier targets. It's possible we'll eventually want to do that for turbine, and I noticed that it also supports runtime -Xmx and -Xms flags (vs. the build-time flags), which could allow tuning it without rebuilding the native image: https://www.graalvm.org/latest/reference-manual/native-image/optimizations-and-performance/MemoryManagement/#java-heap-size

@fmeum
Copy link
Collaborator Author

fmeum commented Nov 29, 2023

That's a good point, with 4a29f08#diff-5d2185ff662bce191b9992a9c9aaba4baadfe1216d453160afaab68b2151d85bL108
settings -Xmx should work for native Turbine. I will give that a try.

Edit: Doesn't work yet since the ability to set args is not exposed to the Starlark interface of java_runtime. So this seems to be the only way to bump the heap size that is available at the moment.

@fmeum
Copy link
Collaborator Author

fmeum commented Dec 6, 2023

@cushon As you said, I don't think that there is currently any other way than setting the min heap size at image build time. I won't make any further changes, this is ready for review.

@cushon cushon added the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Dec 6, 2023
@copybara-service copybara-service bot closed this in 84f4317 Dec 6, 2023
@github-actions github-actions bot removed awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally awaiting-review PR is awaiting review from an assigned reviewer labels Dec 6, 2023
@fmeum fmeum deleted the turbine_benchmark branch December 7, 2023 09:00
@brentleyjones
Copy link
Contributor

Should this be cherry-picked into 7.1?

@fmeum
Copy link
Collaborator Author

fmeum commented Dec 8, 2023

@brentleyjones This entirely lives in java_tools prebuilts, but I do plan to cherry-pick a rules_java update with this change into 7.1.0. Currently it's not even live at HEAD.

We can still cherry-pick this change for transparency.

@fmeum
Copy link
Collaborator Author

fmeum commented Dec 8, 2023

@bazel-io flag

@bazel-io bazel-io added the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Dec 8, 2023
@iancha1992
Copy link
Member

@bazel-io fork 7.1.0

@bazel-io bazel-io removed the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Dec 8, 2023
@fmeum
Copy link
Collaborator Author

fmeum commented Dec 13, 2023

@keertk If you have the time, could you create a new java_tools release with this change?

@keertk
Copy link
Member

keertk commented Dec 13, 2023

@fmeum any chance this can wait till early Jan? I'm out until then. If not, perhaps @hvadehra can help?

@fmeum
Copy link
Collaborator Author

fmeum commented Dec 13, 2023

@keertk No worries, this can wait!

@keertk
Copy link
Member

keertk commented Jan 8, 2024

Tracked here: bazelbuild/java_tools#87

@keertk
Copy link
Member

keertk commented Feb 8, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Rules-Java Issues for Java rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants