From dbc7fb527b7d549a98a17f83d137822875ce1c02 Mon Sep 17 00:00:00 2001 From: Al Liu Date: Tue, 17 Oct 2023 19:26:41 +0800 Subject: [PATCH] Fix CI --- .github/workflows/ci.yml | 5 ++--- Cargo.toml | 2 +- ci/sanitizer.sh | 10 +--------- src/lfu.rs | 8 +++++--- src/lfu/tinylfu.rs | 2 +- src/lfu/tinylfu/bloom.rs | 2 +- src/lfu/tinylfu/sketch/count_min_row.rs | 2 +- src/lfu/tinylfu/sketch/count_min_sketch_core.rs | 2 +- src/lfu/tinylfu/sketch/count_min_sketch_std.rs | 2 +- src/lib.rs | 4 ++-- src/lru/segmented.rs | 2 +- 11 files changed, 17 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd092aa..5f3df7d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -82,7 +82,6 @@ jobs: - riscv64gc-unknown-linux-gnu - wasm32-unknown-unknown - wasm32-unknown-emscripten - - wasm32-wasi runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -102,7 +101,7 @@ jobs: run: | cargo install cross cross build --target ${{ matrix.target }} - if: matrix.target != 'wasm32-unknown-unknown' + if: matrix.target != 'wasm32-wasi' - name: cargo build --target ${{ matrix.target }} run: | rustup target add ${{ matrix.target }} @@ -198,7 +197,7 @@ jobs: run: rustup update $nightly && rustup default $nightly - name: Install rust-src run: rustup component add rust-src - - name: ASAN / LSAN / TSAN + - name: LSAN run: ci/sanitizer.sh miri: diff --git a/Cargo.toml b/Cargo.toml index f1e7561..9f1331d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ getrandom = { version = "0.2", features = ["js"] } [features] default = ["std"] std = ["rand", "rand/std", "rand/std_rng"] -# nightly = ["rand/nightly"] +nightly = ["rand/nightly"] [dependencies] hashbrown = { version = "0.14", optional = true } diff --git a/ci/sanitizer.sh b/ci/sanitizer.sh index 5ecefa9..68ea416 100755 --- a/ci/sanitizer.sh +++ b/ci/sanitizer.sh @@ -4,14 +4,6 @@ set -ex export ASAN_OPTIONS="detect_odr_violation=0 detect_leaks=0" -# Run address sanitizer with cargo-hack -RUSTFLAGS="-Z sanitizer=address" \ -cargo test --lib - -# Run leak sanitizer with cargo-hack +# Run leak sanitizer RUSTFLAGS="-Z sanitizer=leak" \ cargo test --lib - -# Run thread sanitizer with cargo-hack -RUSTFLAGS="-Z sanitizer=thread" \ -cargo -Zbuild-std test --lib diff --git a/src/lfu.rs b/src/lfu.rs index 442bb31..95d5710 100644 --- a/src/lfu.rs +++ b/src/lfu.rs @@ -2,10 +2,12 @@ //! //! This module contains LFU based caches, [`WTinyLFUCache`], [`TinyLFU`] and [`SampledLFU`]. //! -pub mod sampled; -pub mod tinylfu; -mod wtinylfu; +mod sampled; +pub use sampled::SampledLFU; +mod tinylfu; +pub use tinylfu::TinyLFU; +mod wtinylfu; pub use wtinylfu::{WTinyLFUCache, WTinyLFUCacheBuilder}; use crate::{DefaultHashBuilder, KeyRef}; diff --git a/src/lfu/tinylfu.rs b/src/lfu/tinylfu.rs index 6d89015..f80d27b 100644 --- a/src/lfu/tinylfu.rs +++ b/src/lfu/tinylfu.rs @@ -200,7 +200,7 @@ impl> TinyLFU { keys.iter().for_each(|k| self.increment(k)) } - /// increment multiple hashed keys, for details, please see [`increment_hash`]. + /// increment multiple hashed keys, for details, please see [`increment_keys`]. /// /// [`increment_hashed_key`]: struct.TinyLFU.method.increment_hashed_key.html pub fn increment_hashed_keys(&mut self, khs: &[u64]) { diff --git a/src/lfu/tinylfu/bloom.rs b/src/lfu/tinylfu/bloom.rs index ed64a6c..20754c1 100644 --- a/src/lfu/tinylfu/bloom.rs +++ b/src/lfu/tinylfu/bloom.rs @@ -1,6 +1,6 @@ //! This mod implements a Simple Bloom Filter. //! -//! This file is a mechanical translation of the reference Golang code, available at https://github.com/dgraph-io/ristretto/blob/master/z/bbloom.go +//! This file is a mechanical translation of the reference Golang code, available at [here](https://github.com/dgraph-io/ristretto/blob/master/z/bbloom.go) //! //! I claim no additional copyright over the original implementation. use alloc::vec; diff --git a/src/lfu/tinylfu/sketch/count_min_row.rs b/src/lfu/tinylfu/sketch/count_min_row.rs index cacc033..e2f7217 100644 --- a/src/lfu/tinylfu/sketch/count_min_row.rs +++ b/src/lfu/tinylfu/sketch/count_min_row.rs @@ -1,6 +1,6 @@ //! This mod implements Count Min Row. //! -//! This file is a mechanical translation of the reference Golang code, available at https://github.com/dgryski/go-tinylfu/blob/master/cm4.go +//! This file is a mechanical translation of the reference Golang code, available at [here](https://github.com/dgryski/go-tinylfu/blob/master/cm4.go) //! //! I claim no additional copyright over the original implementation. use alloc::fmt::format; diff --git a/src/lfu/tinylfu/sketch/count_min_sketch_core.rs b/src/lfu/tinylfu/sketch/count_min_sketch_core.rs index 783d078..de5c14b 100644 --- a/src/lfu/tinylfu/sketch/count_min_sketch_core.rs +++ b/src/lfu/tinylfu/sketch/count_min_sketch_core.rs @@ -1,6 +1,6 @@ //! This mod implements Count-Min sketch with 4-bit counters. //! -//! This file is a mechanical translation of the reference Golang code, available at https://github.com/dgryski/go-tinylfu/blob/master/cm4.go +//! This file is a mechanical translation of the reference Golang code, available at [here](https://github.com/dgryski/go-tinylfu/blob/master/cm4.go) //! //! I claim no additional copyright over the original implementation. use crate::lfu::tinylfu::error::TinyLFUError; diff --git a/src/lfu/tinylfu/sketch/count_min_sketch_std.rs b/src/lfu/tinylfu/sketch/count_min_sketch_std.rs index 13445b4..14afeff 100644 --- a/src/lfu/tinylfu/sketch/count_min_sketch_std.rs +++ b/src/lfu/tinylfu/sketch/count_min_sketch_std.rs @@ -1,6 +1,6 @@ //! This mod implements Count-Min sketch with 4-bit counters. //! -//! This file is a mechanical translation of the reference Golang code, available at https://github.com/dgraph-io/ristretto/blob/master/sketch.go +//! This file is a mechanical translation of the reference Golang code, available at [here](https://github.com/dgraph-io/ristretto/blob/master/sketch.go) //! //! I claim no additional copyright over the original implementation. use std::time::{SystemTime, UNIX_EPOCH}; diff --git a/src/lib.rs b/src/lib.rs index 21e9399..72de00a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -49,7 +49,7 @@ //! - [ ] `0.4`: Add ttl feature to support //! //! ## Related -//! If you want a high-performance thread-safe modern cache, please see https://crates.io/crates/stretto +//! If you want a high-performance thread-safe modern cache, please see [stretto](https://crates.io/crates/stretto) //! //! ## Acknowledgments //! - The implementation of `RawLRU` is highly inspired by @@ -88,7 +88,7 @@ #![no_std] #![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr(docsrs, allow(unused_attributes))] -// #![cfg_attr(feature = "nightly", feature(negative_impls, auto_traits))] +#![cfg_attr(feature = "nightly", feature(negative_impls, auto_traits))] #![deny(missing_docs)] #![allow(clippy::blocks_in_if_conditions)] diff --git a/src/lru/segmented.rs b/src/lru/segmented.rs index 9020849..53b4657 100644 --- a/src/lru/segmented.rs +++ b/src/lru/segmented.rs @@ -188,7 +188,7 @@ impl SegmentedCache { } impl SegmentedCache { - /// Create a [`AdaptiveCache`] from [`SegmentedCacheBuilder`]. + /// Create a [`SegmentedCache`] from [`SegmentedCacheBuilder`]. /// /// # Example /// ```rust