summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-11-22 13:20:18 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-11-22 13:20:18 +0000
commitbcda1a2143815396ee156b3475ffe9cef343e13f (patch)
tree2d0b4eec524cb14cac0a4306a69fd61afcdea909 /searchlib
parent4c55000acb79a6626cfec05759202eb317ed16a8 (diff)
Ensure the hot path is inlined, and cold path is in separate methods.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.cpp48
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.h4
2 files changed, 32 insertions, 20 deletions
diff --git a/searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.cpp b/searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.cpp
index 431f386fa86..0bbdf89bab7 100644
--- a/searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.cpp
+++ b/searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.cpp
@@ -138,8 +138,8 @@ public:
bool
allTermsHaveMatch(const SimplePhraseSearch::Children &terms, const vector<uint32_t> &eval_order, uint32_t doc_id) {
- for (uint32_t i = 0; i < terms.size(); ++i) {
- if (!terms[eval_order[i]]->seek(doc_id)) {
+ for (unsigned int order : eval_order) {
+ if (!terms[order]->seek(doc_id)) {
return false;
}
}
@@ -147,13 +147,18 @@ allTermsHaveMatch(const SimplePhraseSearch::Children &terms, const vector<uint32
}
} // namespace
-void
+inline void
SimplePhraseSearch::phraseSeek(uint32_t doc_id) {
if (allTermsHaveMatch(getChildren(), _eval_order, doc_id)) {
- AndSearch::doUnpack(doc_id);
- if (PhraseMatcher(_childMatch, _eval_order, _iterators).hasMatch()) {
- setDocId(doc_id);
- }
+ matchPhrase(doc_id);
+ }
+}
+
+void
+SimplePhraseSearch::matchPhrase(uint32_t doc_id) {
+ AndSearch::doUnpack(doc_id);
+ if (PhraseMatcher(_childMatch, _eval_order, _iterators).hasMatch()) {
+ setDocId(doc_id);
}
}
@@ -180,25 +185,30 @@ void
SimplePhraseSearch::doSeek(uint32_t doc_id) {
phraseSeek(doc_id);
if (_strict) {
- uint32_t next_candidate = doc_id;
- while (getDocId() < doc_id || getDocId() == beginId()) {
- getChildren()[0]->seek(next_candidate + 1);
- next_candidate = getChildren()[0]->getDocId();
- if (isAtEnd(next_candidate)) {
- setAtEnd();
- return;
- }
- // child must behave as strict.
- assert(next_candidate > doc_id && next_candidate != beginId());
+ doStrictSeek(doc_id);
+ }
+}
- phraseSeek(next_candidate);
+void
+SimplePhraseSearch::doStrictSeek(uint32_t doc_id) {
+ uint32_t next_candidate = doc_id;
+ while (getDocId() < doc_id || getDocId() == beginId()) {
+ getChildren()[0]->seek(next_candidate + 1);
+ next_candidate = getChildren()[0]->getDocId();
+ if (isAtEnd(next_candidate)) {
+ setAtEnd();
+ return;
}
+ // child must behave as strict.
+ assert(next_candidate > doc_id && next_candidate != beginId());
+
+ phraseSeek(next_candidate);
}
}
void
SimplePhraseSearch::doUnpack(uint32_t doc_id) {
- // All children has already been unpacked before this call is made.
+ // All children have already been unpacked before this call is made.
_tmd.reset(doc_id);
PhraseMatcher(_childMatch, _eval_order, _iterators).fillPositions(_tmd);
diff --git a/searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.h b/searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.h
index 00e75f44844..8ee49183f51 100644
--- a/searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.h
+++ b/searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.h
@@ -27,7 +27,9 @@ class SimplePhraseSearch : public AndSearch
// Reuse this vector instead of allocating a new one when needed.
std::vector<It> _iterators;
- void phraseSeek(uint32_t doc_id);
+ VESPA_DLL_LOCAL void phraseSeek(uint32_t doc_id);
+ VESPA_DLL_LOCAL void matchPhrase(uint32_t doc_id) __attribute__((noinline));
+ VESPA_DLL_LOCAL void doStrictSeek(uint32_t doc_id) __attribute__((noinline));
public:
/**
* Takes ownership of the contents of children.