diff --git a/Cargo.toml b/Cargo.toml index e3912a849..661db2013 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,2 +1,7 @@ [workspace] -members = ["jemallocator", "jemallocator-global", "jemalloc-ctl", "jemalloc-sys"] +members = [ + "jemallocator", + "jemallocator-global", + "jemalloc-ctl", + "jemalloc-sys", +] diff --git a/jemalloc-ctl/Cargo.toml b/jemalloc-ctl/Cargo.toml index a1e450c58..722ee9a83 100644 --- a/jemalloc-ctl/Cargo.toml +++ b/jemalloc-ctl/Cargo.toml @@ -2,13 +2,13 @@ name = "tikv-jemalloc-ctl" version = "0.6.0" authors = [ - "Steven Fackler ", - "Gonzalo Brito Gadeschi ", - "The TiKV Project Developers", + "Steven Fackler ", + "Gonzalo Brito Gadeschi ", + "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" @@ -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" } @@ -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"] diff --git a/jemalloc-ctl/rustfmt.toml b/jemalloc-ctl/rustfmt.toml index b3c83c4e6..a1ffd27ad 100644 --- a/jemalloc-ctl/rustfmt.toml +++ b/jemalloc-ctl/rustfmt.toml @@ -1 +1 @@ -max_width = 79 \ No newline at end of file +max_width = 79 diff --git a/jemalloc-ctl/src/macros.rs b/jemalloc-ctl/src/macros.rs index 23f48e7f5..302c11318 100644 --- a/jemalloc-ctl/src/macros.rs +++ b/jemalloc-ctl/src/macros.rs @@ -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; @@ -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`]. @@ -36,7 +36,7 @@ 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); } }; } @@ -44,7 +44,7 @@ macro_rules! types { /// 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> { @@ -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; @@ -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" @@ -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<()> { @@ -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; @@ -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" @@ -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> { @@ -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; @@ -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" diff --git a/jemalloc-sys/Cargo.toml b/jemalloc-sys/Cargo.toml index c99204cf3..f6428c4cb 100644 --- a/jemalloc-sys/Cargo.toml +++ b/jemalloc-sys/Cargo.toml @@ -2,9 +2,9 @@ name = "tikv-jemalloc-sys" version = "0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7" authors = [ - "Alex Crichton ", - "Gonzalo Brito Gadeschi ", - "The TiKV Project Developers", + "Alex Crichton ", + "Gonzalo Brito Gadeschi ", + "The TiKV Project Developers", ] build = "build.rs" links = "jemalloc" @@ -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] @@ -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"] diff --git a/jemallocator-global/Cargo.toml b/jemallocator-global/Cargo.toml index 492f1f8fc..f44b63293 100644 --- a/jemallocator-global/Cargo.toml +++ b/jemallocator-global/Cargo.toml @@ -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 ", - "The TiKV Project Developers", + "Gonzalo Brito Gadeschi ", + "The TiKV Project Developers", ] edition = "2018" license = "MIT/Apache-2.0" @@ -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: @@ -51,4 +51,3 @@ tikv-jemallocator = { version = "0.6.0", path = "../jemallocator", optional = fa # - fuchsia # - emscripten # - wasm32 - diff --git a/jemallocator/Cargo.toml b/jemallocator/Cargo.toml index bee366359..84c8652a0 100644 --- a/jemallocator/Cargo.toml +++ b/jemallocator/Cargo.toml @@ -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 ", - "Gonzalo Brito Gadeschi ", - "Simon Sapin ", - "Steven Fackler ", - "The TiKV Project Developers", + "Alex Crichton ", + "Gonzalo Brito Gadeschi ", + "Simon Sapin ", + "Steven Fackler ", + "The TiKV Project Developers", ] license = "MIT/Apache-2.0" readme = "README.md" @@ -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] @@ -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"] diff --git a/jemallocator/benches/roundtrip.rs b/jemallocator/benches/roundtrip.rs index 6234a124e..5c277946b 100644 --- a/jemallocator/benches/roundtrip.rs +++ b/jemallocator/benches/roundtrip.rs @@ -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 [](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()); @@ -56,7 +56,7 @@ macro_rules! rt { } #[bench] - fn [](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()); @@ -69,7 +69,7 @@ macro_rules! rt { } #[bench] - fn [](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(); @@ -79,7 +79,7 @@ macro_rules! rt { } #[bench] - fn [](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(); @@ -89,7 +89,7 @@ macro_rules! rt { } #[bench] - fn [](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(); @@ -99,7 +99,7 @@ macro_rules! rt { } #[bench] - fn [](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(); @@ -110,7 +110,7 @@ macro_rules! rt { } #[bench] - fn [](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()); @@ -121,7 +121,7 @@ macro_rules! rt { } #[bench] - fn [](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()); @@ -133,7 +133,7 @@ macro_rules! rt { } #[bench] - fn [](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(); @@ -154,7 +154,7 @@ macro_rules! rt { } #[bench] - fn [](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(); @@ -169,7 +169,7 @@ macro_rules! rt { } #[bench] - fn [](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(); @@ -186,7 +186,7 @@ macro_rules! rt { } #[bench] - fn [](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();