Skip to content

Commit c6f92eb

Browse files
committed
feat(io_uring): add new IO Type: UringIO
Signed-off-by: LHT129 <tianlan.lht@antgroup.com>
1 parent 90201b9 commit c6f92eb

22 files changed

Lines changed: 666 additions & 25 deletions

CMakeLists.txt

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ option (DISABLE_NEON_FORCE "Force disable neon instructions" OFF)
7373
option (DISABLE_SVE_FORCE "Force disable sve instructions" OFF)
7474
# AIO library configuration
7575
option (ENABLE_LIBAIO "Whether to enable libaio support" ON)
76+
option (ENABLE_LIBURING "Whether to enable liburing support" ON)
7677

7778
if (ENABLE_CXX11_ABI)
7879
add_definitions (-D_GLIBCXX_USE_CXX11_ABI=1)
@@ -133,25 +134,8 @@ else ()
133134
endif ()
134135
endif ()
135136

136-
# AIO library detection
137-
if (ENABLE_LIBAIO)
138-
find_library (AIO_LIBRARY aio)
139-
if (AIO_LIBRARY)
140-
message (STATUS "Found libaio: ${AIO_LIBRARY}")
141-
set (HAVE_LIBAIO 1)
142-
add_definitions (-DHAVE_LIBAIO=1)
143-
else ()
144-
message (WARNING "libaio not found, disabling async I/O support")
145-
set (HAVE_LIBAIO 0)
146-
add_definitions (-DHAVE_LIBAIO=0)
147-
add_definitions (-DNO_LIBAIO=1)
148-
endif ()
149-
else ()
150-
message (STATUS "libaio support disabled by user")
151-
set (HAVE_LIBAIO 0)
152-
add_definitions (-DHAVE_LIBAIO=0)
153-
add_definitions (-DNO_LIBAIO=1)
154-
endif ()
137+
include (cmake/FindLibaio.cmake)
138+
include (cmake/FindLiburing.cmake)
155139

156140
# ccache
157141
find_program (CCACHE_FOUND ccache)

cmake/FindLibaio.cmake

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
# Copyright 2024-present the vsag project
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# AIO library detection
17+
if (ENABLE_LIBAIO)
18+
find_library (AIO_LIBRARY aio)
19+
if (AIO_LIBRARY)
20+
message (STATUS "Found libaio: ${AIO_LIBRARY}")
21+
set (HAVE_LIBAIO 1)
22+
add_definitions (-DHAVE_LIBAIO=1)
23+
else ()
24+
message (WARNING "libaio not found, disabling async I/O support")
25+
set (HAVE_LIBAIO 0)
26+
add_definitions (-DHAVE_LIBAIO=0)
27+
add_definitions (-DNO_LIBAIO=1)
28+
endif ()
29+
else ()
30+
message (STATUS "libaio support disabled by user")
31+
set (HAVE_LIBAIO 0)
32+
add_definitions (-DHAVE_LIBAIO=0)
33+
add_definitions (-DNO_LIBAIO=1)
34+
endif ()

cmake/FindLiburing.cmake

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
# Copyright 2024-present the vsag project
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
if (ENABLE_LIBURING)
17+
find_package(PkgConfig QUIET)
18+
if (PkgConfig_FOUND)
19+
pkg_check_modules(PC_LIBURING QUIET liburing)
20+
endif()
21+
22+
if (PC_LIBURING_FOUND)
23+
message(STATUS "Found liburing via pkg-config: ${PC_LIBURING_LIBRARIES}")
24+
set(HAVE_LIBURING 1)
25+
add_definitions(-DHAVE_LIBURING=1)
26+
else()
27+
# fallback to find_library
28+
find_library(URING_LIBRARY NAMES uring PATHS /usr/lib /usr/lib64 /usr/lib/x86_64-linux-gnu)
29+
if (URING_LIBRARY)
30+
message(STATUS "Found liburing: ${URING_LIBRARY}")
31+
set(HAVE_LIBURING 1)
32+
add_definitions(-DHAVE_LIBURING=1)
33+
else()
34+
message(WARNING "liburing not found, disabling io_uring support")
35+
set(HAVE_LIBURING 0)
36+
add_definitions(-DHAVE_LIBURING=0 -DNO_LIBURING=1)
37+
endif()
38+
endif()
39+
else()
40+
message(STATUS "liburing support disabled by user")
41+
set(HAVE_LIBURING 0)
42+
add_definitions(-DHAVE_LIBURING=0 -DNO_LIBURING=1)
43+
endif()

