Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce latency in fetch phase for large shard counts #120419

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,30 +158,31 @@ private void innerRunFetch(ScoreDoc[] scoreDocs, int numShards, SearchPhaseContr
);
for (int i = 0; i < docIdsToLoad.length; i++) {
List<Integer> entry = docIdsToLoad[i];
RankDocShardInfo rankDocs = rankDocsPerShard == null || rankDocsPerShard.get(i).isEmpty()
? null
: new RankDocShardInfo(rankDocsPerShard.get(i));
SearchPhaseResult shardPhaseResult = searchPhaseShardResults.get(i);
if (entry == null) { // no results for this shard ID
if (shardPhaseResult != null) {
// if we got some hits from this shard we have to release the context there
// we do this as we go since it will free up resources and passing on the request on the
// transport layer is cheap.
releaseIrrelevantSearchContext(shardPhaseResult, context);
progressListener.notifyFetchResult(i);
}
// if we got some hits from this shard we have to release the context
// we do this below after sending out the fetch requests relevant to the search to give priority to those requests
// that contribute to the final search response
// in any case we count down this result since we don't talk to this shard anymore
counter.countDown();
} else {
executeFetch(
shardPhaseResult,
searchPhaseShardResults.get(i),
counter,
entry,
rankDocs,
rankDocsPerShard == null || rankDocsPerShard.get(i).isEmpty() ? null : new RankDocShardInfo(rankDocsPerShard.get(i)),
(lastEmittedDocPerShard != null) ? lastEmittedDocPerShard[i] : null
);
}
}
for (int i = 0; i < docIdsToLoad.length; i++) {
if (docIdsToLoad[i] == null) {
SearchPhaseResult shardPhaseResult = searchPhaseShardResults.get(i);
if (shardPhaseResult != null) {
releaseIrrelevantSearchContext(shardPhaseResult, context);
progressListener.notifyFetchResult(i);
}
}
}
}

private List<Map<Integer, RankDoc>> splitRankDocsPerShard(ScoreDoc[] scoreDocs, int numShards) {
Expand Down