diff options
author | Tor Egge <Tor.Egge@yahooinc.com> | 2023-01-17 13:40:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-17 13:40:02 +0100 |
commit | a02f6dede476db726235d22a42ca38523fe9493d (patch) | |
tree | 5a714611bd977621dc7d7c82e627894539f65e97 | |
parent | f3181d09857029695fa00cbe158b3ad29084eb55 (diff) | |
parent | 8a290cc224f76d6cc8625c8350fe8d0b35586a5c (diff) |
Merge pull request #25599 from vespa-engine/toregge/test-hnsw-nodeid-allocation-after-load
Test Hnsw nodeid allocation after load.
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 |