forked from MaterializeInc/materialize
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow force enabling jemalloc on macOS
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)
- Loading branch information
Showing
19 changed files
with
206 additions
and
42 deletions.
There are no files selected for viewing
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# generated by ci/test/lint-deps.sh -- see ci/test/lint-deps/README.md for details | ||
tikv_jemalloc_ctl | ||
0::default,jemalloc,mz-alloc-default,tokio-console | ||
1:mz_alloc:default,jemalloc,tikv-jemallocator,workspace-hack | ||
2:mz_prof:jemalloc,tikv-jemalloc-ctl | ||
3:tikv_jemalloc_ctl:default,use_std | ||
tikv_jemallocator | ||
0::default,jemalloc,mz-alloc-default,tokio-console | ||
1:mz_alloc:default,jemalloc,tikv-jemallocator,workspace-hack | ||
2:tikv_jemallocator:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms | ||
tikv_jemalloc_sys | ||
0::default,jemalloc,mz-alloc-default,tokio-console | ||
1:mz_alloc:default,jemalloc,tikv-jemallocator,workspace-hack | ||
2:mz_prof:jemalloc,tikv-jemalloc-ctl | ||
3:tikv_jemalloc_ctl:default,use_std | ||
4:tikv_jemalloc_sys:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms | ||
2:tikv_jemallocator:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms | ||
3:tikv_jemalloc_sys:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms (*) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# generated by ci/test/lint-deps.sh -- see ci/test/lint-deps/README.md for details | ||
tikv_jemalloc_ctl | ||
0::default,mz-alloc-default,tokio-console | ||
1:mz_alloc:default,jemalloc,tikv-jemallocator,workspace-hack | ||
2:mz_prof:jemalloc,tikv-jemalloc-ctl | ||
3:tikv_jemalloc_ctl:default,use_std | ||
tikv_jemallocator | ||
0::default,mz-alloc-default,tokio-console | ||
1:mz_alloc:default,jemalloc,tikv-jemallocator,workspace-hack | ||
2:tikv_jemallocator:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms | ||
tikv_jemalloc_sys | ||
0::default,mz-alloc-default,tokio-console | ||
1:mz_alloc:default,jemalloc,tikv-jemallocator,workspace-hack | ||
2:mz_prof:jemalloc,tikv-jemalloc-ctl | ||
3:tikv_jemalloc_ctl:default,use_std | ||
4:tikv_jemalloc_sys:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms | ||
2:tikv_jemallocator:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms | ||
3:tikv_jemalloc_sys:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms (*) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# generated by ci/test/lint-deps.sh -- see ci/test/lint-deps/README.md for details | ||
tikv_jemalloc_ctl | ||
0::default,jemalloc,mz-alloc-default,tokio-console | ||
1:mz_alloc:default,jemalloc,tikv-jemallocator,workspace-hack | ||
2:mz_prof:jemalloc,tikv-jemalloc-ctl | ||
3:tikv_jemalloc_ctl:default,use_std | ||
tikv_jemallocator | ||
0::default,jemalloc,mz-alloc-default,tokio-console | ||
1:mz_alloc:default,jemalloc,tikv-jemallocator,workspace-hack | ||
2:tikv_jemallocator:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms | ||
tikv_jemalloc_sys | ||
0::default,jemalloc,mz-alloc-default,tokio-console | ||
1:mz_alloc:default,jemalloc,tikv-jemallocator,workspace-hack | ||
2:mz_prof:jemalloc,tikv-jemalloc-ctl | ||
3:tikv_jemalloc_ctl:default,use_std | ||
4:tikv_jemalloc_sys:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms | ||
2:tikv_jemallocator:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms | ||
3:tikv_jemalloc_sys:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms (*) |
1 change: 1 addition & 0 deletions
1
ci/test/lint-deps/aarch64-unknown-linux-gnu-no-default-features
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# generated by ci/test/lint-deps.sh -- see ci/test/lint-deps/README.md for details |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# generated by ci/test/lint-deps.sh -- see ci/test/lint-deps/README.md for details | ||
tikv_jemalloc_ctl | ||
0::default,jemalloc,mz-alloc-default,tokio-console | ||
1:mz_alloc:default,jemalloc,tikv-jemallocator,workspace-hack | ||
2:mz_prof:jemalloc,tikv-jemalloc-ctl | ||
3:tikv_jemalloc_ctl:default,use_std | ||
tikv_jemallocator | ||
0::default,jemalloc,mz-alloc-default,tokio-console | ||
1:mz_alloc:default,jemalloc,tikv-jemallocator,workspace-hack | ||
2:tikv_jemallocator:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms | ||
tikv_jemalloc_sys | ||
0::default,jemalloc,mz-alloc-default,tokio-console | ||
1:mz_alloc:default,jemalloc,tikv-jemallocator,workspace-hack | ||
2:mz_prof:jemalloc,tikv-jemalloc-ctl | ||
3:tikv_jemalloc_ctl:default,use_std | ||
4:tikv_jemalloc_sys:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms | ||
2:tikv_jemallocator:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms | ||
3:tikv_jemalloc_sys:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms (*) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
# generated by ci/test/lint-deps.sh -- see ci/test/lint-deps/README.md for details | ||
tikv_jemalloc_ctl | ||
0:mz_alloc:default,jemalloc,tikv-jemallocator,workspace-hack | ||
1:mz_prof:default,jemalloc,tikv-jemalloc-ctl,workspace-hack | ||
2:tikv_jemalloc_ctl:default,use_std | ||
0::default,mz-alloc-default,tokio-console | ||
1:mz_alloc:default,jemalloc,tikv-jemallocator,workspace-hack | ||
2:mz_prof:jemalloc,tikv-jemalloc-ctl | ||
3:tikv_jemalloc_ctl:default,use_std | ||
tikv_jemallocator | ||
0:mz_alloc:default,jemalloc,tikv-jemallocator,workspace-hack | ||
1:tikv_jemallocator:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms | ||
0::default,mz-alloc-default,tokio-console | ||
1:mz_alloc:default,jemalloc,tikv-jemallocator,workspace-hack | ||
2:tikv_jemallocator:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms | ||
tikv_jemalloc_sys | ||
0::default,mz-alloc-default,tokio-console | ||
1:mz_alloc:default,jemalloc,tikv-jemallocator,workspace-hack | ||
2:mz_prof:jemalloc,tikv-jemalloc-ctl | ||
3:tikv_jemalloc_ctl:default,use_std | ||
4:tikv_jemalloc_sys:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms | ||
2:tikv_jemallocator:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms | ||
3:tikv_jemalloc_sys:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms (*) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# generated by ci/test/lint-deps.sh -- see ci/test/lint-deps/README.md for details | ||
tikv_jemalloc_ctl | ||
0::default,jemalloc,mz-alloc-default,tokio-console | ||
1:mz_alloc:default,jemalloc,tikv-jemallocator,workspace-hack | ||
2:mz_prof:jemalloc,tikv-jemalloc-ctl | ||
3:tikv_jemalloc_ctl:default,use_std | ||
tikv_jemallocator | ||
0::default,jemalloc,mz-alloc-default,tokio-console | ||
1:mz_alloc:default,jemalloc,tikv-jemallocator,workspace-hack | ||
2:tikv_jemallocator:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms | ||
tikv_jemalloc_sys | ||
0::default,jemalloc,mz-alloc-default,tokio-console | ||
1:mz_alloc:default,jemalloc,tikv-jemallocator,workspace-hack | ||
2:mz_prof:jemalloc,tikv-jemalloc-ctl | ||
3:tikv_jemalloc_ctl:default,use_std | ||
4:tikv_jemalloc_sys:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms | ||
2:tikv_jemallocator:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms | ||
3:tikv_jemalloc_sys:background_threads,background_threads_runtime_support,default,profiling,stats,unprefixed_malloc_on_supported_platforms (*) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[package] | ||
name = "mz-alloc-default" | ||
description = "Activates the best default global memory allocator for the platform." | ||
version = "0.0.0" | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
publish = false | ||
|
||
[lints] | ||
workspace = true | ||
|
||
[dependencies] | ||
mz-alloc = { path = "../alloc", default-features = false } | ||
workspace-hack = { version = "0.0.0", path = "../workspace-hack", optional = true } | ||
|
||
# We use jemalloc by default on non-macOS platforms, as benchmarks indicated it | ||
# outperforms the system allocator, while also providing heap profiles. | ||
# | ||
# However, on macOS, we default to the system allocator, as jemalloc is not well | ||
# supported on macOS [0][1][2]. The issues present as runaway latency on load | ||
# test workloads that are comfortably handled by the macOS system allocator. | ||
# Consider re-evaluating if jemalloc's macOS support improves. | ||
# | ||
# [0]: https://github.com/jemalloc/jemalloc/issues/26 | ||
# [1]: https://github.com/jemalloc/jemalloc/issues/843 | ||
# [2]: https://github.com/jemalloc/jemalloc/issues/1467 | ||
# | ||
# Furthermore, as of August 2022, some engineers are using profiling tools, e.g. | ||
# `heaptrack`, that only work with the system allocator on macOS. | ||
[target.'cfg(not(target_os = "macos"))'.dependencies] | ||
mz-alloc = { path = "../alloc", features = ["jemalloc"] } | ||
|
||
[features] | ||
default = ["workspace-hack"] | ||
|
||
[package.metadata.cargo-udeps.ignore] | ||
normal = ["workspace-hack", "mz-alloc"] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright Materialize, Inc. and contributors. All rights reserved. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the LICENSE file. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0. | ||
|
||
//! Activates the best default global memory allocator for the platform. |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.