-
Notifications
You must be signed in to change notification settings - Fork 466
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
alloc: add force-jemalloc-macos feature #27041
Conversation
58dc8d9
to
3d68e74
Compare
3d68e74
to
757a2d0
Compare
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.
To fix the problem of building tikv_jemallocator
on macOS could you do [target.'cfg(...)
.features]`? e.g. something like:
[target.'cfg(not(target_os = "macos"))'.features]
default = ["jemalloc", "workspace-hack"]
jemalloc = ["tikv-jemallocator", "mz-prof/jemalloc", "mz-prof-http/jemalloc"]
[target.'cfg(target_os = "macos")'.features]
default = ["workspace-hack"]
jemalloc = ["tikv-jemallocator"]
approving to clear the block if its needed!
Let me ponder this one today. I'd love to find a way to do this that doesn't require introducing another Cargo feature. (Although I know Cargo makes that hard with its lack of support for target-specific features.) |
@benesch yes I'll wait! I couldn't come up with anything, but let me know! @ParkMyCar I don't think cargo allows that! |
Twiddle our crates and Cargo configuration for activating jemalloc to achieve the following ideal developer experience: * --no-default-features unequivocally disables jemalloc, regardless of platform. * --features=jemalloc unequivocally enables jemalloc, regardless of platform. * --default-features chooses the best allocator for the platform: the system allocator on macOS and jemalloc on Linux. Since Cargo doesn't explicitly support target-specific features, the trick is to introduce a crate of indirection, as described in [0]. Here's how it works: * The `mz-prof`, `mz-prof-http`, and `mz-alloc` crates have a straightforward setup: they expose a `jemalloc` feature and conditionally enable or disable jemalloc features based on whether the `jemalloc` feature is provided or not. * The `mz-alloc-default` crate depends on the `mz-alloc` crate and enables the best features for the platform: `jemalloc` on Linux, and no additional features on macOS. You can think of this crate as unconditionally enabling the best allocator for the platform. * The `mz-environmentd` and `mz-clusterd` crates unlock the conditional behavior. Bothc crates: 1. depend on `mz-alloc-default` by default, and 2. expose a `jemalloc` feature that force enables the `mz-alloc/jemalloc` feature. The motivation for all of this is to allow macOS developers to enable jemalloc upon request, which is useful for certain kinds of testing. Alternative to MaterializeInc#27041. Closes MaterializeInc#27041. [0]: rust-lang/cargo#1197 (comment)
I put up #27067, which should address the issues here! AFAICT, it makes |
@benesch your replacement pr looks good! |
Twiddle our crates and Cargo configuration for activating jemalloc to achieve the following ideal developer experience: * --no-default-features unequivocally disables jemalloc, regardless of platform. * --features=jemalloc unequivocally enables jemalloc, regardless of platform. * --default-features chooses the best allocator for the platform: the system allocator on macOS and jemalloc on Linux. Since Cargo doesn't explicitly support target-specific features, the trick is to introduce a crate of indirection, as described in [0]. Here's how it works: * The `mz-prof`, `mz-prof-http`, and `mz-alloc` crates have a straightforward setup: they expose a `jemalloc` feature and conditionally enable or disable jemalloc features based on whether the `jemalloc` feature is provided or not. * The `mz-alloc-default` crate depends on the `mz-alloc` crate and enables the best features for the platform: `jemalloc` on Linux, and no additional features on macOS. You can think of this crate as unconditionally enabling the best allocator for the platform. * The `mz-environmentd` and `mz-clusterd` crates unlock the conditional behavior. Bothc crates: 1. depend on `mz-alloc-default` by default, and 2. expose a `jemalloc` feature that force enables the `mz-alloc/jemalloc` feature. The motivation for all of this is to allow macOS developers to enable jemalloc upon request, which is useful for certain kinds of testing. Alternative to MaterializeInc#27041. Closes MaterializeInc#27041. [0]: rust-lang/cargo#1197 (comment)
Some experiments I am doing would be easier if I could turn on jemalloc stats on macos. Heap profiling doesn't work, but it appears relatively stable.
@benesch unfortunately I couldn't figure out a way to not build
tikv-jemallocator
ifforce-jemalloc-macos
is off. I don't think you can ANDfeature
andplatform
's intarget.cfg()
clauses, so the cost of this is macos users have to buildtikv-jemallocator
once. One way around this is turning offjemalloc
by default inbin/environmentd
and adding--features jemalloc
forlinux
users, but that seemed not worth it, because it would also mean we'd have to explicitly enable it everywhere else we build materialize.context: https://materializeinc.slack.com/archives/C0246GEHL8N/p1715300698582579
Motivation
Checklist
$T ⇔ Proto$T
mapping (possibly in a backwards-incompatible way), then it is tagged with aT-proto
label.