1
1
mirror of https://github.com/MarginaliaSearch/MarginaliaSearch.git synced 2025-10-05 21:22:39 +02:00

(index) Adjust timeout logic for evaluation

This commit is contained in:
Viktor Lofgren
2025-07-27 17:27:07 +02:00
parent 233f0acfb1
commit caf2e6fbb7
2 changed files with 11 additions and 8 deletions

View File

@@ -76,7 +76,7 @@ public class IndexQueryExecution {
}
private void lookup(IndexQuery query) {
final LongQueryBuffer buffer = new LongQueryBuffer(512);
final LongQueryBuffer buffer = new LongQueryBuffer(8192);
try {
while (query.hasMore() && budget.hasTimeLeft()) {
@@ -103,7 +103,7 @@ public class IndexQueryExecution {
}
if (stealWork) {
resultHeap.addAll(rankingService.rankResults(rankingContext, docIds, false));
resultHeap.addAll(rankingService.rankResults(rankingContext, budget, docIds, false));
}
else {
// Spawn an evaluation task
@@ -120,7 +120,7 @@ public class IndexQueryExecution {
try {
if (!budget.hasTimeLeft())
return;
resultHeap.addAll(rankingService.rankResults(rankingContext, docIds, false));
resultHeap.addAll(rankingService.rankResults(rankingContext, budget, docIds, false));
} finally {
synchronized (IndexQueryExecution.this) {
if (--evaluationJobCounter == 0) {

View File

@@ -20,6 +20,7 @@ import nu.marginalia.index.index.CombinedIndexReader;
import nu.marginalia.index.index.StatefulIndex;
import nu.marginalia.index.model.ResultRankingContext;
import nu.marginalia.index.model.SearchTermsUtil;
import nu.marginalia.index.query.IndexSearchBudget;
import nu.marginalia.index.results.model.PhraseConstraintGroupList;
import nu.marginalia.index.results.model.QuerySearchTerms;
import nu.marginalia.index.results.model.ids.CombinedDocIdList;
@@ -57,9 +58,10 @@ public class IndexResultRankingService {
}
public List<SearchResultItem> rankResults(
ResultRankingContext rankingContext,
CombinedDocIdList resultIds,
boolean exportDebugData)
ResultRankingContext rankingContext,
IndexSearchBudget budget,
CombinedDocIdList resultIds,
boolean exportDebugData)
{
if (resultIds.isEmpty())
return List.of();
@@ -94,7 +96,7 @@ public class IndexResultRankingService {
// Iterate over documents by their index in the combinedDocIds, as we need the index for the
// term data arrays as well
for (int i = 0; i < resultIds.size(); i++) {
for (int i = 0; i < resultIds.size() && budget.hasTimeLeft(); i++) {
// Prepare term-level data for the document
for (int ti = 0; ti < flags.length; ti++) {
@@ -171,9 +173,10 @@ public class IndexResultRankingService {
}
resultsList.clear();
IndexSearchBudget budget = new IndexSearchBudget(10000);
resultsList.addAll(this.rankResults(
resultRankingContext,
new CombinedDocIdList(combinedIdsList),
budget, new CombinedDocIdList(combinedIdsList),
true)
);
}