diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index c14a51b7..af66656a 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -15,7 +15,7 @@ concurrency:
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
- RUST_TOOLCHAIN_NIGHTLY: nightly-2024-07-19
+ RUST_TOOLCHAIN_NIGHTLY: nightly-2024-08-30
CARGO_TERM_COLOR: always
CACHE_KEY_SUFFIX: 20240821
@@ -122,7 +122,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
- rust_toolchain: [stable, 1.81.0]
+ rust_toolchain: [stable, 1.82.0]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
@@ -164,7 +164,8 @@ jobs:
run: |
cargo clippy --all-targets --features tokio-console -- -D warnings
cargo clippy --all-targets --features deadlock -- -D warnings
- cargo clippy --all-targets --features mtrace -- -D warnings
+ cargo clippy --all-targets --features tracing -- -D warnings
+ cargo clippy --all-targets --features prometheus,prometheus-client_0_22,opentelemetry_0_26,opentelemetry_0_27 -- -D warnings
cargo clippy --all-targets -- -D warnings
- if: steps.cache.outputs.cache-hit != 'true'
uses: taiki-e/install-action@cargo-llvm-cov
@@ -181,7 +182,7 @@ jobs:
RUST_BACKTRACE: 1
CI: true
run: |
- cargo llvm-cov --no-report nextest --features "strict_assertions,sanity"
+ cargo llvm-cov --no-report nextest --features "strict_assertions,sanity,prometheus,prometheus-client_0_22,opentelemetry_0_26,opentelemetry_0_27"
- name: Run examples with coverage
env:
RUST_BACKTRACE: 1
@@ -191,8 +192,10 @@ jobs:
cargo llvm-cov --no-report run --example hybrid
cargo llvm-cov --no-report run --example hybrid_full
cargo llvm-cov --no-report run --example event_listener
- cargo llvm-cov --no-report run --features "mtrace,jaeger" --example tail_based_tracing
- cargo llvm-cov --no-report run --features "mtrace,ot" --example tail_based_tracing
+ cargo llvm-cov --no-report run --features "tracing,jaeger" --example tail_based_tracing
+ cargo llvm-cov --no-report run --features "tracing,ot" --example tail_based_tracing
+ cargo llvm-cov --no-report run --example equivalent
+ cargo llvm-cov --no-report run --example export_metrics_prometheus_hyper
- name: Run foyer-bench with coverage
if: runner.os == 'Linux'
env:
@@ -200,7 +203,9 @@ jobs:
CI: true
run: |
mkdir -p $GITHUB_WORKSPACE/foyer-data/foyer-bench/codecov
- cargo llvm-cov --no-report run --package foyer-bench --bin foyer-bench --features "strict_assertions,sanity" -- --dir $GITHUB_WORKSPACE/foyer-data/foyer-bench/codecov --mem 16MiB --disk 256MiB --region-size 16MiB --get-range 1000 --w-rate 1MiB --r-rate 1MiB --admission-rate-limit 10MiB --time 60
+ cargo llvm-cov --no-report run --package foyer-bench --bin foyer-bench --features "strict_assertions,sanity" -- --dir $GITHUB_WORKSPACE/foyer-data/foyer-bench/codecov --engine large --mem 16MiB --disk 256MiB --region-size 16MiB --get-range 1000 --w-rate 1MiB --r-rate 1MiB --admission-rate-limit 10MiB --entry-size-min 2KiB --entry-size-max 128KiB --time 60
+ cargo llvm-cov --no-report run --package foyer-bench --bin foyer-bench --features "strict_assertions,sanity" -- --dir $GITHUB_WORKSPACE/foyer-data/foyer-bench/codecov --engine small --mem 4MiB --disk 256MiB --region-size 16MiB --get-range 1000 --w-rate 1MiB --r-rate 1MiB --admission-rate-limit 1MiB --entry-size-min 1KiB --entry-size-max 24KiB --time 60
+ cargo llvm-cov --no-report run --package foyer-bench --bin foyer-bench --features "strict_assertions,sanity" -- --dir $GITHUB_WORKSPACE/foyer-data/foyer-bench/codecov --engine mixed=0.1 --mem 16MiB --disk 256MiB --region-size 16MiB --get-range 1000 --w-rate 1MiB --r-rate 1MiB --admission-rate-limit 10MiB --entry-size-min 1KiB --entry-size-max 128KiB --time 60
- name: Generate codecov report
run: |
cargo llvm-cov report --lcov --output-path lcov.info
@@ -240,7 +245,9 @@ jobs:
run: |-
cargo build --all --features deadlock
mkdir -p $GITHUB_WORKSPACE/foyer-data/foyer-storage/deadlock
- timeout 2m ./target/debug/foyer-bench --dir $GITHUB_WORKSPACE/foyer-data/foyer-bench/deadlock --mem 16MiB --disk 256MiB --region-size 16MiB --get-range 1000 --w-rate 1MiB --r-rate 1MiB --admission-rate-limit 10MiB --time 60
+ timeout 2m ./target/debug/foyer-bench --dir $GITHUB_WORKSPACE/foyer-data/foyer-bench/deadlock --engine large --mem 16MiB --disk 256MiB --region-size 16MiB --get-range 1000 --w-rate 1MiB --r-rate 1MiB --admission-rate-limit 10MiB --entry-size-min 2KiB --entry-size-max 128KiB --time 60
+ timeout 2m ./target/debug/foyer-bench --dir $GITHUB_WORKSPACE/foyer-data/foyer-bench/deadlock --engine small --mem 4MiB --disk 256MiB --region-size 16MiB --get-range 1000 --w-rate 1MiB --r-rate 1MiB --admission-rate-limit 1MiB --entry-size-min 1KiB --entry-size-max 24KiB --time 60
+ timeout 2m ./target/debug/foyer-bench --dir $GITHUB_WORKSPACE/foyer-data/foyer-bench/deadlock --engine mixed=0.1 --mem 16MiB --disk 256MiB --region-size 16MiB --get-range 1000 --w-rate 1MiB --r-rate 1MiB --admission-rate-limit 10MiB --entry-size-min 1KiB --entry-size-max 128KiB --time 60
asan:
name: run with address saniziter
runs-on: ubuntu-latest
@@ -278,7 +285,9 @@ jobs:
run: |-
cargo +${{ env.RUST_TOOLCHAIN_NIGHTLY }} build --all --target x86_64-unknown-linux-gnu
mkdir -p $GITHUB_WORKSPACE/foyer-data/foyer-bench/asan
- timeout 2m ./target/x86_64-unknown-linux-gnu/debug/foyer-bench --dir $GITHUB_WORKSPACE/foyer-data/foyer-bench/asan --mem 16MiB --disk 256MiB --region-size 16MiB --get-range 1000 --w-rate 1MiB --r-rate 1MiB --admission-rate-limit 10MiB --time 60
+ timeout 2m ./target/x86_64-unknown-linux-gnu/debug/foyer-bench --dir $GITHUB_WORKSPACE/foyer-data/foyer-bench/asan --engine large --mem 16MiB --disk 256MiB --region-size 16MiB --get-range 1000 --w-rate 1MiB --r-rate 1MiB --admission-rate-limit 10MiB --entry-size-min 2KiB --entry-size-max 128KiB --time 60
+ timeout 2m ./target/x86_64-unknown-linux-gnu/debug/foyer-bench --dir $GITHUB_WORKSPACE/foyer-data/foyer-bench/asan --engine small --mem 4MiB --disk 256MiB --region-size 16MiB --get-range 1000 --w-rate 1MiB --r-rate 1MiB --admission-rate-limit 1MiB --entry-size-min 1KiB --entry-size-max 24KiB --time 60
+ timeout 2m ./target/x86_64-unknown-linux-gnu/debug/foyer-bench --dir $GITHUB_WORKSPACE/foyer-data/foyer-bench/asan --engine mixed=0.1 --mem 16MiB --disk 256MiB --region-size 16MiB --get-range 1000 --w-rate 1MiB --r-rate 1MiB --admission-rate-limit 10MiB --entry-size-min 1KiB --entry-size-max 128KiB --time 60
- name: Prepare Artifacts on Failure
if: ${{ failure() }}
run: |-
@@ -326,7 +335,9 @@ jobs:
run: |-
cargo +${{ env.RUST_TOOLCHAIN_NIGHTLY }} build --all --target x86_64-unknown-linux-gnu
mkdir -p $GITHUB_WORKSPACE/foyer-data/foyer-bench/lsan
- timeout 2m ./target/x86_64-unknown-linux-gnu/debug/foyer-bench --dir $GITHUB_WORKSPACE/foyer-data/foyer-bench/lsan --mem 16MiB --disk 256MiB --region-size 16MiB --get-range 1000 --w-rate 1MiB --r-rate 1MiB --admission-rate-limit 10MiB --time 60
+ timeout 2m ./target/x86_64-unknown-linux-gnu/debug/foyer-bench --dir $GITHUB_WORKSPACE/foyer-data/foyer-bench/lsan --engine large --mem 16MiB --disk 256MiB --region-size 16MiB --get-range 1000 --w-rate 1MiB --r-rate 1MiB --admission-rate-limit 10MiB --entry-size-min 2KiB --entry-size-max 128KiB --time 60
+ timeout 2m ./target/x86_64-unknown-linux-gnu/debug/foyer-bench --dir $GITHUB_WORKSPACE/foyer-data/foyer-bench/lsan --engine small --mem 4MiB --disk 256MiB --region-size 16MiB --get-range 1000 --w-rate 1MiB --r-rate 1MiB --admission-rate-limit 1MiB --entry-size-min 1KiB --entry-size-max 24KiB --time 60
+ timeout 2m ./target/x86_64-unknown-linux-gnu/debug/foyer-bench --dir $GITHUB_WORKSPACE/foyer-data/foyer-bench/lsan --engine mixed=0.1 --mem 16MiB --disk 256MiB --region-size 16MiB --get-range 1000 --w-rate 1MiB --r-rate 1MiB --admission-rate-limit 10MiB --entry-size-min 1KiB --entry-size-max 128KiB --time 60
- name: Prepare Artifacts on Failure
if: ${{ failure() }}
run: |-
@@ -337,43 +348,43 @@ jobs:
with:
name: artifacts.lsan.tgz
path: artifacts.lsan.tgz
- # deterministic-test:
- # name: run deterministic test
- # runs-on: ubuntu-latest
- # steps:
- # - name: Checkout
- # uses: actions/checkout@v4
- # - name: Install rust toolchain
- # uses: dtolnay/rust-toolchain@master
- # with:
- # toolchain: ${{ env.RUST_TOOLCHAIN }}
- # components: rustfmt, clippy
- # - name: Cache Cargo home
- # uses: actions/cache@v4
- # id: cache
- # with:
- # path: |
- # ~/.cargo/bin/
- # ~/.cargo/registry/index/
- # ~/.cargo/registry/cache/
- # ~/.cargo/git/db/
- # key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}-${{ env.CACHE_KEY_SUFFIX }}-deterministic-test
- # - if: steps.cache.outputs.cache-hit != 'true'
- # uses: taiki-e/install-action@nextest
- # - name: Run rust clippy check (madsim)
- # env:
- # RUST_BACKTRACE: 1
- # RUSTFLAGS: "--cfg tokio_unstable --cfg madsim"
- # RUST_LOG: info
- # TOKIO_WORKER_THREADS: 1
- # CI: true
- # run: |-
- # cargo clippy --all-targets
- # - name: Run nextest (madsim)
- # env:
- # RUST_BACKTRACE: 1
- # RUSTFLAGS: "--cfg tokio_unstable --cfg madsim"
- # RUST_LOG: info
- # TOKIO_WORKER_THREADS: 1
- # run: |-
- # cargo nextest run --all
+ madsim:
+ name: check build with madsim
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ - name: Install rust toolchain
+ uses: dtolnay/rust-toolchain@master
+ with:
+ toolchain: ${{ env.RUST_TOOLCHAIN_NIGHTLY }}
+ components: rustfmt, clippy
+ - name: Cache Cargo home
+ uses: actions/cache@v4
+ id: cache
+ with:
+ path: |
+ ~/.cargo/bin/
+ ~/.cargo/registry/index/
+ ~/.cargo/registry/cache/
+ ~/.cargo/git/db/
+ key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}-${{ env.CACHE_KEY_SUFFIX }}-madsim
+ - if: steps.cache.outputs.cache-hit != 'true'
+ uses: taiki-e/install-action@nextest
+ - name: Run rust clippy check (madsim, check only)
+ env:
+ RUST_BACKTRACE: 1
+ RUSTFLAGS: "--cfg tokio_unstable --cfg madsim"
+ RUST_LOG: info
+ TOKIO_WORKER_THREADS: 1
+ CI: true
+ run: |-
+ cargo clippy --all-targets
+ # - name: Run nextest (madsim)
+ # env:
+ # RUST_BACKTRACE: 1
+ # RUSTFLAGS: "--cfg tokio_unstable --cfg madsim"
+ # RUST_LOG: info
+ # TOKIO_WORKER_THREADS: 1
+ # run: |-
+ # cargo nextest run --all --features "strict_assertions,sanity"
diff --git a/.github/workflows/license_check.yml b/.github/workflows/license_check.yml
index 762f4294..bf30028c 100644
--- a/.github/workflows/license_check.yml
+++ b/.github/workflows/license_check.yml
@@ -16,4 +16,4 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Check License Header
- uses: apache/skywalking-eyes/header@df70871af1a8109c9a5b1dc824faaf65246c5236
+ uses: apache/skywalking-eyes/header@v0.6.0
diff --git a/.gitignore b/.gitignore
index e53cc65c..5c844a32 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,4 +11,6 @@ docker-compose.override.yaml
perf.data*
flamegraph.svg
-trace.txt
\ No newline at end of file
+trace.txt
+jeprof.out.*
+*.collapsed
\ No newline at end of file
diff --git a/.licenserc.yaml b/.licenserc.yaml
index bfb4ceb2..0bdd2646 100644
--- a/.licenserc.yaml
+++ b/.licenserc.yaml
@@ -1,7 +1,7 @@
header:
license:
spdx-id: Apache-2.0
- copyright-owner: Foyer Project Authors
+ copyright-owner: foyer Project Authors
paths:
- "**/*.rs"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 17b3fa6b..448e5470 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,141 @@
+---
+title: Changelog
+description: Changelog for foyer.
+authors: mrcroxx
+date: 2023-05-12T11:02:09+08:00
+---
+
+# Changelog
+
+
+
+## Unreleased
+
+### Changes
+
+- Refine in-memory cache framework:
+ - Allow "get"/"release"/"entry drop" to acquire read lock or lock-free if the algorithm allows.
+ - Make most `Eviction` APIs safe, only acquire unsafe Rust while accessing algorithm managed per-entry state with `UnsafeCell`.
+ - Replace the "reinsertion" design with `release` with real "release last ref" design.
+ - Rename some APIs.
+
+## 2024-10-11
+
+### Releases
+
+| crate | version |
+| - | - |
+| foyer | 0.12.2|
+| foyer-common | 0.12.2 |
+| foyer-intrusive | 0.12.2 |
+| foyer-memory | 0.12.2 |
+| foyer-storage | 0.12.2 |
+| foyer-bench | 0.12.2 |
+
+### Changes
+
+- Revert "Scale shards to 1 when there is not enough capacity". It would be useful sometimes. Just raise the warning.
+
+## 2024-10-10
+
+### Releases
+
+| crate | version |
+| - | - |
+| foyer | 0.12.1 |
+| foyer-common | 0.12.1 |
+| foyer-intrusive | 0.12.1 |
+| foyer-memory | 0.12.1 |
+| foyer-storage | 0.12.1 |
+| foyer-bench | 0.12.1 |
+
+### Changes
+
+- Downgrade hashbrown to 0.14 to fix build on nightly for projects using hashbrown < 0.15.
+- Fix build with madsim.
+- Refine small object disk cache.
+- Scale shards to 1 when there is not enough capacity.
+
+## 2024-10-09
+
+### Releases
+
+| crate | version |
+| - | - |
+| foyer | 0.12.0 |
+| foyer-common | 0.12.0 |
+| foyer-intrusive | 0.12.0 |
+| foyer-memory | 0.12.0 |
+| foyer-storage | 0.12.0 |
+| foyer-bench | 0.12.0 |
+
+### Changes
+
+- Align the versions of all components to the same. 📣
+- Introduce small object disk cache. 🎉
+- Introduce mixed/large/small storage engine.
+- Refactor builders for the hybrid cache.
+- Introduce submit queue size threshold to prevent from channel piling up.
+- Support `jeprof` for foyer-bench.
+- Rename feature "mtrace" to "tracing".
+
+## 2024-09-25
+
+### Releases
+
+| crate | version |
+| - | - |
+| foyer | 0.11.5 |
+| foyer-common | 0.9.5 |
+| foyer-intrusive | 0.9.5 |
+| foyer-memory | 0.7.5 |
+| foyer-storage | 0.10.5 |
+| foyer-bench | 0.3.5 |
+
+### Changes
+
+- Fix panic on dropping the hybrid cache. #736
+
+## 2024-09-24
+
+### Releases
+
+| crate | version |
+| - | - |
+| foyer | 0.11.4 |
+| foyer-common | 0.9.4 |
+| foyer-intrusive | 0.9.4 |
+| foyer-memory | 0.7.4 |
+| foyer-storage | 0.10.4 |
+| foyer-bench | 0.3.4 |
+
+### Changes
+
+- Revert pre-serialization design. The insert latency and memory usage would be better for most cases.
+- Rename `with_buffer_threshold` to `with_buffer_pool_size`. The old method is kept but marked as deprecated.
+- Raise a warn when using `DirectFileDevice` on within a file system.
+
+## 2024-09-20
+
+### Releases
+
+| crate | version |
+| - | - |
+| foyer | 0.11.3 |
+| foyer-common | 0.9.3 |
+| foyer-intrusive | 0.9.3 |
+| foyer-memory | 0.7.3 |
+| foyer-storage | 0.10.3 |
+| foyer-bench | 0.3.3 |
+
+### Changes
+
+- Fix panicked by io buffer pool alignment issue.
+
## 2024-09-12
+### Releases
+
| crate | version |
| - | - |
| foyer | 0.11.2 |
@@ -9,8 +145,6 @@
| foyer-storage | 0.10.2 |
| foyer-bench | 0.3.2 |
-
+ Tutorial & Document: + https://foyer.rs +
+ # foyer -![Crates.io Version](https://img.shields.io/crates/v/foyer) -![Crates.io MSRV](https://img.shields.io/crates/msrv/foyer) ![GitHub License](https://img.shields.io/github/license/foyer-rs/foyer) - +![Crates.io MSRV](https://img.shields.io/crates/msrv/foyer) [![CI](https://github.com/foyer-rs/foyer/actions/workflows/ci.yml/badge.svg)](https://github.com/foyer-rs/foyer/actions/workflows/ci.yml) [![License Checker](https://github.com/foyer-rs/foyer/actions/workflows/license_check.yml/badge.svg)](https://github.com/foyer-rs/foyer/actions/workflows/license_check.yml) [![codecov](https://codecov.io/github/foyer-rs/foyer/branch/main/graph/badge.svg?token=YO33YQCB70)](https://codecov.io/github/foyer-rs/foyer) @@ -18,9 +33,16 @@ foyer draws inspiration from [Facebook/CacheLib](https://github.com/facebook/cac However, *foyer* is more than just a *rewrite in Rust* effort; it introduces a variety of new and optimized features. +For more details, please visit foyer's website: https://foyer.rs 🥰 + +[Website](https://foyer.rs) | +[Tutorial](https://foyer.rs/docs/overview) | +[API Docs](https://docs.rs/foyer) | +[Crate](https://crates.io/crates/foyer) + ## Features -- **Hybrid Cache**: Seamlessly integrates both in-memory and disk-based caching for optimal performance and flexibility. +- **Hybrid Cache**: Seamlessly integrates both in-memory and disk cache for optimal performance and flexibility. - **Plug-and-Play Algorithms**: Empowers users with easily replaceable caching algorithms, ensuring adaptability to diverse use cases. - **Fearless Concurrency**: Built to handle high concurrency with robust thread-safe mechanisms, guaranteeing reliable performance under heavy loads. - **Zero-Copy In-Memory Cache Abstraction**: Leveraging Rust's robust type system, the in-memory cache in foyer achieves a better performance with zero-copy abstraction. @@ -35,18 +57,20 @@ Feel free to open a PR and add your projects here: - [Chroma](https://github.com/chroma-core/chroma): Embedding database for LLM apps. - [SlateDB](https://github.com/slatedb/slatedb): A cloud native embedded storage engine built on object storage. -## Usage +## Quick Start + +**This section only shows briefs. Please visit https://foyer.rs for more details.** To use *foyer* in your project, add this line to the `dependencies` section of `Cargo.toml`. ```toml -foyer = "0.11" +foyer = "0.12" ``` If your project is using the nightly rust toolchain, the `nightly` feature needs to be enabled. ```toml -foyer = { version = "0.11", features = ["nightly"] } +foyer = { version = "0.12", features = ["nightly"] } ``` ### Out-of-the-box In-memory Cache @@ -67,7 +91,7 @@ fn main() { ### Easy-to-use Hybrid Cache ```rust -use foyer::{DirectFsDeviceOptionsBuilder, HybridCache, HybridCacheBuilder}; +use foyer::{DirectFsDeviceOptions, Engine, HybridCache, HybridCacheBuilder}; #[tokio::main] async fn main() -> anyhow::Result<()> { @@ -75,12 +99,8 @@ async fn main() -> anyhow::Result<()> { let hybrid: HybridCache