This is an automated email from the ASF dual-hosted git repository. avamingli pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit 1854534a63fb5771e357a9c36d654e9d169cd749 Author: Zhang Mingli <[email protected]> AuthorDate: Thu May 28 18:21:59 2026 +0800 macOS: make PAX's liburing dependency optional liburing is the Linux-only userspace API for the io_uring kernel interface (Linux 5.1+). It is not available on macOS or *BSD. PAX already has a sync fallback path (SyncFastIO using pread(2)) and LocalFile::ReadBatch picks between the two via IOUringFastIO::available(). This commit lets the build proceed without liburing: * configure: AC_CHECK_LIB(uring) no longer aborts when missing; PAX falls back to SyncFastIO at runtime. * fast_io.h / fast_io.cc: wrap the IOUringFastIO class declaration and methods with #ifdef __linux__ so they only exist where the header is available. * local_file_system.cc: gate the IOUringFastIO::available() branch with #ifdef __linux__; non-Linux unconditionally uses SyncFastIO. --- configure | 11 ++++++++++- configure.ac | 16 +++++++++++++--- contrib/pax_storage/src/cpp/comm/fast_io.cc | 2 ++ contrib/pax_storage/src/cpp/comm/fast_io.h | 11 +++++++++-- .../pax_storage/src/cpp/storage/local_file_system.cc | 18 +++++++++++------- 5 files changed, 45 insertions(+), 13 deletions(-) diff --git a/configure b/configure index f873fb97d63..440b66d0f4c 100755 --- a/configure +++ b/configure @@ -9891,7 +9891,16 @@ _ACEOF LIBS="-luring $LIBS" else - as_fn_error $? "library 'uring' is required for PAX support" "$LINENO" 5 + # liburing is required on Linux (io_uring is a Linux 5.1+ kernel iface); + # on non-Linux hosts PAX falls back to pread-based SyncFastIO. + case $host_os in + linux*) + as_fn_error $? "library 'uring' is required for PAX support on Linux" "$LINENO" 5 + ;; + *) + : + ;; + esac fi diff --git a/configure.ac b/configure.ac index 175053baeab..dd259c4f07f 100644 --- a/configure.ac +++ b/configure.ac @@ -1035,9 +1035,19 @@ if test "$enable_pax" = yes; then [AC_MSG_ERROR([libzstd >= 1.4.0 is required for PAX support])] ) - # Check liburing - AC_CHECK_LIB(uring, io_uring_queue_init, [], - [AC_MSG_ERROR([library 'uring' is required for PAX support])]) + # Check liburing. liburing is Linux-only (io_uring kernel iface, 5.1+). + # On Linux it is required as before; on non-Linux hosts (macOS / *BSD) + # PAX falls back to pread-based SyncFastIO and the IOUringFastIO path + # is conditionally compiled — see contrib/pax_storage/src/cpp/comm/fast_io.* + case $host_os in + linux*) + AC_CHECK_LIB(uring, io_uring_queue_init, [], + [AC_MSG_ERROR([library 'uring' is required for PAX support on Linux])]) + ;; + *) + AC_CHECK_LIB(uring, io_uring_queue_init, [], []) + ;; + esac # Check cmake >= 3.11.0 using AX_COMPARE_VERSION AC_PATH_PROG([CMAKE], [cmake], [no]) diff --git a/contrib/pax_storage/src/cpp/comm/fast_io.cc b/contrib/pax_storage/src/cpp/comm/fast_io.cc index c2dcd235541..808bfb26d73 100644 --- a/contrib/pax_storage/src/cpp/comm/fast_io.cc +++ b/contrib/pax_storage/src/cpp/comm/fast_io.cc @@ -41,6 +41,7 @@ namespace pax { +#ifdef __linux__ bool IOUringFastIO::available() { static int8_t support_io_uring = 0; @@ -110,6 +111,7 @@ std::pair<int, int> IOUringFastIO::read(int fd, std::vector<IORequest> &request, } return {retcode, success_read}; // Placeholder } +#endif // __linux__ std::pair<int, int> SyncFastIO::read(int fd, std::vector<IORequest> &request, std::vector<bool> &result) { size_t total_requests = request.size(); diff --git a/contrib/pax_storage/src/cpp/comm/fast_io.h b/contrib/pax_storage/src/cpp/comm/fast_io.h index da63b4d89ea..a7823d3bc9a 100644 --- a/contrib/pax_storage/src/cpp/comm/fast_io.h +++ b/contrib/pax_storage/src/cpp/comm/fast_io.h @@ -29,12 +29,17 @@ #include "comm/common_io.h" -#include <liburing.h> #include <cstddef> #include <cstdio> #include <algorithm> #include <vector> +/* liburing is Linux-only (io_uring kernel iface). On macOS / *BSD we + * compile only the SyncFastIO (pread-based) path. */ +#ifdef __linux__ +#include <liburing.h> +#endif + namespace pax { @@ -56,7 +61,8 @@ public: std::pair<int, int> read(int fd, std::vector<IORequest> &request, std::vector<bool> &result); }; -// io_uring-based FastIO +#ifdef __linux__ +// io_uring-based FastIO (Linux only). class IOUringFastIO { public: IOUringFastIO(size_t queue_size = 128) { @@ -84,5 +90,6 @@ private: // 'u' for uninitialized, 'i' for initialized, 'x' for unsupported char status_ = 'u'; }; +#endif // __linux__ } // namespace pax \ No newline at end of file diff --git a/contrib/pax_storage/src/cpp/storage/local_file_system.cc b/contrib/pax_storage/src/cpp/storage/local_file_system.cc index 82afafbfcfd..712beb80643 100644 --- a/contrib/pax_storage/src/cpp/storage/local_file_system.cc +++ b/contrib/pax_storage/src/cpp/storage/local_file_system.cc @@ -137,6 +137,7 @@ ssize_t LocalFile::PWrite(const void *ptr, size_t n, off_t offset) { void LocalFile::ReadBatch(const std::vector<IORequest> &requests) const { if (unlikely(requests.empty())) return; +#ifdef __linux__ if (IOUringFastIO::available()) { IOUringFastIO fast_io(requests.size()); std::vector<bool> result(requests.size(), false); @@ -144,14 +145,17 @@ void LocalFile::ReadBatch(const std::vector<IORequest> &requests) const { CBDB_CHECK(res.first == 0, cbdb::CException::ExType::kExTypeIOError, fmt("Fail to ReadBatch with io_uring [successful=%d, total=%lu], %s", res.second, requests.size(), DebugString().c_str())); - } else { - SyncFastIO fast_io; - std::vector<bool> result(requests.size(), false); - auto res = fast_io.read(fd_, const_cast<std::vector<IORequest>&>(requests), result); - CBDB_CHECK(res.first == 0, cbdb::CException::ExType::kExTypeIOError, - fmt("Fail to ReadBatch with sync read [successful=%d, total=%lu], %s", - res.second, requests.size(), DebugString().c_str())); + return; } +#endif + + // Fallback: pread-based sync IO (non-Linux, or older kernel without io_uring). + SyncFastIO fast_io; + std::vector<bool> result(requests.size(), false); + auto res = fast_io.read(fd_, const_cast<std::vector<IORequest>&>(requests), result); + CBDB_CHECK(res.first == 0, cbdb::CException::ExType::kExTypeIOError, + fmt("Fail to ReadBatch with sync read [successful=%d, total=%lu], %s", + res.second, requests.size(), DebugString().c_str())); } size_t LocalFile::FileLength() const { --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
