diff options
Diffstat (limited to 'vespalib/src/vespa')
21 files changed, 72 insertions, 37 deletions
diff --git a/vespalib/src/vespa/vespalib/btree/btreebuilder.hpp b/vespalib/src/vespa/vespalib/btree/btreebuilder.hpp index 5abe2b2cebd..3162dfb4820 100644 --- a/vespalib/src/vespa/vespalib/btree/btreebuilder.hpp +++ b/vespalib/src/vespa/vespalib/btree/btreebuilder.hpp @@ -106,10 +106,10 @@ normalize() /* Adjust validLeaves for rightmost nodes */ for (level = 0; level < _inodes.size(); level++) { InternalNodeType *inode = _inodes[level].data; - NodeRef lcRef(inode->getLastChild()); + NodeRef lcRef(inode->get_last_child_relaxed()); assert(NodeAllocatorType::isValidRef(lcRef)); assert((level == 0) == _allocator.isLeafRef(lcRef)); - inode->incValidLeaves(_allocator.validLeaves(inode->getLastChild())); + inode->incValidLeaves(_allocator.validLeaves(inode->get_last_child_relaxed())); inode->update(inode->validSlots() - 1, level == 0 ? _allocator.mapLeafRef(lcRef)->getLastKey() : @@ -134,10 +134,10 @@ normalize() inode = _allocator.mapInternalRef(iRef); assert(inode != nullptr); assert(inode->validSlots() >= 1); - child = inode->getLastChild(); + child = inode->get_last_child_relaxed(); } else { /* Use next to last child of rightmost node on level */ - child = inode->getChild(inode->validSlots() - 2); + child = inode->get_child_relaxed(inode->validSlots() - 2); } if (level == 0) break; @@ -190,11 +190,11 @@ normalize() } if (pnode->validSlots() > 0) { uint32_t s = pnode->validSlots() - 1; - LeafNodeType *l = _allocator.mapLeafRef(pnode->getChild(s)); + LeafNodeType *l = _allocator.mapLeafRef(pnode->get_child_relaxed(s)); pnode->writeKey(s, l->getLastKey()); if (s > 0) { --s; - l = _allocator.mapLeafRef(pnode->getChild(s)); + l = _allocator.mapLeafRef(pnode->get_child_relaxed(s)); pnode->writeKey(s, l->getLastKey()); } } @@ -202,7 +202,7 @@ normalize() InternalNodeType *lpnode = _allocator.mapInternalRef(leftInodes[0]); uint32_t s = lpnode->validSlots() - 1; - LeafNodeType *l = _allocator.mapLeafRef(lpnode->getChild(s)); + LeafNodeType *l = _allocator.mapLeafRef(lpnode->get_child_relaxed(s)); lpnode->writeKey(s, l->getLastKey()); } } @@ -256,11 +256,11 @@ normalize() if (pnode->validSlots() > 0) { uint32_t s = pnode->validSlots() - 1; InternalNodeType *n = - _allocator.mapInternalRef(pnode->getChild(s)); + _allocator.mapInternalRef(pnode->get_child_relaxed(s)); pnode->writeKey(s, n->getLastKey()); if (s > 0) { --s; - n = _allocator.mapInternalRef(pnode->getChild(s)); + n = _allocator.mapInternalRef(pnode->get_child_relaxed(s)); pnode->writeKey(s, n->getLastKey()); } } @@ -270,7 +270,7 @@ normalize() _allocator.mapInternalRef(leftInodes[level + 1]); uint32_t s = lpnode->validSlots() - 1; InternalNodeType *n = - _allocator.mapInternalRef(lpnode->getChild(s)); + _allocator.mapInternalRef(lpnode->get_child_relaxed(s)); lpnode->writeKey(s, n->getLastKey()); } } @@ -333,7 +333,7 @@ allocNewLeafNode() } inode = _inodes[level].data; assert(inode->validSlots() > 0); - NodeRef lcRef(inode->getLastChild()); + NodeRef lcRef(inode->get_last_child_relaxed()); inode->incValidLeaves(_allocator.validLeaves(lcRef)); inode->update(inode->validSlots() - 1, level == 0 ? @@ -358,7 +358,7 @@ allocNewLeafNode() } while (level > 0) { assert(inode->validSlots() > 0); - child = inode->getLastChild(); + child = inode->get_last_child_relaxed(); assert(!_allocator.isLeafRef(child)); inode = _allocator.mapInternalRef(child); level--; diff --git a/vespalib/src/vespa/vespalib/btree/btreeinserter.hpp b/vespalib/src/vespa/vespalib/btree/btreeinserter.hpp index b5980e53f93..de6454f8bae 100644 --- a/vespalib/src/vespa/vespalib/btree/btreeinserter.hpp +++ b/vespalib/src/vespa/vespalib/btree/btreeinserter.hpp @@ -34,17 +34,17 @@ BTreeInserter<KeyT, DataT, AggrT, CompareT, TraitsT, AggrCalcT>::rebalanceLeafEn auto &pathElem = itr.getPath(0); InternalNodeType *parentNode = pathElem.getWNode(); uint32_t parentIdx = pathElem.getIdx(); - BTreeNode::Ref leafRef = parentNode->getChild(parentIdx); + BTreeNode::Ref leafRef = parentNode->get_child_relaxed(parentIdx); BTreeNode::Ref leftRef = BTreeNode::Ref(); LeafNodeType *leftNode = nullptr; BTreeNode::Ref rightRef = BTreeNode::Ref(); LeafNodeType *rightNode = nullptr; if (parentIdx > 0) { - leftRef = parentNode->getChild(parentIdx - 1); + leftRef = parentNode->get_child_relaxed(parentIdx - 1); leftNode = allocator.mapLeafRef(leftRef); } if (parentIdx + 1 < parentNode->validSlots()) { - rightRef = parentNode->getChild(parentIdx + 1); + rightRef = parentNode->get_child_relaxed(parentIdx + 1); rightNode = allocator.mapLeafRef(rightRef); } if (leftNode != nullptr && leftNode->validSlots() < LeafNodeType::maxSlots() && @@ -138,7 +138,7 @@ insert(BTreeNode::Ref &root, idx = pe.getIdx(); AggrT olda(AggrCalcT::hasAggregated() ? node->getAggregated() : AggrT()); - BTreeNode::Ref subNode = node->getChild(idx); + BTreeNode::Ref subNode = node->get_child_relaxed(idx); node->update(idx, *lastKey, subNode); node->incValidLeaves(1); if (NodeAllocatorType::isValidRef(splitNodeRef)) { diff --git a/vespalib/src/vespa/vespalib/btree/btreeiterator.hpp b/vespalib/src/vespa/vespalib/btree/btreeiterator.hpp index 042779f1b1b..8ecd26835c4 100644 --- a/vespalib/src/vespa/vespalib/btree/btreeiterator.hpp +++ b/vespalib/src/vespa/vespalib/btree/btreeiterator.hpp @@ -1163,13 +1163,13 @@ thaw(BTreeNode::Ref rootRef) rootRef; assert(node == allocator.mapInternalRef(nodeRef)); if (!node->getFrozen()) { - node->setChild(pe.getIdx(), childRef); + node->set_child_relaxed(pe.getIdx(), childRef); return rootRef; } InternalNodeTypeRefPair thawed = allocator.thawNode(nodeRef, node); node = thawed.data; pe.setNode(node); - node->setChild(pe.getIdx(), childRef); + node->set_child_relaxed(pe.getIdx(), childRef); childRef = thawed.ref; ++level; } diff --git a/vespalib/src/vespa/vespalib/btree/btreenode.h b/vespalib/src/vespa/vespalib/btree/btreenode.h index 468f17fcd1a..deeaad40ae6 100644 --- a/vespalib/src/vespa/vespalib/btree/btreenode.h +++ b/vespalib/src/vespa/vespalib/btree/btreenode.h @@ -336,8 +336,10 @@ private: public: BTreeNode::Ref getChild(uint32_t idx) const { return getData(idx); } + BTreeNode::Ref get_child_relaxed(uint32_t idx) const { return getData(idx); } void setChild(uint32_t idx, BTreeNode::Ref child) { setData(idx, child); } - BTreeNode::Ref getLastChild() const { return getChild(validSlots() - 1); } + void set_child_relaxed(uint32_t idx, BTreeNode::Ref child) { setData(idx, child); } + BTreeNode::Ref get_last_child_relaxed() const { return get_child_relaxed(validSlots() - 1); } uint32_t validLeaves() const { return _validLeaves; } void setValidLeaves(uint32_t newValidLeaves) { _validLeaves = newValidLeaves; } void incValidLeaves(uint32_t delta) { _validLeaves += delta; } diff --git a/vespalib/src/vespa/vespalib/btree/btreenode.hpp b/vespalib/src/vespa/vespalib/btree/btreenode.hpp index 547dd6f5f3f..62773e57c6f 100644 --- a/vespalib/src/vespa/vespalib/btree/btreenode.hpp +++ b/vespalib/src/vespa/vespalib/btree/btreenode.hpp @@ -273,7 +273,7 @@ splitInsert(BTreeInternalNode *splitNode, uint32_t idx, const KeyT &key, for (uint32_t i = sih.getMedian(); i < validSlots(); ++i) { splitNode->_keys[i - sih.getMedian()] = _keys[i]; splitNode->setData(i - sih.getMedian(), getData(i)); - splitLeaves += allocator.validLeaves(getData(i)); + splitLeaves += allocator.validLeaves(getChild(i)); } splitNode->_validLeaves = splitLeaves; this->cleanRange(sih.getMedian(), validSlots()); @@ -316,7 +316,7 @@ BTreeInternalNode<KeyT, AggrT, NumSlots>::countValidLeaves(uint32_t start, uint3 assert(end <= validSlots()); uint32_t leaves = 0; for (uint32_t i = start; i < end; ++i) { - leaves += allocator.validLeaves(getData(i)); + leaves += allocator.validLeaves(getChild(i)); } return leaves; } diff --git a/vespalib/src/vespa/vespalib/btree/btreeremover.hpp b/vespalib/src/vespa/vespalib/btree/btreeremover.hpp index e0e41c1dd2d..24155abcff9 100644 --- a/vespalib/src/vespa/vespalib/btree/btreeremover.hpp +++ b/vespalib/src/vespa/vespalib/btree/btreeremover.hpp @@ -25,11 +25,11 @@ steal(InternalNodeType *pNode, BTreeNode::Ref rightVictimRef = BTreeNode::Ref(); NodeType * rightVictim = nullptr; if (idx > 0) { - leftVictimRef = pNode->getChild(idx - 1); + leftVictimRef = pNode->get_child_relaxed(idx - 1); leftVictim = allocator.template mapRef<NodeType>(leftVictimRef); } if (idx + 1 < pNode->validSlots()) { - rightVictimRef = pNode->getChild(idx + 1); + rightVictimRef = pNode->get_child_relaxed(idx + 1); rightVictim = allocator.template mapRef<NodeType>(rightVictimRef); } if (leftVictim != nullptr && @@ -141,7 +141,7 @@ remove(BTreeNode::Ref &root, idx = pe.getIdx(); AggrT olda(AggrCalcT::hasAggregated() ? node->getAggregated() : AggrT()); - BTreeNode::Ref subNode = node->getChild(idx); + BTreeNode::Ref subNode = node->get_child_relaxed(idx); node->update(idx, allocator.getLastKey(subNode), subNode); node->decValidLeaves(1); if (level == 0) { diff --git a/vespalib/src/vespa/vespalib/datastore/buffer_type.cpp b/vespalib/src/vespa/vespalib/datastore/buffer_type.cpp index 372370bc2d5..ca908d48210 100644 --- a/vespalib/src/vespa/vespalib/datastore/buffer_type.cpp +++ b/vespalib/src/vespa/vespalib/datastore/buffer_type.cpp @@ -2,6 +2,7 @@ #include "atomic_entry_ref.h" #include "buffer_type.hpp" +#include <algorithm> #include <cassert> #include <cmath> diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store_enumerator.hpp b/vespalib/src/vespa/vespalib/datastore/unique_store_enumerator.hpp index 83e9b10c6d6..ec3b0c54bda 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store_enumerator.hpp +++ b/vespalib/src/vespa/vespalib/datastore/unique_store_enumerator.hpp @@ -56,7 +56,7 @@ void UniqueStoreEnumerator<RefT>::enumerateValues() { _next_enum_val = 1; - _dict_snapshot->foreach_key([this](EntryRef ref) { enumerateValue(ref); }); + _dict_snapshot->foreach_key([this](EntryRef ref) noexcept { enumerateValue(ref); }); } template <typename RefT> diff --git a/vespalib/src/vespa/vespalib/hwaccelrated/private_helpers.hpp b/vespalib/src/vespa/vespalib/hwaccelrated/private_helpers.hpp index 3b063ce6805..76072aa6906 100644 --- a/vespalib/src/vespa/vespalib/hwaccelrated/private_helpers.hpp +++ b/vespalib/src/vespa/vespalib/hwaccelrated/private_helpers.hpp @@ -24,15 +24,17 @@ populationCount(const uint64_t *a, size_t sz) { return count; } -template<typename T> +template<typename T, unsigned ChunkSize> T get(const void * base, bool invert) { + static_assert(sizeof(T) == ChunkSize, "sizeof(T) == ChunkSize"); T v; memcpy(&v, base, sizeof(T)); return __builtin_expect(invert, false) ? ~v : v; } -template <typename T> +template <typename T, unsigned ChunkSize> const T * cast(const void * ptr, size_t offsetBytes) { + static_assert(sizeof(T) == ChunkSize, "sizeof(T) == ChunkSize"); return static_cast<const T *>(static_cast<const void *>(static_cast<const char *>(ptr) + offsetBytes)); } @@ -43,14 +45,14 @@ andChunks(size_t offset, const std::vector<std::pair<const void *, bool>> & src, static_assert(sizeof(Chunk) == ChunkSize, "sizeof(Chunk) == ChunkSize"); static_assert(ChunkSize*Chunks == 64, "ChunkSize*Chunks == 64"); Chunk * chunk = static_cast<Chunk *>(dest); - const Chunk * tmp = cast<Chunk>(src[0].first, offset); + const Chunk * tmp = cast<Chunk, ChunkSize>(src[0].first, offset); for (size_t n=0; n < Chunks; n++) { - chunk[n] = get<Chunk>(tmp+n, src[0].second); + chunk[n] = get<Chunk, ChunkSize>(tmp+n, src[0].second); } for (size_t i(1); i < src.size(); i++) { - tmp = cast<Chunk>(src[i].first, offset); + tmp = cast<Chunk, ChunkSize>(src[i].first, offset); for (size_t n=0; n < Chunks; n++) { - chunk[n] &= get<Chunk>(tmp+n, src[i].second); + chunk[n] &= get<Chunk, ChunkSize>(tmp+n, src[i].second); } } } @@ -62,14 +64,14 @@ orChunks(size_t offset, const std::vector<std::pair<const void *, bool>> & src, static_assert(sizeof(Chunk) == ChunkSize, "sizeof(Chunk) == ChunkSize"); static_assert(ChunkSize*Chunks == 64, "ChunkSize*Chunks == 64"); Chunk * chunk = static_cast<Chunk *>(dest); - const Chunk * tmp = cast<Chunk>(src[0].first, offset); + const Chunk * tmp = cast<Chunk, ChunkSize>(src[0].first, offset); for (size_t n=0; n < Chunks; n++) { - chunk[n] = get<Chunk>(tmp+n, src[0].second); + chunk[n] = get<Chunk, ChunkSize>(tmp+n, src[0].second); } for (size_t i(1); i < src.size(); i++) { - tmp = cast<Chunk>(src[i].first, offset); + tmp = cast<Chunk, ChunkSize>(src[i].first, offset); for (size_t n=0; n < Chunks; n++) { - chunk[n] |= get<Chunk>(tmp+n, src[i].second); + chunk[n] |= get<Chunk, ChunkSize>(tmp+n, src[i].second); } } } diff --git a/vespalib/src/vespa/vespalib/net/async_resolver.cpp b/vespalib/src/vespa/vespalib/net/async_resolver.cpp index f66d34d4174..7eab9d7c13c 100644 --- a/vespalib/src/vespa/vespalib/net/async_resolver.cpp +++ b/vespalib/src/vespa/vespalib/net/async_resolver.cpp @@ -155,6 +155,8 @@ AsyncResolver::AsyncResolver(HostResolver::SP resolver, size_t num_threads) { } +AsyncResolver::~AsyncResolver() = default; + void AsyncResolver::wait_for_pending_resolves() { _executor->sync(); diff --git a/vespalib/src/vespa/vespalib/net/async_resolver.h b/vespalib/src/vespa/vespalib/net/async_resolver.h index 28d04e76c16..64e2285acd2 100644 --- a/vespalib/src/vespa/vespalib/net/async_resolver.h +++ b/vespalib/src/vespa/vespalib/net/async_resolver.h @@ -124,6 +124,7 @@ private: AsyncResolver(HostResolver::SP resolver, size_t num_threads); public: + ~AsyncResolver(); void resolve_async(const vespalib::string &spec, ResultHandler::WP result_handler); void wait_for_pending_resolves(); static AsyncResolver::SP create(Params params); diff --git a/vespalib/src/vespa/vespalib/net/tls/maybe_tls_crypto_engine.cpp b/vespalib/src/vespa/vespalib/net/tls/maybe_tls_crypto_engine.cpp index 91dc64e4165..832d52c0383 100644 --- a/vespalib/src/vespa/vespalib/net/tls/maybe_tls_crypto_engine.cpp +++ b/vespalib/src/vespa/vespalib/net/tls/maybe_tls_crypto_engine.cpp @@ -5,6 +5,8 @@ namespace vespalib { +MaybeTlsCryptoEngine::~MaybeTlsCryptoEngine() = default; + CryptoSocket::UP MaybeTlsCryptoEngine::create_client_crypto_socket(SocketHandle socket, const SocketSpec &spec) { diff --git a/vespalib/src/vespa/vespalib/net/tls/maybe_tls_crypto_engine.h b/vespalib/src/vespa/vespalib/net/tls/maybe_tls_crypto_engine.h index 8c8a4452c80..2b82d6eb8bc 100644 --- a/vespalib/src/vespa/vespalib/net/tls/maybe_tls_crypto_engine.h +++ b/vespalib/src/vespa/vespalib/net/tls/maybe_tls_crypto_engine.h @@ -28,6 +28,7 @@ public: : _null_engine(std::make_shared<NullCryptoEngine>()), _tls_engine(std::move(tls_engine)), _use_tls_when_client(use_tls_when_client) {} + ~MaybeTlsCryptoEngine() override; bool use_tls_when_client() const override { return _use_tls_when_client; } bool always_use_tls_when_server() const override { return false; } CryptoSocket::UP create_client_crypto_socket(SocketHandle socket, const SocketSpec &spec) override; diff --git a/vespalib/src/vespa/vespalib/net/tls/tls_crypto_engine.cpp b/vespalib/src/vespa/vespalib/net/tls/tls_crypto_engine.cpp index 119b4b93a54..9ae270780b5 100644 --- a/vespalib/src/vespa/vespalib/net/tls/tls_crypto_engine.cpp +++ b/vespalib/src/vespa/vespalib/net/tls/tls_crypto_engine.cpp @@ -6,6 +6,8 @@ namespace vespalib { +TlsCryptoEngine::~TlsCryptoEngine() = default; + TlsCryptoEngine::TlsCryptoEngine(net::tls::TransportSecurityOptions tls_opts, net::tls::AuthorizationMode authz_mode) : _tls_ctx(net::tls::TlsContext::create_default_context(tls_opts, authz_mode)) { diff --git a/vespalib/src/vespa/vespalib/net/tls/tls_crypto_engine.h b/vespalib/src/vespa/vespalib/net/tls/tls_crypto_engine.h index 13a514f6954..0e05363ab1b 100644 --- a/vespalib/src/vespa/vespalib/net/tls/tls_crypto_engine.h +++ b/vespalib/src/vespa/vespalib/net/tls/tls_crypto_engine.h @@ -25,6 +25,7 @@ private: public: explicit TlsCryptoEngine(net::tls::TransportSecurityOptions tls_opts, net::tls::AuthorizationMode authz_mode = net::tls::AuthorizationMode::Enforce); + ~TlsCryptoEngine() override; std::unique_ptr<TlsCryptoSocket> create_tls_client_crypto_socket(SocketHandle socket, const SocketSpec &spec) override; std::unique_ptr<TlsCryptoSocket> create_tls_server_crypto_socket(SocketHandle socket) override; bool use_tls_when_client() const override { return true; } diff --git a/vespalib/src/vespa/vespalib/test/btree/btree_printer.h b/vespalib/src/vespa/vespalib/test/btree/btree_printer.h index acac4df90c8..8430dc894ba 100644 --- a/vespalib/src/vespa/vespalib/test/btree/btree_printer.h +++ b/vespalib/src/vespa/vespalib/test/btree/btree_printer.h @@ -60,7 +60,7 @@ class BTreePrinter return; } for (uint32_t i = 0; i < n.validSlots(); ++i) { - printNode(n.getData(i)); + printNode(n.getChild(i)); } } diff --git a/vespalib/src/vespa/vespalib/util/CMakeLists.txt b/vespalib/src/vespa/vespalib/util/CMakeLists.txt index 752bf60c688..747ed736aad 100644 --- a/vespalib/src/vespa/vespalib/util/CMakeLists.txt +++ b/vespalib/src/vespa/vespalib/util/CMakeLists.txt @@ -18,6 +18,7 @@ vespa_add_library(vespalib_vespalib_util OBJECT classname.cpp compress.cpp compressor.cpp + count_down_latch.cpp cpu_usage.cpp destructor_callbacks.cpp dual_merge_director.cpp @@ -26,6 +27,7 @@ vespa_add_library(vespalib_vespalib_util OBJECT exceptions.cpp executor_idle_tracking.cpp file_area_freelist.cpp + gate.cpp gencnt.cpp generationhandler.cpp generationholder.cpp diff --git a/vespalib/src/vespa/vespalib/util/count_down_latch.cpp b/vespalib/src/vespa/vespalib/util/count_down_latch.cpp new file mode 100644 index 00000000000..5064a0a962f --- /dev/null +++ b/vespalib/src/vespa/vespalib/util/count_down_latch.cpp @@ -0,0 +1,9 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "count_down_latch.h" + +namespace vespalib { + +CountDownLatch::~CountDownLatch() = default; + +} diff --git a/vespalib/src/vespa/vespalib/util/count_down_latch.h b/vespalib/src/vespa/vespalib/util/count_down_latch.h index 613a60e90c5..d4298f0d5a9 100644 --- a/vespalib/src/vespa/vespalib/util/count_down_latch.h +++ b/vespalib/src/vespa/vespalib/util/count_down_latch.h @@ -90,7 +90,7 @@ public: /** * Empty. Needs to be virtual to reduce compiler warnings. **/ - virtual ~CountDownLatch() = default; + virtual ~CountDownLatch(); }; } // namespace vespalib diff --git a/vespalib/src/vespa/vespalib/util/gate.cpp b/vespalib/src/vespa/vespalib/util/gate.cpp new file mode 100644 index 00000000000..485c29dc5c8 --- /dev/null +++ b/vespalib/src/vespa/vespalib/util/gate.cpp @@ -0,0 +1,9 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "gate.h" + +namespace vespalib { + +Gate::~Gate() = default; + +} diff --git a/vespalib/src/vespa/vespalib/util/gate.h b/vespalib/src/vespa/vespalib/util/gate.h index c914a4f0911..315adb2939e 100644 --- a/vespalib/src/vespa/vespalib/util/gate.h +++ b/vespalib/src/vespa/vespalib/util/gate.h @@ -17,6 +17,7 @@ public: * Sets the initial count to 1. **/ Gate() noexcept : CountDownLatch(1) {} + ~Gate() override; }; } // namespace vespalib |