-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Introducing "took" time (in ms) for _msearch
#23767
Conversation
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
Hm... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some nits, but they're important as reverting these changes will make the PR smaller.
TransportService transportService = new TransportService(Settings.EMPTY, null, null, | ||
TransportService.NOOP_TRANSPORT_INTERCEPTOR, | ||
boundAddress -> DiscoveryNode.createLocal(settings, boundAddress.publishAddress(), | ||
UUIDs.randomBase64UUID()), null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert all line-length changes that are changing lines that otherwise were not impacted by the changes in this PR.
|
||
TransportMultiSearchAction action = new TransportMultiSearchAction(threadPool, | ||
actionFilters, transportService, clusterService, searchAction, resolver, 10, | ||
System::nanoTime); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell, this is the only change in this file that was necessitated by the changes in this PR.
clusterService.close(); | ||
} | ||
|
||
private enum Clock { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove, a simple boolean like in the other took tests is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was added to readability but I will replace it with a boolean.
@jasontedor I hope I addressed all of your remarks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much @olcbean, I left a first-round review.
|
||
MultiSearchResponse() { | ||
} | ||
|
||
public MultiSearchResponse(Item[] items) { | ||
public MultiSearchResponse(long tookInMillis, Item[] items) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's flip the order of these parameters (in general, I think that new parameters should be added at the end absent a good reason otherwise, but putting it at the end also aligns it more closely with the BulkResponse
; it wouldn't surprise me we are not consistent about this through the codebase, but I'm choosing the BulkResponse
here to be consistent with).
|
||
MultiSearchResponse() { | ||
} | ||
|
||
public MultiSearchResponse(Item[] items) { | ||
public MultiSearchResponse(long tookInMillis, Item[] items) { | ||
this.tookInMillis = tookInMillis; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this parameter down after the order of the parameter is changed.
@@ -111,11 +112,14 @@ public Exception getFailure() { | |||
} | |||
|
|||
private Item[] items; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove this unnecessary space?
/** | ||
* How long the msearch took. | ||
*/ | ||
public TimeValue getTook() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is only used in tests, and only to get the milliseconds, so I think that we can remove it and just use getTookInMillis
in those places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method exists in both SearchResponse
and BulkResponse
.
I would prefer to keep the consistency unless there is a good reason no to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a good reason, the method is unneeded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So shall I remove also the corresponding methods for Bulk
and Search
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not as part of this change.
@@ -138,6 +156,7 @@ public void readFrom(StreamInput in) throws IOException { | |||
for (int i = 0; i < items.length; i++) { | |||
items[i] = Item.readItem(in); | |||
} | |||
tookInMillis = in.readVLong(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are backwards compatibility concerns here. Consider a mixed-version cluster that contains nodes that do not know about took. You need to guard this read in a version check on the stream. For now, let's try for on or after 5.4.0. We can adjust this later if needed.
|
||
@After | ||
public void tearDown() throws Exception { | ||
super.tearDown(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The super teardown should be done after the specific teardown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. However I was closely following the TransportBulkActionTookTests. Maybe you should change it there too?
clusterService.close(); | ||
} | ||
|
||
//Unit conversion using a controller clock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a space between the //
and Unit
, add the word test
and lowercase Unit
?
runTestTook(true); | ||
} | ||
|
||
//Using {@link System#nanoTime()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove the use of Javadoc syntax here since this is not a Javadoc, add a space between //
and Using
, add the word test
, and lowercase Using
.
|
||
@Override | ||
public void onFailure(Exception e) { | ||
logger.warn(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be a fail.
/** | ||
* MultiSearch IT | ||
*/ | ||
public class MultiSearchIT extends ESSingleNodeTestCase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think that we need an integration test for this. I appreciate that you wrote it, but I think unit test suffices.
@olcbean thanks for opening this! It looks like it needs to have master merged in to fix some of the version constants, also, is it ready for another review by @jasontedor? |
@dakrone thanks for following up on this :) I am currently traveling, will rebase at the start of next week. |
removing MultiSearchIT adding a note to the migration docs
@jasontedor I just rebased on top of the current master and set the bwc version to 7.0 ( perhaps should be changed to 6.0 ? ). I also added a short note to the migration docs - feel free to leave it off if the change is not sufficiently notable. Could you please trigger the CI and let me know if any further changes are needed. CC-ing @dakrone as he also expressed interest in this PR. |
@elasticmachine test this please |
It has been about a month with no communication on this PR. Could you please let me know what the next steps are? @jasontedor @dakrone @rjernst |
* master: (356 commits) Do not set SO_LINGER on server channels (elastic#26997) Fix inconsistencies in the rest api specs for *_script (elastic#26971) fix inconsistencies in the rest api specs for cat.snapshots (elastic#26996) Add docs on full_id parameter in cat nodes API [TEST] Add test that replicates versioned updates with random flushes Use internal searcher for all indexing related operations in the engine Reformat paragraph in template docs to 80 columns Clarify settings and template on create index Fix reference to TcpTransport in documentation Allow Uid#decodeId to decode from a byte array slice (elastic#26987) Fix a typo in the similarity docs (elastic#26970) Use separate searchers for "search visibility" vs "move indexing buffer to disk (elastic#26972) Create weights lazily in filter and filters aggregation (elastic#26983) Use a dedicated ThreadGroup in rest sniffer (elastic#26897) Fire global checkpoint sync under system context Update by Query is modified to accept short `script` parameter. (elastic#26841) Cat shards bytes (elastic#26952) Add support for parsing inline script (elastic#23824) (elastic#26846) Change default value to true for transpositions parameter of fuzzy query (elastic#26901) Adding unreleased 5.6.4 version number to Version.java ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few comments.
|
||
public class TransportMultiSearchAction extends HandledTransportAction<MultiSearchRequest, MultiSearchResponse> { | ||
|
||
private final int availableProcessors; | ||
private final ClusterService clusterService; | ||
private final TransportAction<SearchRequest, SearchResponse> searchAction; | ||
private final LongSupplier relativeTimeProvider; | ||
private SetOnce<Long> startTimeInNanos; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think SetOnce<Long>
here is desirable, that's two extra allocations on every multi-search request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The immutability is a positive though, we can obtain this by pushing the start time all the way down via the execute method (i.e., add it as a parameter and chain it through all the way down to finish).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasontedor good point! Thanks.
@jasontedor thank you for picking up this PR. Can you have another look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few more comments.
@@ -123,7 +121,8 @@ void executeSearch( | |||
final Queue<SearchRequestSlot> requests, | |||
final AtomicArray<MultiSearchResponse.Item> responses, | |||
final AtomicInteger responseCounter, | |||
final ActionListener<MultiSearchResponse> listener) { | |||
final ActionListener<MultiSearchResponse> listener, | |||
long startTimeInNanos) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this parameter final, and name it relativeStartTime
(to make it clear that it's start time, but it's a relative and not absolute start time).
@@ -72,7 +70,7 @@ public TransportMultiSearchAction(Settings settings, ThreadPool threadPool, Tran | |||
|
|||
@Override | |||
protected void doExecute(MultiSearchRequest request, ActionListener<MultiSearchResponse> listener) { | |||
startTimeInNanos = new SetOnce<>(relativeTime()); | |||
long startTimeInNanos = relativeTime(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be final, and change it's name relativeStartTime
.
@@ -164,9 +165,9 @@ protected void doExecute(SearchRequest request, ActionListener<SearchResponse> l | |||
availableProcessors, expected::get) { | |||
@Override | |||
void executeSearch(final Queue<SearchRequestSlot> requests, final AtomicArray<MultiSearchResponse.Item> responses, | |||
final AtomicInteger responseCounter, final ActionListener<MultiSearchResponse> listener) { | |||
final AtomicInteger responseCounter, final ActionListener<MultiSearchResponse> listener, long startTimeInNanos) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same suggestion about the addition parameter.
} | ||
}); | ||
} | ||
|
||
private long relativeTime() { | ||
return relativeTimeProvider.getAsLong(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this method is needed.
@jasontedor can you have another look? |
test this please |
@jasontedor so how does it look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one more change I would like, then this can be pulled in.
@@ -0,0 +1,9 @@ | |||
[[breaking_70_java_changes]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We typically do not add changes here for feature adds, preferring to reserve it for changes users need to know to help them migrate; I see this as a feature add. Could you please remove this?
@jasontedor just pushed the latest changes. Take another look? |
test this please |
* master: (63 commits) [Docs] Fix note in bucket_selector [Docs] Fix indentation of examples (elastic#27168) [Docs] Clarify `span_not` query behavior for non-overlapping matches (elastic#27150) [Docs] Remove first person "I" from getting started (elastic#27155) [Docs] Correct link target for datatype murmur3 (elastic#27143) Fix division by zero in phrase suggester that causes assertion to fail Enable Docstats with totalSizeInBytes for 6.1.0 Adds average document size to DocsStats (elastic#27117) Upgrade Painless from ANTLR 4.5.1-1 to ANTLR 4.5.3. (elastic#27153) Exists template needs a template name (elastic#25988) [Tests] Fix occasional test failure due to two random values being the same Fix beidermorse phonetic token filter for unspecified `languageset` (elastic#27112) Fix max score tracking with field collapsing (elastic#27122) [Doc] Add Ingest CSV Processor Plugin to plugin as a community plugin (elastic#27105) Removed the beta tag from cross-cluster search fixed typo in ConstructingObjectParse (elastic#27129) Allow for the Painless Definition to have multiple instances (elastic#27096) Apply missing request options to the expand phase (elastic#27118) Only pull SegmentReader once in getSegmentInfo (elastic#27121) Fix BWC for discovery stats ...
test this please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Thanks @olcbean. |
_msearch
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
As per #23131 (comment) it is not clear if introducing took time for multi search is a desired behavior or if a further discussion is needed.
But as there are no comments against it so far I am submitting this PR.