diff options
author | Tor Egge <Tor.Egge@online.no> | 2021-08-18 10:17:59 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2021-08-18 10:17:59 +0200 |
commit | 996ca504122c999dd0adddf88ab63a37af109161 (patch) | |
tree | 6ed2082b0e4a97be3e8a924b092553b5bbb40b4c /vespalib | |
parent | 5b61adcd248e9bd9f191c21c6d0a6dc39cf78d60 (diff) |
Compact HNSW index when ratio of dead bytes / address space is too high
relative to used bytes / address space.
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/vespa/vespalib/datastore/array_store.hpp | 14 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/datastore/i_compaction_context.h | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/vespalib/src/vespa/vespalib/datastore/array_store.hpp b/vespalib/src/vespa/vespalib/datastore/array_store.hpp index 5409c21594c..29db72c2ed3 100644 --- a/vespalib/src/vespa/vespalib/datastore/array_store.hpp +++ b/vespalib/src/vespa/vespalib/datastore/array_store.hpp @@ -157,6 +157,20 @@ public: } } } + void compact(vespalib::ArrayRef<AtomicEntryRef> refs) override { + if (!_bufferIdsToCompact.empty()) { + for (auto &ref : refs) { + if (ref.load_relaxed().valid()) { + RefT internalRef(ref.load_relaxed()); + if (compactingBuffer(internalRef.bufferId())) { + EntryRef newRef = _store.add(_store.get(ref.load_relaxed())); + std::atomic_thread_fence(std::memory_order_release); + ref.store_release(newRef); + } + } + } + } + } }; } diff --git a/vespalib/src/vespa/vespalib/datastore/i_compaction_context.h b/vespalib/src/vespa/vespalib/datastore/i_compaction_context.h index 72b473adf4a..291d751082a 100644 --- a/vespalib/src/vespa/vespalib/datastore/i_compaction_context.h +++ b/vespalib/src/vespa/vespalib/datastore/i_compaction_context.h @@ -16,6 +16,7 @@ struct ICompactionContext { using UP = std::unique_ptr<ICompactionContext>; virtual ~ICompactionContext() {} virtual void compact(vespalib::ArrayRef<EntryRef> refs) = 0; + virtual void compact(vespalib::ArrayRef<AtomicEntryRef> refs) = 0; }; } |