Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 0 additions & 6 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -404,18 +404,12 @@ tests:
- class: org.elasticsearch.reindex.management.ReindexManagementClientYamlTestSuiteIT
method: test {yaml=reindex/30_cancel_reindex/Cancel running reindex returns response and GET confirms completed}
issue: https://github.com/elastic/elasticsearch/issues/142079
- class: org.elasticsearch.compute.lucene.query.LuceneTopNSourceOperatorScoringTests
method: testAccumulateSearchLoad
issue: https://github.com/elastic/elasticsearch/issues/142986
- class: org.elasticsearch.xpack.rank.rrf.RRFRankClientYamlTestSuiteIT
method: test {yaml=rrf/700_rrf_retriever_search_api_compatibility/nested compound retrievers with min_score correctly compute total_hits}
issue: https://github.com/elastic/elasticsearch/issues/142997
- class: org.elasticsearch.xpack.esql.qa.multi_node.GenerativeIT
method: test
issue: https://github.com/elastic/elasticsearch/issues/143023
- class: org.elasticsearch.compute.lucene.query.LuceneTopNSourceOperatorTests
method: testAccumulateSearchLoad
issue: https://github.com/elastic/elasticsearch/issues/143111
- class: org.elasticsearch.index.mapper.IpFieldMapperTests
method: testSyntheticSourceWithTranslogSnapshot
issue: https://github.com/elastic/elasticsearch/issues/143123
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public DriverContext driverContext() {
* thread to do other work instead of blocking or busy-spinning on the blocked operator.
*/
SubscribableListener<Void> run(TimeValue maxTime, int maxIterations, LongSupplier nowSupplier) {
Comment thread
ivancea marked this conversation as resolved.
Outdated
updateStatus(0, 0, DriverStatus.Status.RUNNING, "driver running");
updateStatus(0, 0, DriverStatus.Status.RUNNING, "driver running", nowSupplier);
long maxTimeNanos = maxTime.nanos();
// Start time, used to stop the calculations after maxTime has passed.
long startTime = nowSupplier.getAsLong();
Expand Down Expand Up @@ -218,26 +218,56 @@ SubscribableListener<Void> run(TimeValue maxTime, int maxIterations, LongSupplie

long now = nowSupplier.getAsLong();
if (isBlocked.listener().isDone() == false) {
updateStatus(now - lastStatusUpdateTime, iterationsSinceLastStatusUpdate, DriverStatus.Status.ASYNC, isBlocked.reason());
updateStatus(
now - lastStatusUpdateTime,
iterationsSinceLastStatusUpdate,
DriverStatus.Status.ASYNC,
isBlocked.reason(),
nowSupplier
);
return isBlocked.listener();
}
if (isFinished()) {
finishNanos = now;
updateStatus(finishNanos - lastStatusUpdateTime, iterationsSinceLastStatusUpdate, DriverStatus.Status.DONE, "driver done");
updateStatus(
finishNanos - lastStatusUpdateTime,
iterationsSinceLastStatusUpdate,
DriverStatus.Status.DONE,
"driver done",
nowSupplier
);
driverContext.finish();
Releasables.close(releasable, driverContext.getSnapshot());
return Operator.NOT_BLOCKED.listener();
}
if (totalIterationsThisRun >= maxIterations) {
updateStatus(now - lastStatusUpdateTime, iterationsSinceLastStatusUpdate, DriverStatus.Status.WAITING, "driver iterations");
updateStatus(
now - lastStatusUpdateTime,
iterationsSinceLastStatusUpdate,
DriverStatus.Status.WAITING,
"driver iterations",
nowSupplier
);
return Operator.NOT_BLOCKED.listener();
}
if (now - startTime >= maxTimeNanos) {
updateStatus(now - lastStatusUpdateTime, iterationsSinceLastStatusUpdate, DriverStatus.Status.WAITING, "driver time");
updateStatus(
now - lastStatusUpdateTime,
iterationsSinceLastStatusUpdate,
DriverStatus.Status.WAITING,
"driver time",
nowSupplier
);
return Operator.NOT_BLOCKED.listener();
}
if (now > nextStatus) {
updateStatus(now - lastStatusUpdateTime, iterationsSinceLastStatusUpdate, DriverStatus.Status.RUNNING, "driver running");
updateStatus(
now - lastStatusUpdateTime,
iterationsSinceLastStatusUpdate,
DriverStatus.Status.RUNNING,
"driver running",
nowSupplier
);
iterationsSinceLastStatusUpdate = 0;
lastStatusUpdateTime = now;
nextStatus = now + statusNanos;
Expand Down Expand Up @@ -402,9 +432,10 @@ public static void start(
) {
driver.completionListener.addListener(listener);
if (driver.started.compareAndSet(false, true)) {
driver.updateStatus(0, 0, DriverStatus.Status.STARTING, "driver starting");
LongSupplier nowSupplier = System::nanoTime;
driver.updateStatus(0, 0, DriverStatus.Status.STARTING, "driver starting", nowSupplier);
initializeEarlyTerminationChecker(driver);
schedule(DEFAULT_TIME_BEFORE_YIELDING, maxIterations, threadContext, executor, driver, driver.completionListener);
schedule(DEFAULT_TIME_BEFORE_YIELDING, maxIterations, threadContext, executor, driver, driver.completionListener, nowSupplier);
}
}

Expand Down Expand Up @@ -455,22 +486,23 @@ private static void schedule(
ThreadContext threadContext,
Executor executor,
Driver driver,
ActionListener<Void> listener
ActionListener<Void> listener,
LongSupplier nowSupplier
) {
final var task = new AbstractRunnable() {

@Override
protected void doRun() {
SubscribableListener<Void> fut = driver.run(maxTime, maxIterations, System::nanoTime);
SubscribableListener<Void> fut = driver.run(maxTime, maxIterations, nowSupplier);
if (driver.isFinished()) {
onComplete(listener);
return;
}
if (fut.isDone()) {
schedule(maxTime, maxIterations, threadContext, executor, driver, listener);
schedule(maxTime, maxIterations, threadContext, executor, driver, listener, nowSupplier);
} else {
ActionListener<Void> readyListener = ActionListener.wrap(
ignored -> schedule(maxTime, maxIterations, threadContext, executor, driver, listener),
ignored -> schedule(maxTime, maxIterations, threadContext, executor, driver, listener, nowSupplier),
this::onFailure
);
fut.addListener(ContextPreservingActionListener.wrapPreservingContext(readyListener, threadContext));
Expand Down Expand Up @@ -570,7 +602,13 @@ private void reportSearchLoad(long extraCpuNanos, long now) {
* @param extraIterations how many iterations to add to the previous status
* @param status the status of the overall driver request
*/
private void updateStatus(long extraCpuNanos, int extraIterations, DriverStatus.Status status, String reason) {
private void updateStatus(
long extraCpuNanos,
int extraIterations,
DriverStatus.Status status,
String reason,
LongSupplier nowSupplier
) {
this.status.getAndUpdate(prev -> {
long now = System.currentTimeMillis();
DriverSleeps sleeps = prev.sleeps();
Expand All @@ -597,7 +635,7 @@ private void updateStatus(long extraCpuNanos, int extraIterations, DriverStatus.
}
}
}
reportSearchLoad(extraCpuNanos, now);
reportSearchLoad(extraCpuNanos, nowSupplier.getAsLong());

return new DriverStatus(
sessionId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ public void testAccumulateSearchLoad() throws IOException {
IndexReader rLarge = null;
try {
r0 = simpleReader(dir0, 0, 1);
rLarge = simpleReader(dirLarge, 200, 10);
rLarge = simpleReader(dirLarge, 2000, 100);
Comment thread
ivancea marked this conversation as resolved.

List<ShardContext> shardContexts = List.of(new MockShardContext(r0, 0), new MockShardContext(rLarge, 1));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public void testAccumulateSearchLoad() throws IOException {
IndexReader rLarge = null;
try {
r0 = simpleReader(dir0, 0, 1);
rLarge = simpleReader(dirLarge, 200, 10);
rLarge = simpleReader(dirLarge, 2000, 100);

List<ShardContext> shardContexts = List.of(new LuceneSourceOperatorTests.MockShardContext(r0, 0) {
@Override
Expand Down