diff --git a/Cargo.lock b/Cargo.lock index 1674fa1be941..1a7f539d17e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3241,7 +3241,6 @@ dependencies = [ "bytes", "hashbrown 0.14.3", "hashlink 0.8.4", - "heapsize", ] [[package]] @@ -8769,15 +8768,6 @@ dependencies = [ "stable_deref_trait", ] -[[package]] -name = "heapsize" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" -dependencies = [ - "winapi", -] - [[package]] name = "heck" version = "0.3.3" diff --git a/src/common/cache/Cargo.toml b/src/common/cache/Cargo.toml index 5da2c73fb4dc..b988ead2be6c 100644 --- a/src/common/cache/Cargo.toml +++ b/src/common/cache/Cargo.toml @@ -10,17 +10,11 @@ edition = { workspace = true } doctest = false test = true -[features] -heapsize = ["heapsize_"] - [dependencies] bytes = { workspace = true } hashbrown = { workspace = true } hashlink = "0.8" -[target.'cfg(not(target_os = "macos"))'.dependencies] -heapsize_ = { package = "heapsize", version = "0.4.2", optional = true } - [dev-dependencies] [lints] diff --git a/src/common/cache/src/cache/lru.rs b/src/common/cache/src/cache/lru.rs index 76f63c858efd..93aff6620c3f 100644 --- a/src/common/cache/src/cache/lru.rs +++ b/src/common/cache/src/cache/lru.rs @@ -42,17 +42,12 @@ //! ``` //! //! The cache can also be limited by an arbitrary metric calculated from its key-value pairs, see -//! [`LruCache::with_meter`][with_meter] for more information. If the `heapsize` feature is enabled, -//! this crate provides one such alternate metric—`HeapSize`. Custom metrics can be written by +//! [`LruCache::with_meter`][with_meter] for more information. Custom metrics can be written by //! implementing the [`Meter`][meter] trait. //! //! [with_meter]: struct.LruCache.html#method.with_meter //! [meter]: trait.Meter.html -#[cfg(feature = "heapsize")] -#[cfg(not(target_os = "macos"))] -extern crate heapsize_; - use std::borrow::Borrow; use std::fmt; use std::hash::BuildHasher; diff --git a/src/common/cache/src/lib.rs b/src/common/cache/src/lib.rs index 68d2c02a5e47..d6f6d452a892 100644 --- a/src/common/cache/src/lib.rs +++ b/src/common/cache/src/lib.rs @@ -14,9 +14,6 @@ #![feature(write_all_vectored)] #![allow(clippy::uninlined_format_args)] -#[cfg(feature = "heapsize")] -#[cfg(not(target_os = "macos"))] -extern crate heapsize_; mod cache; mod meter; @@ -29,7 +26,4 @@ pub use meter::count_meter::Count; pub use meter::count_meter::CountableMeter; pub use meter::count_meter::CountableMeterWithMeasure; pub use meter::file_meter::FileSize; -#[cfg(feature = "heapsize")] -#[cfg(not(target_os = "macos"))] -pub use meter::heap_meter::HeapSize; pub use meter::Meter; diff --git a/src/common/cache/src/meter.rs b/src/common/cache/src/meter.rs index 3478062f970d..c3f2d4730010 100644 --- a/src/common/cache/src/meter.rs +++ b/src/common/cache/src/meter.rs @@ -15,9 +15,6 @@ pub mod bytes_meter; pub mod count_meter; pub mod file_meter; -#[cfg(feature = "heapsize")] -#[cfg(not(target_os = "macos"))] -pub mod heap_meter; use std::borrow::Borrow; diff --git a/src/common/cache/src/meter/heap_meter.rs b/src/common/cache/src/meter/heap_meter.rs deleted file mode 100644 index dfed47a1a9df..000000000000 --- a/src/common/cache/src/meter/heap_meter.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2021 Datafuse Labs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use std::borrow::Borrow; - -use heapsize_::HeapSizeOf; - -use super::Meter; - -/// Size limit based on the heap size of each cache item. -/// -/// Requires cache entries that implement [`HeapSizeOf`][1]. -/// -/// [1]: https://doc.servo.org/heapsize/trait.HeapSizeOf.html -pub struct HeapSize; - -impl Meter for HeapSize { - type Measure = usize; - - fn measure(&self, _: &Q, item: &V) -> usize - where K: Borrow { - item.heap_size_of_children() + ::std::mem::size_of::() - } -} diff --git a/src/common/cache/tests/it/cache/lru.rs b/src/common/cache/tests/it/cache/lru.rs index ae9956afd1d7..4d16e7f9a081 100644 --- a/src/common/cache/tests/it/cache/lru.rs +++ b/src/common/cache/tests/it/cache/lru.rs @@ -206,19 +206,3 @@ fn test_metered_cache_oversize() { assert!(!cache.contains("foo1")); assert!(!cache.contains("foo2")); } - -#[cfg(feature = "heapsize")] -#[cfg(not(target_os = "macos"))] -#[test] -fn test_heapsize_cache() { - use databend_common_cache::HeapSize; - - let mut cache = LruCache::<&str, (u8, u8, u8), _, _>::with_meter(8, HeapSize); - cache.put("foo1", (1, 2, 3)); - cache.put("foo2", (4, 5, 6)); - cache.put("foo3", (7, 8, 9)); - assert!(!cache.contains("foo1")); - cache.put("foo2", (10, 11, 12)); - cache.put("foo4", (13, 14, 15)); - assert!(!cache.contains("foo3")); -}