diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-03-31 22:59:08 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-03-31 22:59:08 +0000 |
commit | 7e028c9a1729ea8998d621b2ca179e2b55cdc211 (patch) | |
tree | 4eb9b4f258ef6ba696194bb79de0c661343c2e14 /searchlib | |
parent | f93e8f9744dc51051c7c83773738fa1224d18e93 (diff) |
- Based on feedback from callgrind and perf add hint about most likely branch in frequently called code.
- Inline small frequent methods.
Diffstat (limited to 'searchlib')
4 files changed, 31 insertions, 56 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp index 5f0b06a1294..697fa33a060 100644 --- a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp @@ -97,16 +97,17 @@ MultiValueNumericPostingAttribute<B, M>::DocumentWeightAttributeAdapter::lookup( { const IEnumStoreDictionary& dictionary = self._enumStore.get_dictionary(); int64_t int_term; - if (key.asInteger(int_term)) { - auto comp = self._enumStore.make_comparator(int_term); - auto find_result = dictionary.find_posting_list(comp, dictionary_snapshot); - if (find_result.first.valid()) { - auto pidx = find_result.second; - if (pidx.valid()) { - const PostingList &plist = self.getPostingList(); - auto minmax = plist.getAggregated(pidx); - return LookupResult(pidx, plist.frozenSize(pidx), minmax.getMin(), minmax.getMax(), find_result.first); - } + if ( !key.asInteger(int_term)) { + return LookupResult(); + } + auto comp = self._enumStore.make_comparator(int_term); + auto find_result = dictionary.find_posting_list(comp, dictionary_snapshot); + if (find_result.first.valid()) { + auto pidx = find_result.second; + if (pidx.valid()) { + const PostingList &plist = self.getPostingList(); + auto minmax = plist.getAggregated(pidx); + return LookupResult(pidx, plist.frozenSize(pidx), minmax.getMin(), minmax.getMax(), find_result.first); } } return LookupResult(); diff --git a/searchlib/src/vespa/searchlib/fef/properties.cpp b/searchlib/src/vespa/searchlib/fef/properties.cpp index e7a69cbcfa7..3e6a37e44dd 100644 --- a/searchlib/src/vespa/searchlib/fef/properties.cpp +++ b/searchlib/src/vespa/searchlib/fef/properties.cpp @@ -10,44 +10,6 @@ namespace search::fef { const Property::Value Property::_emptyValue; const Property::Values Property::_emptyValues; -Property::Property(const Property::Values &values) - : _values(&values) -{ } - -Property::Property() - : _values(&_emptyValues) -{ } - -bool -Property::found() const -{ - return !(*_values).empty(); -} - -const Property::Value & -Property::get() const -{ - if ((*_values).empty()) { - return _emptyValue; - } - return (*_values)[0]; -} - -const Property::Value & -Property::get(const Property::Value &fallBack) const -{ - if ((*_values).empty()) { - return fallBack; - } - return (*_values)[0]; -} - -uint32_t -Property::size() const -{ - return (*_values).size(); -} - const Property::Value & Property::getAt(uint32_t idx) const { diff --git a/searchlib/src/vespa/searchlib/fef/properties.h b/searchlib/src/vespa/searchlib/fef/properties.h index 37d29a0ba50..468e9a90fab 100644 --- a/searchlib/src/vespa/searchlib/fef/properties.h +++ b/searchlib/src/vespa/searchlib/fef/properties.h @@ -37,7 +37,7 @@ private: * * @param values the values for this property **/ - Property(const Values &values); + Property(const Values &values) : _values(&values) { } public: /** @@ -46,14 +46,16 @@ public: * object on the stack in the application, and will also be used * by the @ref Properties class when a lookup gives no results. **/ - Property(); + Property() : _values(&_emptyValues) { } /** * Check if we found what we were looking for or not. * * @return true if the key we looked up had at least one value **/ - bool found() const; + bool found() const { + return !(*_values).empty(); + } /** * Get the first value assigned to the looked up key. This method @@ -61,7 +63,12 @@ public: * * @return first value for the looked up key, or "" **/ - const Value &get() const; + const Value &get() const { + if ((*_values).empty()) { + return _emptyValue; + } + return (*_values)[0]; + } /** * Get the first value assigned to the looked up key. This method @@ -71,14 +78,19 @@ public: * @return first value for the looked up key, or fallBack * @param fallBack value to return if no values were found **/ - const Value & get(const Value &fallBack) const; + const Value & get(const Value &fallBack) const { + if ((*_values).empty()) { + return fallBack; + } + return (*_values)[0]; + } /** * The number of values found for the looked up key. * * @return number of values for this property **/ - uint32_t size() const; + uint32_t size() const { return (*_values).size(); } /** * Obtain a specific value for the looked up key. diff --git a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp index c37dba762ef..0af36d6bb94 100644 --- a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp +++ b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp @@ -101,12 +101,12 @@ bool SimpleQueryStackDumpIterator::readNext() { } else { _currWeight.setPercent(100); } - if (ParseItem::getFeature_UniqueId(typefield)) { + if (__builtin_expect(ParseItem::getFeature_UniqueId(typefield), false)) { _currUniqueId = readCompressedPositiveInt(p); } else { _currUniqueId = 0; } - if (ParseItem::getFeature_Flags(typefield)) { + if (__builtin_expect(ParseItem::getFeature_Flags(typefield), false)) { if ((p + sizeof(uint8_t)) > _bufEnd) return false; _currFlags = (uint8_t)*p++; } else { |