Skip to content

Commit

Permalink
update jemalloc to 5.3.0 (#23)
Browse files Browse the repository at this point in the history
Signed-off-by: Jay Lee <BusyJayLee@gmail.com>
  • Loading branch information
BusyJay committed May 13, 2022
1 parent 161451b commit 2ffd08e
Show file tree
Hide file tree
Showing 33 changed files with 2,121 additions and 462 deletions.
3 changes: 1 addition & 2 deletions .gitmodules
@@ -1,4 +1,3 @@
[submodule "jemalloc-sys/jemalloc"]
path = jemalloc-sys/jemalloc
url = https://github.com/tikv/jemalloc
branch = v5.2.x
url = https://github.com/jemalloc/jemalloc
59 changes: 1 addition & 58 deletions Cargo.toml
@@ -1,59 +1,2 @@
[package]
name = "jemallocator"
# Make sure to update the version in the README as well:
version = "0.4.3"
authors = [
"Alex Crichton <alex@alexcrichton.com>",
"Gonzalo Brito Gadeschi <gonzalobg88@gmail.com>",
"Simon Sapin <simon.sapin@exyr.org>",
"Steven Fackler <sfackler@gmail.com>",
"The TiKV Project Developers",
]
license = "MIT/Apache-2.0"
readme = "README.md"
keywords = ["allocator", "jemalloc"]
categories = ["memory-management", "api-bindings"]
repository = "https://github.com/tikv/jemallocator"
homepage = "https://github.com/tikv/jemallocator"
documentation = "https://docs.rs/jemallocator"
description = """
A Rust allocator backed by jemalloc
"""
edition = "2018"

[badges]
travis-ci = { repository = "tikv/jemallocator" }
codecov = { repository = "tikv/jemallocator" }
is-it-maintained-issue-resolution = { repository = "tikv/jemallocator" }
is-it-maintained-open-issues = { repository = "tikv/jemallocator" }
maintenance = { status = "actively-developed" }

[lib]
test = false
bench = false

[workspace]
members = ["systest", "jemallocator-global", "jemalloc-ctl", "jemalloc-sys" ]

[dependencies]
jemalloc-sys = { path = "jemalloc-sys", version = "0.4.0", default-features = false }
libc = { version = "^0.2.8", default-features = false }

[dev-dependencies]
paste = "1"
jemalloc-ctl = { path = "jemalloc-ctl", version = "0.4" }

[features]
default = ["background_threads_runtime_support"]
alloc_trait = []
profiling = ["jemalloc-sys/profiling"]
debug = ["jemalloc-sys/debug"]
stats = ["jemalloc-sys/stats"]
background_threads_runtime_support = ["jemalloc-sys/background_threads_runtime_support"]
background_threads = ["jemalloc-sys/background_threads"]
unprefixed_malloc_on_supported_platforms = ["jemalloc-sys/unprefixed_malloc_on_supported_platforms"]
disable_initial_exec_tls = ["jemalloc-sys/disable_initial_exec_tls"]

[package.metadata.docs.rs]
features = []
rustdoc-args = [ "--cfg", "jemallocator_docs" ]
members = ["jemallocator", "jemallocator-global", "jemalloc-ctl", "jemalloc-sys"]
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -30,7 +30,7 @@ To use `jemallocator` add it as a dependency:
[dependencies]

[target.'cfg(not(target_env = "msvc"))'.dependencies]
jemallocator = "0.4.0"
jemallocator = "0.4.3"
```

To set `jemallocator::Jemalloc` as the global allocator add this to your project:
Expand Down
4 changes: 0 additions & 4 deletions ci/run.sh
Expand Up @@ -66,10 +66,6 @@ case "${TARGET}" in
;;
esac

if rustc --version | grep -v nightly >/dev/null; then
# systest can't be built on nightly
cargo test --target "${TARGET}" -p systest
fi
cargo test --target "${TARGET}" --manifest-path jemallocator-global/Cargo.toml
cargo test --target "${TARGET}" \
--manifest-path jemallocator-global/Cargo.toml \
Expand Down
4 changes: 2 additions & 2 deletions jemalloc-ctl/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "jemalloc-ctl"
version = "0.4.2"
version = "0.4.3"
authors = [
"Steven Fackler <sfackler@gmail.com>",
"Gonzalo Brito Gadeschi <gonzalobg88@gmail.com>",
Expand Down Expand Up @@ -31,7 +31,7 @@ libc = { version = "0.2", default-features = false }
paste = "1"

[dev-dependencies]
jemallocator = { path = "..", version = "0.4.0" }
jemallocator = { path = "../jemallocator", version = "0.4.0" }

[features]
default = []
Expand Down
4 changes: 2 additions & 2 deletions jemalloc-ctl/src/lib.rs
Expand Up @@ -169,8 +169,8 @@ option! {
/// use jemalloc_ctl::max_background_threads;
/// let m = max_background_threads::mib().unwrap();
/// println!("max_background_threads: {}", m.read().unwrap());
/// m.write(0).unwrap();
/// assert_eq!(m.read().unwrap(), 0);
/// m.write(2).unwrap();
/// assert_eq!(m.read().unwrap(), 2);
/// #
/// # } // #[cfg(..)]
/// # }
Expand Down
2 changes: 1 addition & 1 deletion jemalloc-ctl/src/macros.rs
Expand Up @@ -26,7 +26,7 @@ macro_rules! types {
Ok([<$id _mib>](Self::NAME.$name_to_mib()?))
}

/// Key [`::keys::Name`].
/// Key [`crate::keys::Name`].
pub fn name() -> &'static crate::keys::Name {
Self::NAME
}
Expand Down
8 changes: 4 additions & 4 deletions jemalloc-ctl/src/opt.rs
Expand Up @@ -166,7 +166,7 @@ option! {
}

option! {
lg_tcache_max[ str: b"opt.lg_tcache_max\0", non_str: 2 ] => libc::size_t |
tcache_max[ str: b"opt.tcache_max\0", non_str: 2 ] => libc::size_t |
ops: r |
docs:
/// Maximum size class (log base 2) to cache in the thread-specific cache
Expand All @@ -183,11 +183,11 @@ option! {
/// #
/// # fn main() {
/// use jemalloc_ctl::opt;
/// let lg_tcache_max = opt::lg_tcache_max::read().unwrap();
/// println!("max cached allocation size: {}", 1 << lg_tcache_max);
/// let tcache_max = opt::tcache_max::read().unwrap();
/// println!("max cached allocation size: {}", tcache_max);
/// # }
/// ```
mib_docs: /// See [`lg_tcache_max`].
mib_docs: /// See [`tcache_max`].
}

option! {
Expand Down
14 changes: 7 additions & 7 deletions jemalloc-ctl/src/stats.rs
@@ -1,7 +1,7 @@
//! Global allocator statistics.
//!
//! `jemalloc` tracks a wide variety of statistics. Many of them are cached, and
//! only refreshed when the `jemalloc` "epoch" is advanced. See the [`::epoch`] type
//! only refreshed when the `jemalloc` "epoch" is advanced. See the [`crate::epoch`] type
//! for more information.

option! {
Expand All @@ -11,7 +11,7 @@ option! {
/// Total number of bytes allocated by the application.
///
/// This statistic is cached, and is only refreshed when the epoch is
/// advanced. See the [`::epoch`] type for more information.
/// advanced. See the [`crate::epoch`] type for more information.
///
/// This corresponds to `stats.allocated` in jemalloc's API.
///
Expand Down Expand Up @@ -46,7 +46,7 @@ option! {
/// value returned by [`allocated`].
///
/// This statistic is cached, and is only refreshed when the epoch is
/// advanced. See the [`::epoch`] type for more information.
/// advanced. See the [`crate::epoch`] type for more information.
///
/// This corresponds to `stats.active` in jemalloc's API.
///
Expand Down Expand Up @@ -78,7 +78,7 @@ option! {
/// Total number of bytes dedicated to `jemalloc` metadata.
///
/// This statistic is cached, and is only refreshed when the epoch is
/// advanced. See the [`::epoch`] type for more information.
/// advanced. See the [`crate::epoch`] type for more information.
///
/// This corresponds to `stats.metadata` in jemalloc's API.
///
Expand Down Expand Up @@ -116,7 +116,7 @@ option! {
/// value returned by [`active`].
///
/// This statistic is cached, and is only refreshed when the epoch is
/// advanced. See the [`::epoch`] type for more information.
/// advanced. See the [`crate::epoch`] type for more information.
///
/// This corresponds to `stats.resident` in jemalloc's API.
///
Expand Down Expand Up @@ -151,7 +151,7 @@ option! {
/// larger than the value returned by [`active`].
///
/// This statistic is cached, and is only refreshed when the epoch is
/// advanced. See the [`::epoch`] type for more information.
/// advanced. See the [`crate::epoch`] type for more information.
///
/// This corresponds to `stats.mapped` in jemalloc's API.
///
Expand Down Expand Up @@ -186,7 +186,7 @@ option! {
/// excluded from mapped memory statistics, e.g. [`mapped`].
///
/// This statistic is cached, and is only refreshed when the epoch is
/// advanced. See the [`::epoch`] type for more information.
/// advanced. See the [`crate::epoch`] type for more information.
///
/// This corresponds to `stats.retained` in jemalloc's API.
///
Expand Down
2 changes: 1 addition & 1 deletion jemalloc-ctl/src/thread.rs
Expand Up @@ -9,7 +9,7 @@ option! {
docs:
/// Access to the total number of bytes allocated by the current thread.
///
/// Unlike [`::stats::allocated`], the value returned by this type is not the
/// Unlike [`crate::stats::allocated`], the value returned by this type is not the
/// number of bytes *currently* allocated, but rather the number of bytes
/// that have *ever* been allocated by this thread.
///
Expand Down
7 changes: 1 addition & 6 deletions jemalloc-sys/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "jemalloc-sys"
version = "0.4.3+5.2.1-patched.2"
version = "0.4.3+5.3.0"
authors = [
"Alex Crichton <alex@alexcrichton.com>",
"Gonzalo Brito Gadeschi <gonzalobg88@gmail.com>",
Expand All @@ -20,16 +20,11 @@ Rust FFI bindings to jemalloc
edition = "2018"

[badges]
travis-ci = { repository = "tikv/jemallocator" }
codecov = { repository = "tikv/jemallocator" }
is-it-maintained-issue-resolution = { repository = "tikv/jemallocator" }
is-it-maintained-open-issues = { repository = "tikv/jemallocator" }
maintenance = { status = "actively-developed" }

[lib]
test = false
bench = false

[dependencies]
libc = { version = "^0.2.8", default-features = false }

Expand Down
39 changes: 10 additions & 29 deletions jemalloc-sys/build.rs
Expand Up @@ -13,32 +13,7 @@ use std::fs;
use std::path::{Path, PathBuf};
use std::process::Command;

// `jemalloc` is known not to work on these targets:
const UNSUPPORTED_TARGETS: &[&str] = &[
"rumprun",
"bitrig",
"emscripten",
"fuchsia",
"redox",
"wasm32",
];

// `jemalloc-sys` is not tested on these targets in CI:
const UNTESTED_TARGETS: &[&str] = &["openbsd", "msvc"];

// `jemalloc`'s background_thread support is known not to work on these targets:
const NO_BG_THREAD_TARGETS: &[&str] = &["musl"];

// targets that don't support unprefixed `malloc`
//
// “it was found that the `realpath` function in libc would allocate with libc malloc
// (not jemalloc malloc), and then the standard library would free with jemalloc free,
// causing a segfault.”
// https://github.com/rust-lang/rust/commit/e3b414d8612314e74e2b0ebde1ed5c6997d28e8d
// https://github.com/rust-lang/rust/commit/536011d929ecbd1170baf34e09580e567c971f95
// https://github.com/rust-lang/rust/commit/9f3de647326fbe50e0e283b9018ab7c41abccde3
// https://github.com/rust-lang/rust/commit/ed015456a114ae907a36af80c06f81ea93182a24
const NO_UNPREFIXED_MALLOC: &[&str] = &["android", "dragonfly", "musl", "darwin"];
include!("src/env.rs");

macro_rules! info {
($($args:tt)*) => { println!($($args)*) }
Expand Down Expand Up @@ -78,7 +53,11 @@ fn main() {
let mut use_prefix =
env::var("CARGO_FEATURE_UNPREFIXED_MALLOC_ON_SUPPORTED_PLATFORMS").is_err();

if !use_prefix && NO_UNPREFIXED_MALLOC.iter().any(|i| target.contains(i)) {
if !use_prefix
&& NO_UNPREFIXED_MALLOC_TARGETS
.iter()
.any(|i| target.contains(i))
{
warning!(
"Unprefixed `malloc` requested on unsupported platform `{}` => using prefixed `malloc`",
target
Expand Down Expand Up @@ -164,7 +143,9 @@ fn main() {
.env("CFLAGS", cflags.clone())
.env("LDFLAGS", cflags.clone())
.env("CPPFLAGS", cflags)
.arg("--disable-cxx");
.arg("--disable-cxx")
.arg("--enable-doc=no")
.arg("--enable-shared=no");

if target.contains("ios") {
// newer iOS deviced have 16kb page sizes:
Expand Down Expand Up @@ -307,7 +288,7 @@ fn main() {
if target.contains("android") {
println!("cargo:rustc-link-lib=gcc");
} else if !target.contains("windows") {
println!("cargo:rustc-link-lib=pthread");
println!("cargo:rustc-link-arg=-pthread");
}
// GCC may generate a __atomic_exchange_1 library call which requires -latomic
// during the final linking. https://github.com/riscv-collab/riscv-gcc/issues/12
Expand Down
2 changes: 1 addition & 1 deletion jemalloc-sys/configure/VERSION
@@ -1 +1 @@
5.2.1-2-g172143a2979d9d948035423ce347e35cd1388fc3
5.3.0-0-g54eaed1d8b56b1aa528be3bdd1877e59c56fa90c

0 comments on commit 2ffd08e

Please sign in to comment.