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

Reduce Java Heap for Mill Client #4163

Merged
merged 1 commit into from
Jan 21, 2025

Conversation

gamlerhart
Copy link
Contributor

@gamlerhart gamlerhart commented Dec 18, 2024

The Mill Client only forwards requests and therefore does not need much memory.
However, Java doesn't know that an allocates a large heap based on the machines memory size.

Therefore, give a way lower heap limit,
creating a leaner client memory wise.

Example on my machine:

  • Before: A Mill client reserved ~500MByte
  • After: A Mill client reserves the specified 24Mbyte

This is mostly relevant for a long running mill client (examples --watch clients, -i --no-build-lock and --bsp`).

@gamlerhart
Copy link
Contributor Author

gamlerhart commented Dec 19, 2024

facepalm. Its also added to the test-runner (mill.testrunner.entrypoint.TestRunnerMain), creating out of memory exceptions. Will take a look later.

@lihaoyi lihaoyi marked this pull request as draft December 24, 2024 00:21
@gamlerhart gamlerhart force-pushed the reduce-memory-size-of-client branch 2 times, most recently from 096c27c to 2819232 Compare December 31, 2024 10:15
@gamlerhart gamlerhart marked this pull request as ready for review December 31, 2024 11:17
@gamlerhart
Copy link
Contributor Author

Question: Are some tests flacky? And if so, how can I rerun that specific test suite/github action?

@lihaoyi
Copy link
Member

lihaoyi commented Dec 31, 2024

yes some tests are flaky. I'll give them a kick

@gamlerhart gamlerhart force-pushed the reduce-memory-size-of-client branch from 2819232 to aa24db9 Compare January 1, 2025 20:03
@gamlerhart gamlerhart force-pushed the reduce-memory-size-of-client branch from aa24db9 to 51a1198 Compare January 13, 2025 21:39
@lihaoyi
Copy link
Member

lihaoyi commented Jan 14, 2025

@gamlerhart could you test this out with Mill's new ability to download JVMs on demand using Coursier (https://mill-build.org/mill/main-branch/cli/installation-ide.html#_customizing_mills_jvm)? I expect that will take more memory than the base Mill client, and we should adjust the number accordingly

@gamlerhart gamlerhart force-pushed the reduce-memory-size-of-client branch from 51a1198 to 3dac87b Compare January 17, 2025 20:35
@gamlerhart
Copy link
Contributor Author

The Memory is enough to download a JDK. It downloaded a Zulu JDK without issues for me.
I still increased it slightly, to have a bit more buffer.

However, the question is if this PR is still required. Now that we have native Graal clients, I assume most setups will use those. So, this optimization is less relevant.

@gamlerhart gamlerhart force-pushed the reduce-memory-size-of-client branch from 3dac87b to 0631a67 Compare January 18, 2025 19:56
@lihaoyi
Copy link
Member

lihaoyi commented Jan 20, 2025

I think it's still worth doing. We will need to continue support the JVM launcher anyway, either as a cross-platform launcher, or for platforms like Windows-ARM (e.g. my surface 7 laptop) that do not have Graal native image support yet

The Mill Client only forwards requests and therefore
does not need much memory.
However, Java doesn't know that an allocates a large heap
based on the machines memory size.

Therefore, give a way lower heap limit,
creating a leaner client memory wise.
@gamlerhart gamlerhart force-pushed the reduce-memory-size-of-client branch from 0631a67 to 35b100f Compare January 20, 2025 20:57
Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@lihaoyi lihaoyi merged commit 5c48b68 into com-lihaoyi:main Jan 21, 2025
28 checks passed
@lihaoyi
Copy link
Member

lihaoyi commented Jan 21, 2025

Thanks @gamlerhart !

@lefou lefou added this to the 0.12.6 milestone Jan 21, 2025
gamlerhart added a commit to gamlerhart/mill that referenced this pull request Feb 9, 2025
The Mill Client only forwards requests and therefore does not need much
memory.
However, Java doesn't know that an allocates a large heap based on the
machines memory size.

Therefore, give a way lower heap limit,
creating a leaner client memory wise.

Example on my machine:
- Before: A Mill client reserved ~500MByte
- After: A Mill client reserves the specified 24Mbyte

This is mostly relevant for a long running mill client (examples
`--watch` clients, `-i --no-build-lock` and --bsp`).

Co-authored-by: Li Haoyi <[email protected]>
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.

3 participants