Skip to content

[Native Image][GR-64079] Ability to opt-out of GC / multiple GC strategies #10973

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

Open
sgammon opened this issue Apr 2, 2025 · 1 comment
Open

Comments

@sgammon
Copy link

sgammon commented Apr 2, 2025

Is your feature request related to a problem? Please describe.
We ship a command line tool with GraalVM Native Image. Sometimes, we want to execute a very quick operation and exit; other times, the operation is a long-running one, involving server activity. It can be difficult in this case to pick an optimal GC strategy. Serial or even epsilon GCs work best for short executions and startup time, but serial or G1GC is best for server modes and epsilon is definitely not an option.

Describe the solution you'd like.
If there were a way to opt-out of GC for an execution of the binary (at runtime), or build in support for multiple GC strategies and set one early at runtime, we could achieve the best of both worlds: no GC pauses or activity at all for quick-running executions which are expected to be reaped by the OS, and also long-running executions which need some GC and benefit greatly from advanced GC strategies like G1.

Describe who do you think will benefit the most.
Native Image targets like command line tools which sometimes execute quickly and other times execute for a long amount of time.

Describe alternatives you've considered.
We have considered tuning GC to avoid "kicking in" until it is clear a longer execution is needed. Maybe a parameter could be introduced that defers any GCs for a certain wall-clock time, where epsilon applies for, say, the first second of execution and G1 GC afterward.

Additional context.
N/A

Express whether you'd like to help contributing this feature
If you'd like to contribute, please read the contribution guide.

I'd be happy to help however I can.

@sgammon sgammon added the feature label Apr 2, 2025
@sgammon sgammon changed the title Ability to opt-out of GC Ability to opt-out of GC / multiple GC strategies Apr 2, 2025
@sgammon sgammon changed the title Ability to opt-out of GC / multiple GC strategies [Native Image] Ability to opt-out of GC / multiple GC strategies Apr 2, 2025
@oubidar-Abderrahim oubidar-Abderrahim self-assigned this Apr 8, 2025
@oubidar-Abderrahim oubidar-Abderrahim changed the title [Native Image] Ability to opt-out of GC / multiple GC strategies [Native Image][GR-64079] Ability to opt-out of GC / multiple GC strategies Apr 8, 2025
@wirthi
Copy link
Member

wirthi commented Apr 8, 2025

Hi @sgammon

thanks for that request. This is a feature we are actively developing at the moment. I hope we can still bring it to our Java 25 release, but in any case, it should arrive sooner or later.

I.e. you will be able to select with GC to use at runtime - at the cost of including all potential GCs into the image (increasing image size).

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