Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
[workspace]
members = ["jemallocator", "jemallocator-global", "jemalloc-ctl", "jemalloc-sys"]
members = [
"jemallocator",
"jemallocator-global",
"jemalloc-ctl",
"jemalloc-sys",
]
14 changes: 7 additions & 7 deletions jemalloc-ctl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
name = "tikv-jemalloc-ctl"
version = "0.6.0"
authors = [
"Steven Fackler <[email protected]>",
"Gonzalo Brito Gadeschi <[email protected]>",
"The TiKV Project Developers",
"Steven Fackler <[email protected]>",
"Gonzalo Brito Gadeschi <[email protected]>",
"The TiKV Project Developers",
]
license = "MIT/Apache-2.0"
readme = "README.md"
categories = ["memory-management", "api-bindings", "development-tools" ]
categories = ["memory-management", "api-bindings", "development-tools"]
keywords = ["allocator", "jemalloc"]
repository = "https://github.com/tikv/jemallocator"
homepage = "https://github.com/tikv/jemallocator"
Expand All @@ -28,7 +28,7 @@ maintenance = { status = "actively-developed" }
[dependencies]
tikv-jemalloc-sys = { path = "../jemalloc-sys", version = "0.6.0" }
libc = { version = "0.2", default-features = false }
paste = "1"
preinterpret = "0.2.0"

[dev-dependencies]
tikv-jemallocator = { path = "../jemallocator", version = "0.6.0" }
Expand All @@ -37,9 +37,9 @@ tikv-jemallocator = { path = "../jemallocator", version = "0.6.0" }
default = []
stats = ["tikv-jemalloc-sys/stats"]
profiling = ["tikv-jemalloc-sys/profiling"]
use_std = [ "libc/use_std" ]
use_std = ["libc/use_std"]
disable_initial_exec_tls = ["tikv-jemalloc-sys/disable_initial_exec_tls"]

