aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-08-16 14:48:50 +0200
committerGitHub <noreply@github.com>2021-08-16 14:48:50 +0200
commit74d0fba5384ae051ed0badce29710a29bffa063d (patch)
tree25d5fe4e74b2c413decdcff52f3771af6db84fe2 /searchlib
parent11b2ccae96944799bab31269f83873949f3807c8 (diff)
parentb74e8425c532cf2f24c82fd118306f36ceef81e7 (diff)
Merge pull request #18752 from vespa-engine/toregge/use-4096-buffers-for-hnsw-index-link-array-store
Use 4096 buffers for HNSW link array store.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/tensor/hnsw_graph.h9
-rw-r--r--searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp2
2 files changed, 7 insertions, 4 deletions
diff --git a/searchlib/src/vespa/searchlib/tensor/hnsw_graph.h b/searchlib/src/vespa/searchlib/tensor/hnsw_graph.h
index ce2bc172752..4d07f74f8e3 100644
--- a/searchlib/src/vespa/searchlib/tensor/hnsw_graph.h
+++ b/searchlib/src/vespa/searchlib/tensor/hnsw_graph.h
@@ -18,7 +18,10 @@ struct HnswGraph {
// This uses 10 bits for buffer id -> 1024 buffers.
// As we have very short arrays we get less fragmentation with fewer and larger buffers.
- using EntryRefType = vespalib::datastore::EntryRefT<22>;
+ using LevelArrayEntryRefType = vespalib::datastore::EntryRefT<22>;
+
+ // This uses 12 bits for buffer id -> 4096 buffers.
+ using LinkArrayEntryRefType = vespalib::datastore::EntryRefT<20>;
// Provides mapping from document id -> node reference.
// The reference is used to lookup the node data in NodeStore.
@@ -27,13 +30,13 @@ struct HnswGraph {
// This stores the level arrays for all nodes.
// Each node consists of an array of levels (from level 0 to n) where each entry is a reference to the link array at that level.
- using NodeStore = vespalib::datastore::ArrayStore<AtomicEntryRef, EntryRefType>;
+ using NodeStore = vespalib::datastore::ArrayStore<AtomicEntryRef, LevelArrayEntryRefType>;
using StoreConfig = vespalib::datastore::ArrayStoreConfig;
using LevelArrayRef = NodeStore::ConstArrayRef;
// This stores all link arrays.
// A link array consists of the document ids of the nodes a particular node is linked to.
- using LinkStore = vespalib::datastore::ArrayStore<uint32_t, EntryRefType>;
+ using LinkStore = vespalib::datastore::ArrayStore<uint32_t, LinkArrayEntryRefType>;
using LinkArrayRef = LinkStore::ConstArrayRef;
NodeRefVector node_refs;
diff --git a/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp b/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp
index 3d780d0b534..8183a7caf3d 100644
--- a/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp
+++ b/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp
@@ -30,7 +30,7 @@ constexpr size_t min_num_arrays_for_new_buffer = 512_Ki;
constexpr float alloc_grow_factor = 0.3;
// TODO: Adjust these numbers to what we accept as max in config.
constexpr size_t max_level_array_size = 16;
-constexpr size_t max_link_array_size = 64;
+constexpr size_t max_link_array_size = 193;
constexpr vespalib::duration MAX_COUNT_DURATION(100ms);
bool has_link_to(vespalib::ConstArrayRef<uint32_t> links, uint32_t id) {