docs/hgraph.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ For examples, refer to [103_index_hgraph.cpp](https://github.com/antgroup/vsag/b
121121
### base_io_type
122122
- **Parameter Type**: string
123123
- **Parameter Description**: Storage type for base quantization codes
124-
- **Optional Values**: "memory_io", "block_memory_io", "buffer_io", "async_io", "mmap_io"
124+
- **Optional Values**: "memory_io", "block_memory_io", "buffer_io", "async_io", "mmap_io", "uring_io"
125125
- **Default Value**: "block_memory_io"
126126

127127
### base_file_path
@@ -133,7 +133,7 @@ For examples, refer to [103_index_hgraph.cpp](https://github.com/antgroup/vsag/b
133133
### precise_io_type
134134
- **Parameter Type**: string
135135
- **Parameter Description**: Storage type for precise quantization codes, same as base_io_type but for reordering codes
136-
- **Optional Values**: "memory_io", "block_memory_io", "buffer_io", "async_io", "mmap_io"
136+
- **Optional Values**: "memory_io", "block_memory_io", "buffer_io", "async_io", "mmap_io", "uring_io"
137137
- **Default Value**: "block_memory_io"
138138

139139
### precise_file_path

scripts/deps/install_deps_centos.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# install python3-devel
2-
yum install -y gfortran python3-devel libaio-devel libcurl-devel
2+
yum install -y gfortran python3-devel libaio-devel libcurl-devel liburing-devel
33

44
# install openmp for alibaba clang 11
55
yum install -y current -y libomp11-devel libomp11

src/algorithm/hgraph.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,6 @@ HGraph::map_hgraph_param(const JsonType& hgraph_json) {
502502
std::string str = format_map(hgraph_params_template, DEFAULT_MAP);
503503
auto inner_json = JsonType::Parse(str);
504504
mapping_external_param_to_inner(hgraph_json, external_mapping, inner_json);
505-
506505
return inner_json;
507506
}
508507

src/datacell/bucket_interface.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ BucketInterface::MakeInstance(const BucketDataCellParamPtr& param,
109109
if (io_type_name == IO_TYPE_VALUE_BUFFER_IO) {
110110
return make_instance<NonContinuousIO<BufferIO>>(param, common_param);
111111
}
112+
if (io_type_name == IO_TYPE_VALUE_URING_IO) {
113+
return make_instance<NonContinuousIO<UringIO>>(param, common_param);
114+
}
112115
return nullptr;
113116
}
114117
} // namespace vsag

src/datacell/flatten_interface.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ FlattenInterface::MakeInstance(const FlattenInterfaceParamPtr& param,
190190
if (io_type_name == IO_TYPE_VALUE_READER_IO) {
191191
return make_instance<ReaderIO>(param, common_param);
192192
}
193+
if (io_type_name == IO_TYPE_VALUE_URING_IO) {
194+
return make_instance<UringIO>(param, common_param);
195+
}
193196
return nullptr;
194197
}
195198

src/inner_string_params.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const char* const IO_TYPE_VALUE_BUFFER_IO = "buffer_io";
5555
const char* const IO_TYPE_VALUE_MMAP_IO = "mmap_io";
5656
const char* const IO_TYPE_VALUE_READER_IO = "reader_io";
5757
const char* const IO_TYPE_VALUE_ASYNC_IO = "async_io";
58+
const char* const IO_TYPE_VALUE_URING_IO = "uring_io";
5859
const char* const IO_TYPE_VALUE_BLOCK_MEMORY_IO = "block_memory_io";
5960
const char* const BLOCK_IO_BLOCK_SIZE_KEY = "block_size";
6061

src/io/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ set (IO_SRC
2828
memory_block_io.cpp
2929
reader_io.cpp
3030
reader_io_parameter.cpp
31+
uring_io.cpp
32+
uring_io_parameter.cpp
3133
)
3234

3335
add_library (io OBJECT ${IO_SRC})
@@ -41,6 +43,16 @@ else ()
4143
message (STATUS "io module: libaio not available, async I/O disabled")
4244
endif ()
4345

46+
if (HAVE_LIBURING)
47+
target_compile_definitions (io PUBLIC -DHAVE_LIBURING=1)
48+
target_link_libraries (io PUBLIC fmt::fmt uring coverage_config)
49+
message (STATUS "io module: linking with liburing")
50+
else ()
51+
target_compile_definitions (io PUBLIC -DHAVE_LIBURING=0)
52+
target_link_libraries (io PUBLIC fmt::fmt coverage_config)
53+
message (STATUS "io module: liburing not available, io_uring disabled")
54+
endif ()
55+
4456
maybe_add_dependencies (io spdlog)
4557

4658
if (ENABLE_TESTS)

0 commit comments

Comments
 (0)