Fix multithreaded fork on OS X and add a test.#954
Merged
davidtgoldblatt merged 2 commits intojemalloc:devfrom Jul 11, 2017
Merged
Fix multithreaded fork on OS X and add a test.#954davidtgoldblatt merged 2 commits intojemalloc:devfrom
davidtgoldblatt merged 2 commits intojemalloc:devfrom
Conversation
Contributor
Author
|
@alexcrichton, could you confirm that this fixes things on your end? |
djwatson
reviewed
Jul 10, 2017
src/zone.c
Outdated
| } else { | ||
| jemalloc_postfork_child(); | ||
| } | ||
| zone_force_lock_pid = 1; |
There was a problem hiding this comment.
Is there some reason this is 1 instead of -1?
Contributor
Author
There was a problem hiding this comment.
Nope, typo. Thanks.
On OS X, we rely on the zone machinery to call our prefork and postfork handlers. In zone_force_unlock, we call jemalloc_postfork_child, reinitializing all our mutexes regardless of state, since the mutex implementation will assert if the tid of the unlocker is different from that of the locker. This has the effect of unlocking the mutexes, but also fails to wake any threads waiting on them in the parent. To fix this, we track whether or not we're the parent or child after the fork, and unlock or reinit as appropriate. This resolves jemalloc#895.
eb1bc11 to
3423787
Compare
|
Works for me 👍 Thanks @davidtgoldblatt! |
djwatson
reviewed
Jul 10, 2017
| #endif | ||
|
|
||
| static void | ||
| wait_for_child_exit(int pid) { |
There was a problem hiding this comment.
looks like some of this needs more define guards
Forking a multithreaded process is dangerous but allowed, so long as the child only executes async-signal-safe functions (e.g. exec). Add a test to ensure that we don't break this behavior.
3423787 to
4f67d6a
Compare
nicktrav
added a commit
to nicktrav/cockroach
that referenced
this pull request
Dec 8, 2022
Update jemalloc to point to the upstream 5.3.0 release, hosted on our internal fork. This removes two custom patches that are no longer required: - Fix deadlock in multithreaded fork in OS X - fix upstreamed in jemalloc/jemalloc#954. - Fix JEMALLOC_MUTEX_INIT_CB to only be set if OSS_PINLOCK is false - spinlock support was removed upstream in jemalloc/jemalloc#1367 Touches cockroachdb#83289. Epic: CRDB-20293. Release note: None.
nicktrav
added a commit
to nicktrav/cockroach
that referenced
this pull request
Jan 5, 2023
Update jemalloc to point to the upstream 5.3.0 release, hosted on our internal fork. This removes two custom patches that are no longer required: - Fix deadlock in multithreaded fork in OS X - fix upstreamed in jemalloc/jemalloc#954. - Fix JEMALLOC_MUTEX_INIT_CB to only be set if OSS_PINLOCK is false - spinlock support was removed upstream in jemalloc/jemalloc#1367 Touches cockroachdb#83289. Epic: CRDB-20293. Release note: None.
craig bot
pushed a commit
to cockroachdb/cockroach
that referenced
this pull request
Jan 6, 2023
93045: c-deps: update jemalloc to 5.3.0 r=rickystewart a=nicktrav Update jemalloc to point to the upstream 5.3.0 release, hosted on our internal fork. This removes two custom patches that are no longer required: - Fix deadlock in multithreaded fork in OS X - fix upstreamed in jemalloc/jemalloc#954. - Fix JEMALLOC_MUTEX_INIT_CB to only be set if OSS_PINLOCK is false - spinlock support was removed upstream in jemalloc/jemalloc#1367 Touches #83289. Closes #17013. Closes #83289. Epic: CRDB-20293. Release note (performance improvement): The memory allocator, `jemalloc` was updated to the latest available upstream version, 5.3.0, from 4.5.0. This update pulls in a number of upstream improvements, including reduced memory fragmentation for memory allocated outside of the Go runtime (i.e. the Pebble block and table caches), resulting in better memory utilization. Co-authored-by: Nick Travers <travers@cockroachlabs.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This resolves #895.