-
Notifications
You must be signed in to change notification settings - Fork 1
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
Lazily spawn finalisation thread #17
Conversation
This is the canonical place for globals and ensures that they are included in the right object files.
fnlz_mlc.c
Outdated
pthread_t t; | ||
pthread_create(&t, NULL, init_finalize_thread, NULL /* arg */); | ||
GC_finalizer_thread_exists = 1; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extraneous blank line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed here c1d312d
@@ -2069,9 +2069,11 @@ GC_API void GC_CALL GC_enable(void) | |||
LOCK(); | |||
GC_ASSERT(GC_dont_gc != 0); /* ensure no counter underflow */ | |||
GC_dont_gc--; | |||
#ifndef BUFFERED_FINALIZATION |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this #ifndef
ed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we allocate the pages for the finaliser buffer, we do so from within the STW pause which can cause the heap to grow if lots of objects are enqueued for finalisation in a single GC. This WARN
prints to stderr anytime the heap grows, and in alloy tests this can cause spurious output which causes a test to fail because stderr does not match.
I probably should have made this a separate commit, happy for me to do so when I squash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I probably should have made this a separate commit, happy for me to do so when I squash?
Works for me!
Please squash. |
This ensures that the synchronisation cost of spawning the finalisation thread is only spent when a) the program contains finalisers, and b) dead objects become finalisable candidates.
The allocation of pages for the finaliser buffer is done from within the STW pause. This can cause the heap to grow if lots of objects are enqueued for finalisation in a single GC and can cause spurious warnings to be printed to stderr.
c1d312d
to
fd7ce82
Compare
Squashed |
This ensures that the synchronisation cost of spawning the finalisation thread is only spent when a) the program contains finalisers, and b) dead objects become finalisable candidates.