-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix false positive query timeouts due to using cached time (#3454)
* Fix false positive query timeouts due to using cached time Signed-off-by: Ahmad AbuKhalil <abukhali@amazon.com> * delegate nanoTime call to SearchContext Signed-off-by: Ahmad AbuKhalil <abukhali@amazon.com> * add override to SearchContext getRelativeTimeInMillis to force non cached time Signed-off-by: Ahmad AbuKhalil <abukhali@amazon.com>
- Loading branch information
1 parent
5b3a164
commit bc3dffb
Showing
5 changed files
with
143 additions
and
10 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
...rks/src/main/java/org/opensearch/benchmark/time/NanoTimeVsCurrentTimeMillisBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.benchmark.time; | ||
|
||
import org.openjdk.jmh.annotations.*; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
@Fork(3) | ||
@Warmup(iterations = 10) | ||
@Measurement(iterations = 20) | ||
@BenchmarkMode(Mode.AverageTime) | ||
@OutputTimeUnit(TimeUnit.NANOSECONDS) | ||
@State(Scope.Benchmark) | ||
@SuppressWarnings("unused") // invoked by benchmarking framework | ||
public class NanoTimeVsCurrentTimeMillisBenchmark { | ||
private volatile long var = 0; | ||
|
||
@Benchmark | ||
public long currentTimeMillis() { | ||
return System.currentTimeMillis(); | ||
} | ||
|
||
@Benchmark | ||
public long nanoTime() { | ||
return System.nanoTime(); | ||
} | ||
|
||
/* | ||
* this acts as upper bound of how time is cached in org.opensearch.threadpool.ThreadPool | ||
* */ | ||
@Benchmark | ||
public long accessLongVar() { | ||
return var++; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters