update jemalloc to 5.3.0 (#23)
Signed-off-by: Jay Lee <BusyJayLee@gmail.com>
This commit is contained in:
parent
2706fb3874
commit
ab0676d77e
|
@ -1,4 +1,3 @@
|
||||||
[submodule "jemalloc-sys/jemalloc"]
|
[submodule "jemalloc-sys/jemalloc"]
|
||||||
path = jemalloc-sys/jemalloc
|
path = jemalloc-sys/jemalloc
|
||||||
url = https://github.com/tikv/jemalloc
|
url = https://github.com/jemalloc/jemalloc
|
||||||
branch = v5.2.x
|
|
||||||
|
|
59
Cargo.toml
59
Cargo.toml
|
@ -1,59 +1,2 @@
|
||||||
[package]
|
|
||||||
name = "tikv-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/tikv-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]
|
[workspace]
|
||||||
members = ["systest", "jemallocator-global", "jemalloc-ctl", "jemalloc-sys" ]
|
members = ["jemallocator", "jemallocator-global", "jemalloc-ctl", "jemalloc-sys"]
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
tikv-jemalloc-sys = { path = "jemalloc-sys", version = "0.4.0", default-features = false }
|
|
||||||
libc = { version = "^0.2.8", default-features = false }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
paste = "1"
|
|
||||||
tikv-jemalloc-ctl = { path = "jemalloc-ctl", version = "0.4" }
|
|
||||||
|
|
||||||
[features]
|
|
||||||
default = ["background_threads_runtime_support"]
|
|
||||||
alloc_trait = []
|
|
||||||
profiling = ["tikv-jemalloc-sys/profiling"]
|
|
||||||
debug = ["tikv-jemalloc-sys/debug"]
|
|
||||||
stats = ["tikv-jemalloc-sys/stats"]
|
|
||||||
background_threads_runtime_support = ["tikv-jemalloc-sys/background_threads_runtime_support"]
|
|
||||||
background_threads = ["tikv-jemalloc-sys/background_threads"]
|
|
||||||
unprefixed_malloc_on_supported_platforms = ["tikv-jemalloc-sys/unprefixed_malloc_on_supported_platforms"]
|
|
||||||
disable_initial_exec_tls = ["tikv-jemalloc-sys/disable_initial_exec_tls"]
|
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
|
||||||
features = []
|
|
||||||
rustdoc-args = [ "--cfg", "jemallocator_docs" ]
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ To use `tikv-jemallocator` add it as a dependency:
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
[target.'cfg(not(target_env = "msvc"))'.dependencies]
|
[target.'cfg(not(target_env = "msvc"))'.dependencies]
|
||||||
tikv-jemallocator = "0.4.0"
|
tikv-jemallocator = "0.4.3"
|
||||||
```
|
```
|
||||||
|
|
||||||
To set `tikv_jemallocator::Jemalloc` as the global allocator add this to your project:
|
To set `tikv_jemallocator::Jemalloc` as the global allocator add this to your project:
|
||||||
|
|
|
@ -66,10 +66,6 @@ case "${TARGET}" in
|
||||||
;;
|
;;
|
||||||
esac
|
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
|
||||||
cargo test --target "${TARGET}" \
|
cargo test --target "${TARGET}" \
|
||||||
--manifest-path jemallocator-global/Cargo.toml \
|
--manifest-path jemallocator-global/Cargo.toml \
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "tikv-jemalloc-ctl"
|
name = "tikv-jemalloc-ctl"
|
||||||
version = "0.4.2"
|
version = "0.4.3"
|
||||||
authors = [
|
authors = [
|
||||||
"Steven Fackler <sfackler@gmail.com>",
|
"Steven Fackler <sfackler@gmail.com>",
|
||||||
"Gonzalo Brito Gadeschi <gonzalobg88@gmail.com>",
|
"Gonzalo Brito Gadeschi <gonzalobg88@gmail.com>",
|
||||||
|
@ -31,7 +31,7 @@ libc = { version = "0.2", default-features = false }
|
||||||
paste = "1"
|
paste = "1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tikv-jemallocator = { path = "..", version = "0.4.0" }
|
tikv-jemallocator = { path = "../jemallocator", version = "0.4.0" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
|
|
|
@ -169,8 +169,8 @@ option! {
|
||||||
/// use tikv_jemalloc_ctl::max_background_threads;
|
/// use tikv_jemalloc_ctl::max_background_threads;
|
||||||
/// let m = max_background_threads::mib().unwrap();
|
/// let m = max_background_threads::mib().unwrap();
|
||||||
/// println!("max_background_threads: {}", m.read().unwrap());
|
/// println!("max_background_threads: {}", m.read().unwrap());
|
||||||
/// m.write(0).unwrap();
|
/// m.write(2).unwrap();
|
||||||
/// assert_eq!(m.read().unwrap(), 0);
|
/// assert_eq!(m.read().unwrap(), 2);
|
||||||
/// #
|
/// #
|
||||||
/// # } // #[cfg(..)]
|
/// # } // #[cfg(..)]
|
||||||
/// # }
|
/// # }
|
||||||
|
|
|
@ -26,7 +26,7 @@ macro_rules! types {
|
||||||
Ok([<$id _mib>](Self::NAME.$name_to_mib()?))
|
Ok([<$id _mib>](Self::NAME.$name_to_mib()?))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Key [`::keys::Name`].
|
/// Key [`crate::keys::Name`].
|
||||||
pub fn name() -> &'static crate::keys::Name {
|
pub fn name() -> &'static crate::keys::Name {
|
||||||
Self::NAME
|
Self::NAME
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ option! {
|
||||||
}
|
}
|
||||||
|
|
||||||
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 |
|
ops: r |
|
||||||
docs:
|
docs:
|
||||||
/// Maximum size class (log base 2) to cache in the thread-specific cache
|
/// Maximum size class (log base 2) to cache in the thread-specific cache
|
||||||
|
@ -183,11 +183,11 @@ option! {
|
||||||
/// #
|
/// #
|
||||||
/// # fn main() {
|
/// # fn main() {
|
||||||
/// use tikv_jemalloc_ctl::opt;
|
/// use tikv_jemalloc_ctl::opt;
|
||||||
/// let lg_tcache_max = opt::lg_tcache_max::read().unwrap();
|
/// let tcache_max = opt::tcache_max::read().unwrap();
|
||||||
/// println!("max cached allocation size: {}", 1 << lg_tcache_max);
|
/// println!("max cached allocation size: {}", tcache_max);
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
mib_docs: /// See [`lg_tcache_max`].
|
mib_docs: /// See [`tcache_max`].
|
||||||
}
|
}
|
||||||
|
|
||||||
option! {
|
option! {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//! Global allocator statistics.
|
//! Global allocator statistics.
|
||||||
//!
|
//!
|
||||||
//! `jemalloc` tracks a wide variety of statistics. Many of them are cached, and
|
//! `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.
|
//! for more information.
|
||||||
|
|
||||||
option! {
|
option! {
|
||||||
|
@ -11,7 +11,7 @@ option! {
|
||||||
/// Total number of bytes allocated by the application.
|
/// Total number of bytes allocated by the application.
|
||||||
///
|
///
|
||||||
/// This statistic is cached, and is only refreshed when the epoch is
|
/// 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.
|
/// This corresponds to `stats.allocated` in jemalloc's API.
|
||||||
///
|
///
|
||||||
|
@ -46,7 +46,7 @@ option! {
|
||||||
/// value returned by [`allocated`].
|
/// value returned by [`allocated`].
|
||||||
///
|
///
|
||||||
/// This statistic is cached, and is only refreshed when the epoch is
|
/// 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.
|
/// This corresponds to `stats.active` in jemalloc's API.
|
||||||
///
|
///
|
||||||
|
@ -78,7 +78,7 @@ option! {
|
||||||
/// Total number of bytes dedicated to `jemalloc` metadata.
|
/// Total number of bytes dedicated to `jemalloc` metadata.
|
||||||
///
|
///
|
||||||
/// This statistic is cached, and is only refreshed when the epoch is
|
/// 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.
|
/// This corresponds to `stats.metadata` in jemalloc's API.
|
||||||
///
|
///
|
||||||
|
@ -116,7 +116,7 @@ option! {
|
||||||
/// value returned by [`active`].
|
/// value returned by [`active`].
|
||||||
///
|
///
|
||||||
/// This statistic is cached, and is only refreshed when the epoch is
|
/// 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.
|
/// This corresponds to `stats.resident` in jemalloc's API.
|
||||||
///
|
///
|
||||||
|
@ -151,7 +151,7 @@ option! {
|
||||||
/// larger than the value returned by [`active`].
|
/// larger than the value returned by [`active`].
|
||||||
///
|
///
|
||||||
/// This statistic is cached, and is only refreshed when the epoch is
|
/// 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.
|
/// This corresponds to `stats.mapped` in jemalloc's API.
|
||||||
///
|
///
|
||||||
|
@ -186,7 +186,7 @@ option! {
|
||||||
/// excluded from mapped memory statistics, e.g. [`mapped`].
|
/// excluded from mapped memory statistics, e.g. [`mapped`].
|
||||||
///
|
///
|
||||||
/// This statistic is cached, and is only refreshed when the epoch is
|
/// 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.
|
/// This corresponds to `stats.retained` in jemalloc's API.
|
||||||
///
|
///
|
||||||
|
|
|
@ -9,7 +9,7 @@ option! {
|
||||||
docs:
|
docs:
|
||||||
/// Access to the total number of bytes allocated by the current thread.
|
/// 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
|
/// number of bytes *currently* allocated, but rather the number of bytes
|
||||||
/// that have *ever* been allocated by this thread.
|
/// that have *ever* been allocated by this thread.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "tikv-jemalloc-sys"
|
name = "tikv-jemalloc-sys"
|
||||||
version = "0.4.3+5.2.1-patched.2"
|
version = "0.4.3+5.3.0"
|
||||||
authors = [
|
authors = [
|
||||||
"Alex Crichton <alex@alexcrichton.com>",
|
"Alex Crichton <alex@alexcrichton.com>",
|
||||||
"Gonzalo Brito Gadeschi <gonzalobg88@gmail.com>",
|
"Gonzalo Brito Gadeschi <gonzalobg88@gmail.com>",
|
||||||
|
@ -20,16 +20,11 @@ Rust FFI bindings to jemalloc
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[badges]
|
[badges]
|
||||||
travis-ci = { repository = "tikv/jemallocator" }
|
|
||||||
codecov = { repository = "tikv/jemallocator" }
|
codecov = { repository = "tikv/jemallocator" }
|
||||||
is-it-maintained-issue-resolution = { repository = "tikv/jemallocator" }
|
is-it-maintained-issue-resolution = { repository = "tikv/jemallocator" }
|
||||||
is-it-maintained-open-issues = { repository = "tikv/jemallocator" }
|
is-it-maintained-open-issues = { repository = "tikv/jemallocator" }
|
||||||
maintenance = { status = "actively-developed" }
|
maintenance = { status = "actively-developed" }
|
||||||
|
|
||||||
[lib]
|
|
||||||
test = false
|
|
||||||
bench = false
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libc = { version = "^0.2.8", default-features = false }
|
libc = { version = "^0.2.8", default-features = false }
|
||||||
|
|
||||||
|
|
|
@ -13,32 +13,7 @@ use std::fs;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
// `jemalloc` is known not to work on these targets:
|
include!("src/env.rs");
|
||||||
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"];
|
|
||||||
|
|
||||||
macro_rules! info {
|
macro_rules! info {
|
||||||
($($args:tt)*) => { println!($($args)*) }
|
($($args:tt)*) => { println!($($args)*) }
|
||||||
|
@ -78,7 +53,11 @@ fn main() {
|
||||||
let mut use_prefix =
|
let mut use_prefix =
|
||||||
env::var("CARGO_FEATURE_UNPREFIXED_MALLOC_ON_SUPPORTED_PLATFORMS").is_err();
|
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!(
|
warning!(
|
||||||
"Unprefixed `malloc` requested on unsupported platform `{}` => using prefixed `malloc`",
|
"Unprefixed `malloc` requested on unsupported platform `{}` => using prefixed `malloc`",
|
||||||
target
|
target
|
||||||
|
@ -164,7 +143,9 @@ fn main() {
|
||||||
.env("CFLAGS", cflags.clone())
|
.env("CFLAGS", cflags.clone())
|
||||||
.env("LDFLAGS", cflags.clone())
|
.env("LDFLAGS", cflags.clone())
|
||||||
.env("CPPFLAGS", cflags)
|
.env("CPPFLAGS", cflags)
|
||||||
.arg("--disable-cxx");
|
.arg("--disable-cxx")
|
||||||
|
.arg("--enable-doc=no")
|
||||||
|
.arg("--enable-shared=no");
|
||||||
|
|
||||||
if target.contains("ios") {
|
if target.contains("ios") {
|
||||||
// newer iOS deviced have 16kb page sizes:
|
// newer iOS deviced have 16kb page sizes:
|
||||||
|
@ -307,7 +288,7 @@ fn main() {
|
||||||
if target.contains("android") {
|
if target.contains("android") {
|
||||||
println!("cargo:rustc-link-lib=gcc");
|
println!("cargo:rustc-link-lib=gcc");
|
||||||
} else if !target.contains("windows") {
|
} 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
|
// 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
|
// during the final linking. https://github.com/riscv-collab/riscv-gcc/issues/12
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
5.2.1-2-g172143a2979d9d948035423ce347e35cd1388fc3
|
5.3.0-0-g54eaed1d8b56b1aa528be3bdd1877e59c56fa90c
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1 +1 @@
|
||||||
Subproject commit 172143a2979d9d948035423ce347e35cd1388fc3
|
Subproject commit 54eaed1d8b56b1aa528be3bdd1877e59c56fa90c
|
|
@ -0,0 +1,25 @@
|
||||||
|
/// `jemalloc` is known not to work on these targets:
|
||||||
|
pub static UNSUPPORTED_TARGETS: &[&str] = &[
|
||||||
|
"rumprun",
|
||||||
|
"bitrig",
|
||||||
|
"emscripten",
|
||||||
|
"fuchsia",
|
||||||
|
"redox",
|
||||||
|
"wasm32",
|
||||||
|
];
|
||||||
|
|
||||||
|
/// `jemalloc-sys` is not tested on these targets in CI:
|
||||||
|
pub static UNTESTED_TARGETS: &[&str] = &["openbsd", "msvc"];
|
||||||
|
|
||||||
|
/// `jemalloc`'s background_thread support is known not to work on these targets:
|
||||||
|
pub static 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
|
||||||
|
pub static NO_UNPREFIXED_MALLOC_TARGETS: &[&str] = &["android", "dragonfly", "musl", "darwin"];
|
|
@ -59,7 +59,7 @@ type c_bool = c_int;
|
||||||
///
|
///
|
||||||
/// It does not validate that `la` is within the valid range.
|
/// It does not validate that `la` is within the valid range.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn MALLOCX_LG_ALIGN(la: usize) -> c_int {
|
pub const fn MALLOCX_LG_ALIGN(la: usize) -> c_int {
|
||||||
la as c_int
|
la as c_int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ pub fn MALLOCX_LG_ALIGN(la: usize) -> c_int {
|
||||||
///
|
///
|
||||||
/// This macro does not validate that a is a power of 2.
|
/// This macro does not validate that a is a power of 2.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn MALLOCX_ALIGN(aling: usize) -> c_int {
|
pub const fn MALLOCX_ALIGN(aling: usize) -> c_int {
|
||||||
aling.trailing_zeros() as c_int
|
aling.trailing_zeros() as c_int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ pub const MALLOCX_ZERO: c_int = 0x40;
|
||||||
/// `tc` must have been acquired via the `tcache.create mallctl`. This function
|
/// `tc` must have been acquired via the `tcache.create mallctl`. This function
|
||||||
/// does not validate that `tc` specifies a valid identifier.
|
/// does not validate that `tc` specifies a valid identifier.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn MALLOCX_TCACHE(tc: usize) -> c_int {
|
pub const fn MALLOCX_TCACHE(tc: usize) -> c_int {
|
||||||
tc.wrapping_add(2).wrapping_shl(8) as c_int
|
tc.wrapping_add(2).wrapping_shl(8) as c_int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,10 +104,7 @@ pub fn MALLOCX_TCACHE(tc: usize) -> c_int {
|
||||||
/// This option cannot be used in the same `flags` argument as
|
/// This option cannot be used in the same `flags` argument as
|
||||||
/// `MALLOCX_TCACHE(tc)`.
|
/// `MALLOCX_TCACHE(tc)`.
|
||||||
// FIXME: This should just be a const.
|
// FIXME: This should just be a const.
|
||||||
#[inline]
|
pub const MALLOCX_TCACHE_NONE: c_int = MALLOCX_TCACHE((-1isize) as usize);
|
||||||
pub fn MALLOCX_TCACHE_NONE() -> c_int {
|
|
||||||
MALLOCX_TCACHE(!0)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Use the arena specified by the index `a`.
|
/// Use the arena specified by the index `a`.
|
||||||
///
|
///
|
||||||
|
@ -119,7 +116,7 @@ pub fn MALLOCX_TCACHE_NONE() -> c_int {
|
||||||
/// This function does not validate that `a` specifies an arena index in the
|
/// This function does not validate that `a` specifies an arena index in the
|
||||||
/// valid range.
|
/// valid range.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn MALLOCX_ARENA(a: usize) -> c_int {
|
pub const fn MALLOCX_ARENA(a: usize) -> c_int {
|
||||||
(a as c_int).wrapping_add(1).wrapping_shl(20)
|
(a as c_int).wrapping_add(1).wrapping_shl(20)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -899,3 +896,8 @@ pub extern "C" fn pthread_atfork(
|
||||||
) -> i32 {
|
) -> i32 {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(missing_docs)]
|
||||||
|
mod env;
|
||||||
|
|
||||||
|
pub use env::*;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "tikv-jemallocator-global"
|
name = "tikv-jemallocator-global"
|
||||||
# Make sure to update the version in the readme as well:
|
# Make sure to update the version in the readme as well:
|
||||||
version = "0.4.0"
|
version = "0.4.3"
|
||||||
authors = [
|
authors = [
|
||||||
"Gonzalo Brito Gadeschi <gonzalobg88@gmail.com>",
|
"Gonzalo Brito Gadeschi <gonzalobg88@gmail.com>",
|
||||||
"The TiKV Project Developers",
|
"The TiKV Project Developers",
|
||||||
|
@ -26,7 +26,7 @@ is-it-maintained-open-issues = { repository = "tikv/jemallocator" }
|
||||||
maintenance = { status = "actively-developed" }
|
maintenance = { status = "actively-developed" }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tikv-jemallocator = { version = "0.4.0", path = "..", optional = true }
|
tikv-jemallocator = { version = "0.4.0", path = "../jemallocator", optional = true }
|
||||||
cfg-if = "0.1"
|
cfg-if = "0.1"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -38,11 +38,11 @@ force_global_jemalloc = [ "tikv-jemallocator" ]
|
||||||
# for a particular target, white-list the target explicitly here:
|
# for a particular target, white-list the target explicitly here:
|
||||||
|
|
||||||
[target.'cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))'.dependencies]
|
[target.'cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))'.dependencies]
|
||||||
tikv-jemallocator = { version = "0.4.0", path = "..", optional = false }
|
tikv-jemallocator = { version = "0.4.0", path = "../jemallocator", optional = false }
|
||||||
|
|
||||||
# FIXME: https://github.com/gnzlbg/jemallocator/issues/91
|
# FIXME: https://github.com/gnzlbg/jemallocator/issues/91
|
||||||
# [target.'cfg(target_os = "windows")'.dependencies]
|
# [target.'cfg(target_os = "windows")'.dependencies]
|
||||||
# jemallocator = { path = ".." }
|
# jemallocator = { path = "../jemallocator" }
|
||||||
|
|
||||||
# `jemalloc` is known not to work on - see `jemalloc-sys/build.rs`.
|
# `jemalloc` is known not to work on - see `jemalloc-sys/build.rs`.
|
||||||
# - rumprun
|
# - rumprun
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
[package]
|
||||||
|
name = "tikv-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
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
tikv-jemalloc-sys = { path = "../jemalloc-sys", version = "0.4.0", default-features = false }
|
||||||
|
libc = { version = "^0.2.8", default-features = false }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
paste = "1"
|
||||||
|
tikv-jemalloc-ctl = { path = "../jemalloc-ctl", version = "0.4.0" }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["background_threads_runtime_support"]
|
||||||
|
alloc_trait = []
|
||||||
|
profiling = ["tikv-jemalloc-sys/profiling"]
|
||||||
|
debug = ["tikv-jemalloc-sys/debug"]
|
||||||
|
stats = ["tikv-jemalloc-sys/stats"]
|
||||||
|
background_threads_runtime_support = ["tikv-jemalloc-sys/background_threads_runtime_support"]
|
||||||
|
background_threads = ["tikv-jemalloc-sys/background_threads"]
|
||||||
|
unprefixed_malloc_on_supported_platforms = ["tikv-jemalloc-sys/unprefixed_malloc_on_supported_platforms"]
|
||||||
|
disable_initial_exec_tls = ["tikv-jemalloc-sys/disable_initial_exec_tls"]
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
features = []
|
||||||
|
rustdoc-args = [ "--cfg", "jemallocator_docs" ]
|
|
@ -1,13 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "systest"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Alex Crichton <alex@alexcrichton.com>"]
|
|
||||||
build = "build.rs"
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
tikv-jemalloc-sys = { path = "../jemalloc-sys" }
|
|
||||||
libc = "0.2"
|
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
ctest = "0.2.22"
|
|
|
@ -1,32 +0,0 @@
|
||||||
use std::env;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
const FUNCTION_POINTER: &[&str] = &[
|
|
||||||
"extent_alloc_t",
|
|
||||||
"extent_dalloc_t",
|
|
||||||
"extent_destroy_t",
|
|
||||||
"extent_commit_t",
|
|
||||||
"extent_decommit_t",
|
|
||||||
"extent_purge_t",
|
|
||||||
"extent_split_t",
|
|
||||||
"extent_merge_t",
|
|
||||||
];
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let root = PathBuf::from(env::var_os("DEP_JEMALLOC_ROOT").unwrap());
|
|
||||||
|
|
||||||
let mut cfg = ctest::TestGenerator::new();
|
|
||||||
cfg.header("jemalloc/jemalloc.h")
|
|
||||||
.include(root.join("include"))
|
|
||||||
.cfg("prefixed", None)
|
|
||||||
.fn_cname(|rust, link_name| link_name.unwrap_or(rust).to_string())
|
|
||||||
.skip_signededness(|c| c.ends_with("_t"))
|
|
||||||
// No need to test pure C function pointer.
|
|
||||||
.skip_type(|name| FUNCTION_POINTER.contains(&name));
|
|
||||||
|
|
||||||
if cfg!(target_os = "linux") {
|
|
||||||
cfg.skip_fn(|f| f == "malloc_usable_size");
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg.generate("../jemalloc-sys/src/lib.rs", "all.rs");
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
// TODO: remove systest
|
|
||||||
#![allow(bad_style, improper_ctypes, dead_code, unused_imports, deref_nullptr)]
|
|
||||||
#![allow(clippy::all)]
|
|
||||||
|
|
||||||
use std::alloc::System;
|
|
||||||
|
|
||||||
#[global_allocator]
|
|
||||||
static A: System = System;
|
|
||||||
|
|
||||||
use libc::{c_char, c_int, c_void};
|
|
||||||
use tikv_jemalloc_sys::*;
|
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/all.rs"));
|
|
Loading…
Reference in New Issue