diff options
author | Tor Egge <Tor.Egge@online.no> | 2023-01-17 11:39:09 +0100 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2023-01-17 11:39:09 +0100 |
commit | 8a290cc224f76d6cc8625c8350fe8d0b35586a5c (patch) | |
tree | 7fa0902f7dce78212fb0dc3e8cdf2370c9ceb03c /searchlib | |
parent | fd0f732c68d287290bb8fa811c0bc5906ed2029f (diff) |
Test Hnsw nodeid allocation after load.
Diffstat (limited to 'searchlib')
3 files changed, 5 insertions, 3 deletions
diff --git a/searchlib/src/tests/tensor/hnsw_nodeid_mapping/hnsw_nodeid_mapping_test.cpp b/searchlib/src/tests/tensor/hnsw_nodeid_mapping/hnsw_nodeid_mapping_test.cpp index bc1417e325a..032ca96178b 100644 --- a/searchlib/src/tests/tensor/hnsw_nodeid_mapping/hnsw_nodeid_mapping_test.cpp +++ b/searchlib/src/tests/tensor/hnsw_nodeid_mapping/hnsw_nodeid_mapping_test.cpp @@ -112,10 +112,11 @@ TEST_F(HnswNodeidMappingTest, on_load_populates_mapping) nodes[7].levels_ref().store_relaxed(EntryRef(3)); nodes[7].store_docid(4); nodes[7].store_subspace(1); - mapping.on_load(vespalib::ConstArrayRef(nodes.data(), nodes.size())); + mapping.on_load(vespalib::ConstArrayRef(nodes.data(), 9)); expect_get({1}, 7); expect_get({2, 7}, 4); - expect_allocate_get({3, 4, 5, 6, 8, 9}, 1); + // Drain free list when allocating nodeids. + expect_allocate_get({3, 4, 5, 6, 8, 9, 10}, 1); } TEST_F(HnswNodeidMappingTest, memory_usage_increases_when_allocating_nodeids) diff --git a/searchlib/src/vespa/searchlib/tensor/hnsw_index_loader.hpp b/searchlib/src/vespa/searchlib/tensor/hnsw_index_loader.hpp index 279adbac559..73316cbf259 100644 --- a/searchlib/src/vespa/searchlib/tensor/hnsw_index_loader.hpp +++ b/searchlib/src/vespa/searchlib/tensor/hnsw_index_loader.hpp @@ -66,7 +66,7 @@ HnswIndexLoader<ReaderType, type>::load_next() _graph.trim_nodes_size(); auto entry_levels_ref = _graph.get_levels_ref(_entry_nodeid); _graph.set_entry_node({_entry_nodeid, entry_levels_ref, _entry_level}); - _id_mapping.on_load(_graph.nodes.make_read_view(_graph.nodes.size())); + _id_mapping.on_load(_graph.nodes.make_read_view(_graph.size())); _complete = true; return false; } diff --git a/searchlib/src/vespa/searchlib/tensor/hnsw_nodeid_mapping.cpp b/searchlib/src/vespa/searchlib/tensor/hnsw_nodeid_mapping.cpp index bcfd0f3beeb..e3afbc3b4c5 100644 --- a/searchlib/src/vespa/searchlib/tensor/hnsw_nodeid_mapping.cpp +++ b/searchlib/src/vespa/searchlib/tensor/hnsw_nodeid_mapping.cpp @@ -185,6 +185,7 @@ HnswNodeidMapping::populate_docid_to_nodeids_mapping_and_free_list(vespalib::Con ++nodeid; } std::reverse(_free_list.begin(), _free_list.end()); + _nodeid_limit = nodes.size(); } void |