forked from XiangpengHao/liquid-cache
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: build and test natively on macOS #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
1dff9e3
feat(store): mount the on-disk store through one platform-aware policy
zfarrell ebec58b
fix(benchmark): build on targets without perf_event_open
zfarrell 7e6858c
docs: state what buffered I/O costs off Linux
zfarrell 3b8a52a
refactor(store): collapse mount to a single policy body
zfarrell 9831329
test(utils): cover the portable and_then path on every architecture
zfarrell 5ca1106
fix(nix): keep Linux-only tools out of the darwin devShell
zfarrell 477a35b
test(local): gate the exact-memory snapshot to Linux
zfarrell 4118830
ci: run clippy and tests on macOS
zfarrell 32859f2
fix(store): scope the Once import to the non-Linux path
zfarrell 8ac2363
test(local): gate the exact-memory snapshot by arch, not OS
zfarrell 0603cc6
docs(utils): note which and_then impl each host tests
zfarrell deca1e6
docs: record the arch-dependent FSST symbol table
zfarrell 4944e8b
test(local): bound memory_bytes off x86_64 instead of skipping
zfarrell 0ed767d
chore: drop t4 from crates that no longer reference it
zfarrell 9542842
test(local): derive the arm64 memory bound from the snapshot
zfarrell d901a32
chore(lint): forbid direct t4 mounts outside the store policy
zfarrell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| disallowed-methods = [ | ||
| { path = "t4::mount", reason = "use liquid_cache::store::mount so the store's I/O mode stays in one place" }, | ||
| { path = "t4::mount_with_options", reason = "use liquid_cache::store::mount so the store's I/O mode stays in one place" }, | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
|
|
||
| pub mod cache; | ||
| pub mod liquid_array; | ||
| pub mod store; | ||
| mod sync; | ||
| pub mod utils; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| //! Mounting the on-disk store that backs the cache's disk tier. | ||
| //! | ||
| //! LiquidCache wants DIRECT I/O. Bypassing the OS page cache is what makes the | ||
| //! cache's own byte accounting the whole truth: one copy of a cached page | ||
| //! exists, and the cache knows about it. The admission gate | ||
| //! ([`crate::cache`] budgets, and `liquid-cache-datafusion`'s footprint gate) | ||
| //! is built on that premise. | ||
| //! | ||
| //! [`t4`] only implements DIRECT I/O on Linux — every other target refuses the | ||
| //! option outright rather than silently ignoring it. So off Linux we mount | ||
| //! buffered and say so. The cache stays correct: it writes, reads and evicts | ||
| //! exactly as before. What it loses is the accounting guarantee, because the | ||
| //! kernel now keeps a second copy of every page that the cache does not count. | ||
| //! That makes non-Linux fine for development and wrong for measurement. | ||
|
|
||
| use std::path::Path; | ||
|
|
||
| /// Mount the on-disk store for a LiquidCache instance at `path`, which is the | ||
| /// full path to the store file. | ||
| /// | ||
| /// Prefer this over calling [`t4::mount`] directly: it is the one place that | ||
| /// decides the store's I/O mode, so the choice cannot drift between the cache | ||
| /// builders, the server, benches and tests. | ||
| /// | ||
| /// On Linux this is exactly [`t4::mount`] — `direct_io` and `dsync` both come | ||
| /// out `true`, matching [`t4::MountOptions::default`]. See the | ||
| /// [module docs](self) for what the buffered fallback costs elsewhere. | ||
| // The one place allowed to mount through `t4` directly — `clippy.toml` sends | ||
| // every other call site here, so this is where the `disallowed_methods` rule has | ||
| // to stop. | ||
| #[allow(clippy::disallowed_methods)] | ||
| pub async fn mount(path: impl AsRef<Path>) -> t4::Result<t4::Store> { | ||
| #[cfg(not(target_os = "linux"))] | ||
| warn_buffered_once(); | ||
|
|
||
| // `dsync` stays at t4's default: O_DSYNC is honoured off Linux too, so the | ||
| // fallback keeps the write-durability semantics Linux gets. | ||
| t4::mount_with_options( | ||
| path, | ||
| t4::MountOptions { | ||
| direct_io: cfg!(target_os = "linux"), | ||
| ..Default::default() | ||
| }, | ||
| ) | ||
| .await | ||
| } | ||
|
|
||
| #[cfg(not(target_os = "linux"))] | ||
| fn warn_buffered_once() { | ||
| static WARNED: std::sync::Once = std::sync::Once::new(); | ||
| WARNED.call_once(|| { | ||
| log::warn!( | ||
| "mounting the liquid cache store with buffered I/O: t4 implements DIRECT I/O on Linux \ | ||
| only. The cache is fully functional, but memory accounting now excludes the kernel \ | ||
| page-cache copy of every cached page, so reported usage understates real residency \ | ||
| and the admission gate's budget is measured against an incomplete figure. Measure \ | ||
| performance on Linux." | ||
| ); | ||
| }); | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
|
|
||
| /// The store must mount, round-trip a value and survive a remount on every | ||
| /// platform. On Linux this covers t4's io_uring backend; elsewhere it is the | ||
| /// only coverage the generic thread-pool backend gets. | ||
| #[tokio::test] | ||
| async fn mount_round_trips_on_this_platform() { | ||
| let dir = tempfile::tempdir().unwrap(); | ||
| let path = dir.path().join("liquid_cache.t4"); | ||
|
|
||
| let store = mount(&path).await.expect("mount must succeed"); | ||
| store.put(b"key".to_vec(), b"hello".to_vec()).await.unwrap(); | ||
| assert_eq!(store.get(b"key").await.unwrap(), b"hello"); | ||
| store.sync().await.unwrap(); | ||
| drop(store); | ||
|
|
||
| let store = mount(&path).await.expect("remount must succeed"); | ||
| assert_eq!( | ||
| store.get(b"key").await.unwrap(), | ||
| b"hello", | ||
| "a remounted store must replay what was written" | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.