@@ -40,9 +40,11 @@ bool DefragmenterTask::run(void) {
4040 // then resume from where we last were, otherwise create a new visitor
4141 // starting from the beginning.
4242 if (!prAdapter) {
43- prAdapter = std::make_unique<PauseResumeVBAdapter>(
44- std::make_unique<DefragmentVisitor>(
45- getAgeThreshold (), getMaxValueSize (alloc_hooks)));
43+ auto visitor = std::make_unique<DefragmentVisitor>(
44+ getMaxValueSize (alloc_hooks));
45+
46+ prAdapter =
47+ std::make_unique<PauseResumeVBAdapter>(std::move (visitor));
4648 epstore_position = engine->getKVBucket ()->startPosition ();
4749 }
4850
@@ -70,6 +72,13 @@ bool DefragmenterTask::run(void) {
7072 const auto start = ProcessClock::now ();
7173 const auto deadline = start + getChunkDuration ();
7274 visitor.setDeadline (deadline);
75+ visitor.setBlobAgeThreshold (getAgeThreshold ());
76+ // Only defragment StoredValues of persistent buckets because the
77+ // HashTable defrag method doesn't yet know how to maintain the
78+ // ephemeral seqno linked-list
79+ if (engine->getConfiguration ().getBucketType () == " persistent" ) {
80+ visitor.setStoredValueAgeThreshold (getStoredValueAgeThreshold ());
81+ }
7382 visitor.clearStats ();
7483
7584 // Do it - set off the visitor.
@@ -80,9 +89,7 @@ bool DefragmenterTask::run(void) {
8089 // Defrag complete. Restore thread caching.
8190 alloc_hooks->enable_thread_cache (old_tcache);
8291
83- // Update stats
84- stats.defragNumMoved .fetch_add (visitor.getDefragCount ());
85- stats.defragNumVisited .fetch_add (visitor.getVisitedCount ());
92+ updateStats (visitor);
8693
8794 // Release any free memory we now have in the allocator back to the OS.
8895 // TODO: Benchmark this - is it necessary? How much of a slowdown does it
@@ -153,6 +160,17 @@ size_t DefragmenterTask::getAgeThreshold() const {
153160 return engine->getConfiguration ().getDefragmenterAgeThreshold ();
154161}
155162
163+ size_t DefragmenterTask::getStoredValueAgeThreshold () const {
164+ return engine->getConfiguration ().getDefragmenterStoredValueAgeThreshold ();
165+ }
166+
167+ void DefragmenterTask::updateStats (DefragmentVisitor& visitor) {
168+ stats.defragNumMoved .fetch_add (visitor.getDefragCount ());
169+ stats.defragStoredValueNumMoved .fetch_add (
170+ visitor.getStoredValueDefragCount ());
171+ stats.defragNumVisited .fetch_add (visitor.getVisitedCount ());
172+ }
173+
156174size_t DefragmenterTask::getMaxValueSize (ALLOCATOR_HOOKS_API* alloc_hooks) {
157175 size_t nbins{0 };
158176 alloc_hooks->get_allocator_property (" arenas.nbins" , &nbins);
0 commit comments