Repository navigation
jemalloc-sys: don't enable background threads on unsupported targets - #191
Conversation
NO_BG_THREAD_TARGETS only produced a warning, so the background_threads feature still put background_thread:true into the default malloc_conf for musl. Return early with always_enabled set to false instead. Also add Apple targets to the list: jemalloc's configure never enables background thread support for darwin/ios, so the option makes malloc_init_hard() fail and every later allocation goes through the global init lock. Fixes tikv#179 Signed-off-by: Akash Kumar <116457960+akashchamp@users.noreply.github.com>
|
Welcome @akashchamp! It looks like this is your first PR to tikv/jemallocator 🎉 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (5)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughBuild-time handling now disables default background-thread configuration on Apple targets. The runtime-default test and documentation reflect this limitation. The enabled-feature test no longer excludes musl targets. ChangesBackground-thread target handling
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to This change stops the default background_thread:true option from being applied on Apple targets, where jemalloc rejects it. The tests, README and changelog match that behavior. Removing musl from the unsupported list depends on a jemalloc fix that the supplied evidence does not confirm for musl builds, but nothing shows a failure there. Pre-merge checks |
|
| pub static NO_BG_THREAD_TARGETS: &[&str] = &["musl"]; | ||
| /// `jemalloc`'s background_thread support is known not to work on these targets | ||
| /// (on Apple targets jemalloc's `configure` never enables it): | ||
| pub static NO_BG_THREAD_TARGETS: &[&str] = &["musl", "apple"]; |
There was a problem hiding this comment.
musl was added due to missing symbols pthread_create when linking statically. However, this issue was fixed in 5.2.0. So I think it's OK to remove "musl" from the list now. And related test gates can also be removed.
There was a problem hiding this comment.
Done in 83f79d3: "musl" is removed from NO_BG_THREAD_TARGETS (only "apple" remains) and the musl gate on background_thread_enabled.rs is dropped, so the musl CI job now runs it.
The missing pthread_create symbol that required musl in NO_BG_THREAD_TARGETS was fixed in jemalloc 5.2.0. Keep only Apple targets in the list and drop the musl test gates. Signed-off-by: Akash Kumar <116457960+akashchamp@users.noreply.github.com>
|
Thanks! |
Fixes #179.
BackgroundThreadSupport::newwarned for targets inNO_BG_THREAD_TARGETSbut then fell through, so with thebackground_threadsfeature--with-malloc-conf=background_thread:truewas still passed to configure on those targets. It now returns early withalways_enabled: false(and says so in a second warning whenbackground_threadswas requested).I also added
"apple"toNO_BG_THREAD_TARGETS. In the vendored 5.4.0configure.ac,JEMALLOC_BACKGROUND_THREADis only defined whenabi != macho, and darwin/ios setabi="macho", so jemalloc on Apple targets never supports the option."apple"covers darwin and ios, likeNO_UNPREFIXED_MALLOC_TARGETSalready does.Following the review,
"musl"is removed from the list: the missingpthread_createsymbol that it was added for was fixed in jemalloc 5.2.0. Thetarget_env = "musl"gate onbackground_thread_enabled.rsis dropped too, so the musl CI job now runs it.background_thread_defaults.rsnow expects background threads to be off by default on Apple targets even withbackground_threads. Without that change the macOS CI job that runs--features background_threadswould fail. The README and CHANGELOG are updated as well.What I checked:
cargo test -p tikv-jemallocator --features background_threads --test background_thread_defaults --test background_thread_enabledpasses.cargo fmt --all -- --checkpasses."gnu"temporarily added to the list,opt.background_threadreadtrueon main andfalseon this branch with--features background_threads, so the option really is dropped from the build.Summary by CodeRabbit
background_threadsfeature has no effect on musl and Apple targets.