[package.metadata.docs.rs]
rustdoc-args = [ "--cfg", "jemallocator_docs" ]
rustdoc-args = ["--cfg", "jemallocator_docs"]
features = ["stats", "profiling", "use_std"]
2 changes: 1 addition & 1 deletion jemalloc-ctl/rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
max_width = 79
max_width = 79
26 changes: 13 additions & 13 deletions jemalloc-ctl/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ macro_rules! types {
docs: $(#[$doc:meta])*
mib_docs: $(#[$doc_mib:meta])*
) => {
paste::paste! {
preinterpret::preinterpret! {
$(#[$doc])*
#[allow(non_camel_case_types)]
pub struct $id;
Expand All @@ -22,8 +22,8 @@ macro_rules! types {
/// Returns Management Information Base (MIB)
///
/// This value can be used to access the key without doing string lookup.
pub fn mib() -> crate::error::Result<[<$id _mib>]> {
Ok([<$id _mib>](Self::NAME.$name_to_mib()?))
pub fn mib() -> crate::error::Result<[!ident! $id _mib]> {
Ok([!ident! $id _mib](Self::NAME.$name_to_mib()?))
}

/// Key [`crate::keys::Name`].
Expand All @@ -36,15 +36,15 @@ macro_rules! types {
#[repr(transparent)]
#[derive(Copy, Clone)]
#[allow(non_camel_case_types)]
pub struct [<$id _mib>](pub crate::keys::$mib);
pub struct [!ident! $id _mib](pub crate::keys::$mib);
}
};
}

/// Read
macro_rules! r {
($id:ident => $ret_ty:ty) => {
paste::paste! {
preinterpret::preinterpret! {
impl $id {
/// Reads value using string API.
pub fn read() -> crate::error::Result<$ret_ty> {
Expand All @@ -53,7 +53,7 @@ macro_rules! r {
}
}

impl [<$id _mib>] {
impl [!ident! $id _mib] {
/// Reads value using MIB API.
pub fn read(self) -> crate::error::Result<$ret_ty> {
use crate::keys::Access;
Expand All @@ -64,7 +64,7 @@ macro_rules! r {
#[cfg(test)]
#[test]
#[allow(unused)]
fn [<$id _read_test>]() {
fn [!ident! $id _read_test]() {
match stringify!($id) {
"background_thread" |
"max_background_threads"
Expand Down Expand Up @@ -92,7 +92,7 @@ macro_rules! r {
/// Write
macro_rules! w {
($id:ident => $ret_ty:ty) => {
paste::paste! {
preinterpret::preinterpret! {
impl $id {
/// Writes `value` using string API.
pub fn write(value: $ret_ty) -> crate::error::Result<()> {
Expand All @@ -101,7 +101,7 @@ macro_rules! w {
}
}

impl [<$id _mib>] {
impl [!ident! $id _mib] {
/// Writes `value` using MIB API.
pub fn write(self, value: $ret_ty) -> crate::error::Result<()> {
use crate::keys::Access;
Expand All @@ -111,7 +111,7 @@ macro_rules! w {

#[cfg(test)]
#[test]
fn [<$id _write_test>]() {
fn [!ident! $id _write_test]() {
match stringify!($id) {
"background_thread" |
"max_background_threads"
Expand Down Expand Up @@ -140,7 +140,7 @@ macro_rules! w {
/// Update
macro_rules! u {
($id:ident => $ret_ty:ty) => {
paste::paste! {
preinterpret::preinterpret! {
impl $id {
/// Updates key to `value` returning its old value using string API.
pub fn update(value: $ret_ty) -> crate::error::Result<$ret_ty> {
Expand All @@ -149,7 +149,7 @@ macro_rules! u {
}
}

impl [<$id _mib>] {
impl [!ident! $id _mib] {
/// Updates key to `value` returning its old value using MIB API.
pub fn update(self, value: $ret_ty) -> crate::error::Result<$ret_ty> {
use crate::keys::Access;
Expand All @@ -160,7 +160,7 @@ macro_rules! u {
#[cfg(test)]
#[test]
#[allow(unused)]
fn [<$id _update_test>]() {
fn [!ident! $id _update_test]() {
match stringify!($id) {
"background_thread" |
"max_background_threads"
Expand Down
14 changes: 7 additions & 7 deletions jemalloc-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
name = "tikv-jemalloc-sys"
version = "0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7"
authors = [
"Alex Crichton <[email protected]>",
"Gonzalo Brito Gadeschi <[email protected]>",
"The TiKV Project Developers",
"Alex Crichton <[email protected]>",
"Gonzalo Brito Gadeschi <[email protected]>",
"The TiKV Project Developers",
]
build = "build.rs"
links = "jemalloc"
Expand All @@ -28,8 +28,8 @@ maintenance = { status = "actively-developed" }

[lints.rust]
unexpected_cfgs = { level = "allow", check-cfg = [
'cfg(jemallocator_docs)',
'cfg(prefixed)',
'cfg(jemallocator_docs)',
'cfg(prefixed)',
] }

[dependencies]
Expand All @@ -43,11 +43,11 @@ default = ["background_threads_runtime_support"]
profiling = []
debug = []
background_threads_runtime_support = []
background_threads = [ "background_threads_runtime_support" ]
background_threads = ["background_threads_runtime_support"]
stats = []
unprefixed_malloc_on_supported_platforms = []
disable_initial_exec_tls = []
disable_cache_oblivious = []

[package.metadata.docs.rs]
rustdoc-args = [ "--cfg", "jemallocator_docs" ]
rustdoc-args = ["--cfg", "jemallocator_docs"]
7 changes: 3 additions & 4 deletions jemallocator-global/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name = "tikv-jemallocator-global"
# Make sure to update the version in the readme as well:
version = "0.6.0"
authors = [
"Gonzalo Brito Gadeschi <[email protected]>",
"The TiKV Project Developers",
"Gonzalo Brito Gadeschi <[email protected]>",
"The TiKV Project Developers",
]
edition = "2018"
license = "MIT/Apache-2.0"
Expand Down Expand Up @@ -32,7 +32,7 @@ cfg-if = "0.1"
[features]
default = []
# Unconditionally sets jemalloc as the global allocator:
force_global_jemalloc = [ "tikv-jemallocator" ]
force_global_jemalloc = ["tikv-jemallocator"]

# To enable `jemalloc` as the `#[global_allocator]` by default
# for a particular target, white-list the target explicitly here:
Expand All @@ -51,4 +51,3 @@ tikv-jemallocator = { version = "0.6.0", path = "../jemallocator", optional = fa
# - fuchsia
# - emscripten
# - wasm32

22 changes: 13 additions & 9 deletions jemallocator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name = "tikv-jemallocator"
# Make sure to update the version in the README as well:
version = "0.6.0"
authors = [
"Alex Crichton <[email protected]>",
"Gonzalo Brito Gadeschi <[email protected]>",
"Simon Sapin <[email protected]>",
"Steven Fackler <[email protected]>",
"The TiKV Project Developers",
"Alex Crichton <[email protected]>",
"Gonzalo Brito Gadeschi <[email protected]>",
"Simon Sapin <[email protected]>",
"Steven Fackler <[email protected]>",
"The TiKV Project Developers",
]
license = "MIT/Apache-2.0"
readme = "README.md"
Expand Down Expand Up @@ -41,7 +41,7 @@ tikv-jemalloc-sys = { path = "../jemalloc-sys", version = "0.6.0", default-featu
libc = { version = "^0.2.8", default-features = false }

[dev-dependencies]
paste = "1"
preinterpret = "0.2.0"
tikv-jemalloc-ctl = { path = "../jemalloc-ctl", version = "0.6.0" }

[features]
Expand All @@ -50,12 +50,16 @@ 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_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"]
unprefixed_malloc_on_supported_platforms = [
"tikv-jemalloc-sys/unprefixed_malloc_on_supported_platforms",
]
disable_initial_exec_tls = ["tikv-jemalloc-sys/disable_initial_exec_tls"]
disable_cache_oblivious = ["tikv-jemalloc-sys/disable_cache_oblivious"]

[package.metadata.docs.rs]
features = []
rustdoc-args = [ "--cfg", "jemallocator_docs" ]
rustdoc-args = ["--cfg", "jemallocator_docs"]
26 changes: 13 additions & 13 deletions jemallocator/benches/roundtrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ fn layout_to_flags(layout: &Layout) -> c_int {

macro_rules! rt {
($size:expr, $align:expr) => {
paste::paste! {
preinterpret::preinterpret! {
#[bench]
fn [<rt_mallocx_size_ $size _align_ $align>](b: &mut Bencher) {
fn [!ident! rt_mallocx_size_ $size _align_ $align](b: &mut Bencher) {
b.iter(|| unsafe {
use jemalloc_sys as jemalloc;
let flags = layout_to_flags(&Layout::from_size_align($size, $align).unwrap());
Expand All @@ -56,7 +56,7 @@ macro_rules! rt {
}

#[bench]
fn [<rt_mallocx_nallocx_size_ $size _align_ $align>](b: &mut Bencher) {
fn [!ident! rt_mallocx_nallocx_size_ $size _align_ $align](b: &mut Bencher) {
b.iter(|| unsafe {
use jemalloc_sys as jemalloc;
let flags = layout_to_flags(&Layout::from_size_align($size, $align).unwrap());
Expand All @@ -69,7 +69,7 @@ macro_rules! rt {
}

#[bench]
fn [<rt_alloc_layout_checked_size_ $size _align_ $align>](b: &mut Bencher) {
fn [!ident! rt_alloc_layout_checked_size_ $size _align_ $align](b: &mut Bencher) {
b.iter(|| unsafe {
let layout = Layout::from_size_align($size, $align).unwrap();
let ptr = Jemalloc.alloc(layout.clone()).unwrap();
Expand All @@ -79,7 +79,7 @@ macro_rules! rt {
}

#[bench]
fn [<rt_alloc_layout_unchecked_size_ $size _align_ $align>](b: &mut Bencher) {
fn [!ident! rt_alloc_layout_unchecked_size_ $size _align_ $align](b: &mut Bencher) {
b.iter(|| unsafe {
let layout = Layout::from_size_align_unchecked($size, $align);
let ptr = Jemalloc.alloc(layout.clone()).unwrap();
Expand All @@ -89,7 +89,7 @@ macro_rules! rt {
}

#[bench]
fn [<rt_alloc_excess_unused_size_ $size _align_ $align>](b: &mut Bencher) {
fn [!ident! rt_alloc_excess_unused_size_ $size _align_ $align](b: &mut Bencher) {
b.iter(|| unsafe {
let layout = Layout::from_size_align($size, $align).unwrap();
let Excess(ptr, _) = Jemalloc.alloc_excess(layout.clone()).unwrap();
Expand All @@ -99,7 +99,7 @@ macro_rules! rt {
}

#[bench]
fn [<rt_alloc_excess_used_size_ $size _align_ $align>](b: &mut Bencher) {
fn [!ident! rt_alloc_excess_used_size_ $size _align_ $align](b: &mut Bencher) {
b.iter(|| unsafe {
let layout = Layout::from_size_align($size, $align).unwrap();
let Excess(ptr, excess) = Jemalloc.alloc_excess(layout.clone()).unwrap();
Expand All @@ -110,7 +110,7 @@ macro_rules! rt {
}

#[bench]
fn [<rt_mallocx_zeroed_size_ $size _align_ $align>](b: &mut Bencher) {
fn [!ident! rt_mallocx_zeroed_size_ $size _align_ $align](b: &mut Bencher) {
b.iter(|| unsafe {
use jemalloc_sys as jemalloc;
let flags = layout_to_flags(&Layout::from_size_align($size, $align).unwrap());
Expand All @@ -121,7 +121,7 @@ macro_rules! rt {
}

#[bench]
fn [<rt_calloc_size_ $size _align_ $align>](b: &mut Bencher) {
fn [!ident! rt_calloc_size_ $size _align_ $align](b: &mut Bencher) {
b.iter(|| unsafe {
use jemalloc_sys as jemalloc;
let flags = layout_to_flags(&Layout::from_size_align($size, $align).unwrap());
Expand All @@ -133,7 +133,7 @@ macro_rules! rt {
}

#[bench]
fn [<rt_realloc_naive_size_ $size _align_ $align>](b: &mut Bencher) {
fn [!ident! rt_realloc_naive_size_ $size _align_ $align](b: &mut Bencher) {
b.iter(|| unsafe {
let layout = Layout::from_size_align($size, $align).unwrap();
let ptr = Jemalloc.alloc(layout.clone()).unwrap();
Expand All @@ -154,7 +154,7 @@ macro_rules! rt {
}

#[bench]
fn [<rt_realloc_size_ $size _align_ $align>](b: &mut Bencher) {
fn [!ident! rt_realloc_size_ $size _align_ $align](b: &mut Bencher) {
b.iter(|| unsafe {
let layout = Layout::from_size_align($size, $align).unwrap();
let ptr = Jemalloc.alloc(layout.clone()).unwrap();
Expand All @@ -169,7 +169,7 @@ macro_rules! rt {
}

#[bench]
fn [<rt_realloc_excess_unused_size_ $size _align_ $align>](b: &mut Bencher) {
fn [!ident! rt_realloc_excess_unused_size_ $size _align_ $align](b: &mut Bencher) {
b.iter(|| unsafe {
let layout = Layout::from_size_align($size, $align).unwrap();
let ptr = Jemalloc.alloc(layout.clone()).unwrap();
Expand All @@ -186,7 +186,7 @@ macro_rules! rt {
}

#[bench]
fn [<rt_realloc_excess_used_size_ $size _align_ $align>](b: &mut Bencher) {
fn [!ident! rt_realloc_excess_used_size_ $size _align_ $align](b: &mut Bencher) {
b.iter(|| unsafe {
let layout = Layout::from_size_align($size, $align).unwrap();
let ptr = Jemalloc.alloc(layout.clone()).unwrap();
Expand Down