diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-02-25 12:55:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-25 12:55:17 +0100 |
commit | cc59c26b7ff4b7a5754972a025d45858de449f61 (patch) | |
tree | d216a29bd428d837827c9e245eee4bec2c0aab97 | |
parent | 4a23616becf49bf591af6730ddf8b700b138e4aa (diff) | |
parent | 82c1a153a1f846090c35f043efbdd22ca75c2160 (diff) |
Merge branch 'master' into balder/consider_vespa_timer_hz
-rwxr-xr-x | messagebus/src/main/java/com/yahoo/messagebus/Messenger.java | 12 | ||||
-rw-r--r-- | vespalib/src/tests/btree/btree-stress/btree_stress_test.cpp | 40 |
2 files changed, 47 insertions, 5 deletions
diff --git a/messagebus/src/main/java/com/yahoo/messagebus/Messenger.java b/messagebus/src/main/java/com/yahoo/messagebus/Messenger.java index f2ebbbe76cb..478cb7554ee 100755 --- a/messagebus/src/main/java/com/yahoo/messagebus/Messenger.java +++ b/messagebus/src/main/java/com/yahoo/messagebus/Messenger.java @@ -1,6 +1,8 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.messagebus; +import com.yahoo.concurrent.SystemTimer; + import java.util.logging.Level; import java.util.ArrayDeque; @@ -147,12 +149,17 @@ public class Messenger implements Runnable { @Override public void run() { + int timeoutMS = 100*1000/SystemTimer.detectHz(); while (true) { Task task = null; synchronized (this) { if (queue.isEmpty()) { try { - wait(10); + if (children.isEmpty()) { + wait(); + } else { + wait(timeoutMS); + } } catch (final InterruptedException e) { continue; } @@ -173,8 +180,7 @@ public class Messenger implements Runnable { try { task.destroy(); } catch (final Exception e) { - log.warning("An exception was thrown while destroying " + task.getClass().getName() + ": " + - e.toString()); + log.warning("An exception was thrown while destroying " + task.getClass().getName() + ": " + e); log.warning("Someone, somewhere might have to wait indefinitely for something."); } } diff --git a/vespalib/src/tests/btree/btree-stress/btree_stress_test.cpp b/vespalib/src/tests/btree/btree-stress/btree_stress_test.cpp index 95ee39c6507..05f126839e9 100644 --- a/vespalib/src/tests/btree/btree-stress/btree_stress_test.cpp +++ b/vespalib/src/tests/btree/btree-stress/btree_stress_test.cpp @@ -21,6 +21,7 @@ #include <vespa/vespalib/btree/btree.hpp> #include <vespa/vespalib/btree/btreestore.hpp> #include <vespa/vespalib/btree/btreeaggregator.hpp> +#include <vespa/vespalib/datastore/compaction_strategy.h> #include <vespa/log/log.h> LOG_SETUP("btree_stress_test"); @@ -28,6 +29,7 @@ LOG_SETUP("btree_stress_test"); using GenerationHandler = vespalib::GenerationHandler; using RefType = vespalib::datastore::EntryRefT<22>; using vespalib::btree::NoAggregated; +using vespalib::datastore::CompactionStrategy; using vespalib::datastore::EntryRef; using vespalib::makeLambdaTask; using generation_t = GenerationHandler::generation_t; @@ -139,6 +141,9 @@ protected: std::atomic<long> _doneReadWork; std::atomic<bool> _stopRead; bool _reportWork; + bool _want_compact_tree; + uint32_t _consider_compact_tree_checks; + uint32_t _compact_tree_count; Fixture(); ~Fixture() override; @@ -146,6 +151,8 @@ protected: bool adjustWriteIterator(uint32_t key); void insert(uint32_t key); void remove(uint32_t key); + void compact_tree(); + void consider_compact_tree(); void readWork(uint32_t cnt); void readWork(); @@ -172,7 +179,10 @@ Fixture<Params>::Fixture() _doneWriteWork(0), _doneReadWork(0), _stopRead(false), - _reportWork(false) + _reportWork(false), + _want_compact_tree(false), + _consider_compact_tree_checks(0u), + _compact_tree_count(0u) { _rnd.srand48(32); } @@ -250,6 +260,31 @@ Fixture<Params>::remove(uint32_t key) template <typename Params> void +Fixture<Params>::compact_tree() +{ + // Use a compaction strategy that will compact all active buffers + CompactionStrategy compaction_strategy(0.0, 0.0, RefType::numBuffers(), 1.0); + _tree.compact_worst(compaction_strategy); + _writeItr = _tree.begin(); +} + +template <typename Params> +void +Fixture<Params>::consider_compact_tree() +{ + if ((_consider_compact_tree_checks % 1000) == 0) { + _want_compact_tree = true; + } + ++_consider_compact_tree_checks; + if (_want_compact_tree && !_tree.getAllocator().getNodeStore().has_held_buffers()) { + compact_tree(); + _want_compact_tree = false; + ++_compact_tree_count; + } +} + +template <typename Params> +void Fixture<Params>::readWork(uint32_t cnt) { vespalib::Rand48 rnd; @@ -284,6 +319,7 @@ Fixture<Params>::writeWork(uint32_t cnt) { vespalib::Rand48 &rnd(_rnd); for (uint32_t i = 0; i < cnt; ++i) { + consider_compact_tree(); uint32_t key = rnd.lrand48() % _keyLimit; if ((rnd.lrand48() & 1) == 0) { insert(key); @@ -294,7 +330,7 @@ Fixture<Params>::writeWork(uint32_t cnt) } _doneWriteWork += cnt; _stopRead = true; - LOG(info, "done %u write work", cnt); + LOG(info, "done %u write work, %u compact tree", cnt, _compact_tree_count); } template <typename Params> |