refactor(diskann): decouple from libaio via dlopen (#532)

Co-authored-by: Zefeng Yin <yinzefeng.yzf@alibaba-inc.com>
This commit is contained in:
rayx
2026-07-16 17:58:25 +08:00
committed by GitHub
co-authored by Zefeng Yin
parent 23538ab876
commit ec8a78ee08
49 changed files with 1108 additions and 809 deletions
+16 -26
View File
@@ -20,7 +20,6 @@
#include <zvec/db/schema.h>
#include <zvec/db/status.h>
#include <zvec/db/type.h>
#include <zvec/plugin/diskann_plugin.h>
#include "ailego/internal/cpu_features.h"
#include "db/common/constants.h"
#include "db/common/typedef.h"
@@ -154,7 +153,8 @@ Status FieldSchema::validate() const {
support_dense_vector_index.end()) {
return Status::InvalidArgument(
"schema validate failed: dense_vector's index_params only "
"support FLAT|HNSW|IVF index, but field[",
"support FLAT|HNSW|HNSW_RABITQ|IVF|DISKANN|VAMANA index, but "
"field[",
name_, "]'s index_type is ",
IndexTypeCodeBook::AsString(index_params_->type()));
}
@@ -198,30 +198,20 @@ Status FieldSchema::validate() const {
}
if (index_params_->type() == IndexType::DISKANN) {
// Probe the DiskAnn runtime eagerly at creation time so unsupported
// platforms (non Linux x86_64), missing libaio, or a missing plugin
// .so fail fast with a clear message instead of surfacing later during
// optimize(). This reuses the same gate DiskAnnIndex applies on first
// use (zvec::LoadDiskAnnPlugin, wrapped by EnsureDiskAnnRuntimeReady).
// All validate() call sites are creation-time only, so triggering the
// plugin load here is safe (and idempotent/cached).
const int rc = ::zvec::LoadDiskAnnPlugin();
switch (rc) {
case kDiskAnnPluginOk:
break;
case kDiskAnnPluginUnsupportedPlatform:
return Status::NotSupported(
"DiskAnn is not supported on this platform (Linux x86_64 "
"only)");
case kDiskAnnPluginLibAioMissing:
return Status::NotSupported(
"DiskAnn requires libaio at runtime, but it was not found on "
"this host. Install it (e.g. 'apt-get install libaio1', or "
"'libaio1t64' on Ubuntu 24.04+) and retry.");
default:
return Status::NotSupported(
"DiskAnn runtime could not be initialized on this host");
}
// DiskAnn requires Linux x86_64/i686/i386. The CMake variable
// DISKANN_SUPPORTED (defined in the top-level CMakeLists.txt) is the
// single source of truth for platform eligibility — it is also used by
// index_factory.cc to conditionally compile the DiskAnn index
// registration. Using the same macro here ensures that schema
// validation and index registration agree on supported platforms.
//
// libaio is loaded eagerly (via dlopen) inside DiskAnnBuilder::init()
// and DiskAnnStreamer::init(); if libaio is missing, DiskAnn falls
// back to synchronous pread() with degraded performance.
#if !DISKANN_SUPPORTED
return Status::NotSupported(
"DiskAnn is not supported on this platform (Linux x86_64 only)");
#endif
}