From ecd3e4512648499708e18f082a20e59ddff1959f Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Mon, 15 Jan 2024 11:50:55 +0100 Subject: [PATCH] alternative --- Cargo.lock | 4 ++-- Cargo.toml | 8 ++++++-- pageserver/src/virtual_file/io_engine.rs | 2 ++ pageserver/src/virtual_file/open_options.rs | 10 ++++++++++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fc8c652031..429a0c9023 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5483,7 +5483,7 @@ dependencies = [ [[package]] name = "tokio-epoll-uring" version = "0.1.0" -source = "git+https://github.com/neondatabase/tokio-epoll-uring.git?branch=main#9c5ea716add1357dc8c180167e43a2ae596eba68" +source = "git+https://github.com/neondatabase/tokio-epoll-uring.git?branch=problame/macos-usage-alternative#f3983bcce513d80f938ca6f1e9eb038e7803afeb" dependencies = [ "futures", "once_cell", @@ -6049,7 +6049,7 @@ dependencies = [ [[package]] name = "uring-common" version = "0.1.0" -source = "git+https://github.com/neondatabase/tokio-epoll-uring.git?branch=main#9c5ea716add1357dc8c180167e43a2ae596eba68" +source = "git+https://github.com/neondatabase/tokio-epoll-uring.git?branch=problame/macos-usage-alternative#f3983bcce513d80f938ca6f1e9eb038e7803afeb" dependencies = [ "io-uring", "libc", diff --git a/Cargo.toml b/Cargo.toml index ddcdad91a6..497174e019 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -150,8 +150,6 @@ test-context = "0.1" thiserror = "1.0" tls-listener = { version = "0.7", features = ["rustls", "hyper-h1"] } tokio = { version = "1.17", features = ["macros"] } -#tokio-epoll-uring = { path = "../tokio-epoll-uring/tokio-epoll-uring" } -tokio-epoll-uring = { git = "https://github.com/neondatabase/tokio-epoll-uring.git" , branch = "main" } tokio-io-timeout = "1.2.0" tokio-postgres-rustls = "0.10.0" tokio-rustls = "0.24" @@ -175,6 +173,12 @@ x509-parser = "0.15" env_logger = "0.10" log = "0.4" +## tokio-epoll-uring +#tokio-epoll-uring = { path = "../tokio-epoll-uring/tokio-epoll-uring" } +#uring-common = { path = "../tokio-epoll-uring/uring-common" } +tokio-epoll-uring = { git = "https://github.com/neondatabase/tokio-epoll-uring.git" , branch = "problame/macos-usage-alternative" } +#uring-common = { git = "https://github.com/neondatabase/tokio-epoll-uring.git" , branch = "problame/macos-usage" } + ## Libraries from neondatabase/ git forks, ideally with changes to be upstreamed postgres = { git = "https://github.com/neondatabase/rust-postgres.git", branch="neon" } postgres-native-tls = { git = "https://github.com/neondatabase/rust-postgres.git", branch="neon" } diff --git a/pageserver/src/virtual_file/io_engine.rs b/pageserver/src/virtual_file/io_engine.rs index 8619cbf661..f9e9aa9630 100644 --- a/pageserver/src/virtual_file/io_engine.rs +++ b/pageserver/src/virtual_file/io_engine.rs @@ -22,6 +22,7 @@ #[strum(serialize_all = "kebab-case")] pub enum IoEngineKind { StdFs, + #[cfg(target_os = "linux")] TokioEpollUring, } @@ -91,6 +92,7 @@ impl IoEngineKind { drop(dst); ((file_guard, buf), res) } + #[cfg(target_os = "linux")] IoEngineKind::TokioEpollUring => { let system = tokio_epoll_uring::thread_local_system().await; let (resources, res) = system.read(file_guard, offset, buf).await; diff --git a/pageserver/src/virtual_file/open_options.rs b/pageserver/src/virtual_file/open_options.rs index eb925327b1..1e5ffe15cc 100644 --- a/pageserver/src/virtual_file/open_options.rs +++ b/pageserver/src/virtual_file/open_options.rs @@ -6,6 +6,7 @@ use std::{os::fd::OwnedFd, path::Path}; #[derive(Debug, Clone)] pub enum OpenOptions { StdFs(std::fs::OpenOptions), + #[cfg(target_os = "linux")] TokioEpollUring(tokio_epoll_uring::ops::open_at::OpenOptions), } @@ -13,6 +14,7 @@ impl Default for OpenOptions { fn default() -> Self { match super::io_engine::get() { IoEngineKind::StdFs => Self::StdFs(std::fs::OpenOptions::new()), + #[cfg(target_os = "linux")] IoEngineKind::TokioEpollUring => { Self::TokioEpollUring(tokio_epoll_uring::ops::open_at::OpenOptions::new()) } @@ -30,6 +32,7 @@ impl OpenOptions { OpenOptions::StdFs(x) => { let _ = x.read(read); } + #[cfg(target_os = "linux")] OpenOptions::TokioEpollUring(x) => { let _ = x.read(read); } @@ -42,6 +45,7 @@ impl OpenOptions { OpenOptions::StdFs(x) => { let _ = x.write(write); } + #[cfg(target_os = "linux")] OpenOptions::TokioEpollUring(x) => { let _ = x.write(write); } @@ -54,6 +58,7 @@ impl OpenOptions { OpenOptions::StdFs(x) => { let _ = x.create(create); } + #[cfg(target_os = "linux")] OpenOptions::TokioEpollUring(x) => { let _ = x.create(create); } @@ -66,6 +71,7 @@ impl OpenOptions { OpenOptions::StdFs(x) => { let _ = x.create_new(create_new); } + #[cfg(target_os = "linux")] OpenOptions::TokioEpollUring(x) => { let _ = x.create_new(create_new); } @@ -78,6 +84,7 @@ impl OpenOptions { OpenOptions::StdFs(x) => { let _ = x.truncate(truncate); } + #[cfg(target_os = "linux")] OpenOptions::TokioEpollUring(x) => { let _ = x.truncate(truncate); } @@ -88,6 +95,7 @@ impl OpenOptions { pub(in crate::virtual_file) async fn open(&self, path: &Path) -> std::io::Result { match self { OpenOptions::StdFs(x) => x.open(path).map(|file| file.into()), + #[cfg(target_os = "linux")] OpenOptions::TokioEpollUring(x) => { let system = tokio_epoll_uring::thread_local_system().await; system.open(path, x).await.map_err(|e| match e { @@ -107,6 +115,7 @@ impl std::os::unix::prelude::OpenOptionsExt for OpenOptions { OpenOptions::StdFs(x) => { let _ = x.mode(mode); } + #[cfg(target_os = "linux")] OpenOptions::TokioEpollUring(x) => { let _ = x.mode(mode); } @@ -119,6 +128,7 @@ impl std::os::unix::prelude::OpenOptionsExt for OpenOptions { OpenOptions::StdFs(x) => { let _ = x.custom_flags(flags); } + #[cfg(target_os = "linux")] OpenOptions::TokioEpollUring(x) => { let _ = x.custom_flags(flags); }