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

Implementing switch to disable generational behaviour of the GC #56646

Open
gbaraldi opened this issue Nov 21, 2024 · 4 comments
Open

Implementing switch to disable generational behaviour of the GC #56646

gbaraldi opened this issue Nov 21, 2024 · 4 comments
Labels
GC Garbage collector

Comments

@gbaraldi
Copy link
Member

While experimenting with julia as a shared lib the GC can become a latency issue. Specifically full GCs can cause significant pauses. While taking a look it dawned on me that some workflows don't allocate any amount of permanent memory and all of it is short lived, so turning any of it old is wasteful anyway.
I'm proposing adding a switch that turns off full gcs and promoting objects to the old age. Python has something similar called freeze https://docs.python.org/3/library/gc.html#gc.freeze

@oscardssmith oscardssmith added the GC Garbage collector label Nov 21, 2024
@d-netto
Copy link
Member

d-netto commented Nov 22, 2024

I'm proposing adding a switch that turns off full gcs and promoting objects to the old age.

So you will have a single generation of objects? If that's the case, doesn't this make literally every GC a full GC? Am I misunderstanding something?

@d-netto
Copy link
Member

d-netto commented Nov 22, 2024

Ah, OK. You may be proposing doing this after some objects have been allocated in the heap: i.e. accumulate a bunch of objects in the old generation, and from that point on, don't move anything to the old generation.

But since you had promotions before the generational behavior was disabled, then you may possibly have some objects in the old generation.

I.e. you are not really disabling generational GC at startup? (Which would make all GCs full GCs as I mentioned above).

@oscardssmith
Copy link
Member

This isn't something you would run at startup. This is something you run after you have allocated all the memory your process needs that will live for ~the length of the process, and the rest of your process is will only have relatively short lived allocations.

@gbaraldi
Copy link
Member Author

It's a switch you enable during the process. Basically you do something like

setup()
GC.gc(true)
GC.gc(true) # make sure anything that's alive is now old
GC.generational(false)
...

The idea is to make the performance more predictable.

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

No branches or pull requests

3 participants