refactor(diskann): decouple from libaio via dlopen#532
Conversation
… into refactor/diskann_dlopen
|
可以把workflow里,打包相关的libaio-devel依赖,在这个PR里移除 |
| if: matrix.platform == 'linux-x64' | ||
| run: | | ||
| cd "$GITHUB_WORKSPACE/build" | ||
| cmake --build . --target unittest --parallel $NPROC |
There was a problem hiding this comment.
updated. only run diskann related tests.
There was a problem hiding this comment.
可以多放一个非diskann的测试吧,验证安装libaio后对已有其他单测不会有影响
… into refactor/diskann_dlopen
|
DiskANN 以及本 PR 新增的 IO backend API 在运行时绑定和 type hints 之间存在多处不一致,建议合入前一起补齐。 1. Python stubs 没有声明 DiskANN 参数运行时已经导出了:
对应绑定位于:
但 与此同时,顶层 建议在 class DiskAnnIndexParam(IndexParam):
metric_type: MetricType
max_degree: int
list_size: int
pq_chunk_num: int
quantize_type: QuantizeType
quantizer_param: QuantizerParam
class DiskAnnQueryParam(QueryParam):
list_size: int构造函数签名和默认值需要与 pybind 保持一致: DiskAnnIndexParam(
metric_type=MetricType.IP,
max_degree=100,
list_size=50,
pq_chunk_num=0,
quantize_type=QuantizeType.UNDEFINED,
quantizer_param=QuantizerParam(),
)
DiskAnnQueryParam(list_size=300)2.
|
fixed. add missing hints, stub, etc. and also changed the macro guard. |
| @@ -0,0 +1,242 @@ | |||
| # Copyright 2025-present the zvec project | |||
| # | |||
| # Licensed under the Apache License, Version 2.0 (the "License"); | |||
There was a problem hiding this comment.
一条 runtime API 与 type hints 的一致性测试,详情见zhourrr的comment。
Re-express the ARM64 DiskANN enablement on top of PR alibaba#532's dlopen-based libaio decoupling (the plugin architecture is gone, so the old plugin/EnsureDiskAnnRuntimeReady error-message tweaks no longer apply). - CMakeLists.txt: widen DISKANN_SUPPORTED gate to x86_64|i686|i386|aarch64|arm64|riscv64. - cmake/option.cmake: _setup_armv8_march now tries "armv8-a" before the bare "armv8" (GCC/Clang on aarch64 reject the bare form). - src/core/algorithm/diskann/CMakeLists.txt: widen the ${CMAKE_DL_LIBS} (dlopen) link gate to match the supported-platform set. - src/db/index/common/schema.cc: update the unsupported-platform message to reflect the widened platform list. libaio_def.h already provides aarch64 ABI struct layouts; libaio is loaded at runtime via dlopen with a synchronous pread() fallback when absent.
| @@ -12,6 +12,7 @@ | |||
| // See the License for the specific language governing permissions and | |||
| // limitations under the License.#pragma once | |||
There was a problem hiding this comment.
这个support提示过时了,现在支持DISKANN了
| // ============================================================================= | ||
|
|
||
| zvec_io_backend_type_t zvec_get_io_backend_type(void) { | ||
| auto type = zvec::ailego::IOBackend::Instance().available(); |
There was a problem hiding this comment.
把switch换成static_cast ?
// C++ -> C
return static_cast<zvec_io_backend_type_t>(static_cast<uint32_t>(type));
// C -> C++
auto cpp_type = static_castzvec::IOBackendType(type);
| } | ||
|
|
||
| const char *zvec_get_io_backend_type_name(zvec_io_backend_type_t type) { | ||
| thread_local std::string cached; |
There was a problem hiding this comment.
这里没有必要用cached, IOBackendTypeName返回的全是字符串字面量, 字面量是静态存储期,指针永远有效。
| } | ||
|
|
||
| const char *zvec_get_io_backend_description(void) { | ||
| thread_local std::string cached; |
Currently, DiskAnn ships as a separate runtime-loaded .so (libzvec_diskann_plugin.so) file which requires a hard build-time dependency on libaio-dev.
This PR improves with a simpler, more robust design. Probing libaio.so file, a thread-safe singleton dlopens it and caches the syscall pointers. If libaio is absent, it will fall back to degrade to synchronous pread() with a warning.
The following shows the performance comparison on Cohere 1M between pread w/ and w/o AIO enabled. (Aliyun g9i, PL0, 10000 IOPS)
Pread w/ AIO Enabled
Pread w/o AIO Enabled