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

Introducing "took" time (in ms) for _msearch #23767

Merged
merged 10 commits into from
Nov 2, 2017

Conversation

olcbean
Copy link
Contributor

@olcbean olcbean commented Mar 27, 2017

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.

@elasticmachine
Copy link
Collaborator

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?

@olcbean
Copy link
Contributor Author

olcbean commented Mar 27, 2017

Hm...
I signed the CLA, but still the check is failing...

Copy link
Member

@jasontedor jasontedor left a 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) {
Copy link
Member

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);
Copy link
Member

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 {
Copy link
Member

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.

Copy link
Contributor Author

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.

@olcbean
Copy link
Contributor Author

olcbean commented Mar 28, 2017

@jasontedor I hope I addressed all of your remarks.
Thank you for your review :)

Copy link
Member

@jasontedor jasontedor left a 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) {
Copy link
Member

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;
Copy link
Member

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;

Copy link
Member

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() {
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

@olcbean olcbean Apr 4, 2017

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?

Copy link
Member

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();
Copy link
Member

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();
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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()}
Copy link
Member

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);
Copy link
Member

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 {
Copy link
Member

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.

@dakrone
Copy link
Member

dakrone commented Aug 15, 2017

@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?

@olcbean
Copy link
Contributor Author

olcbean commented Aug 16, 2017

@dakrone thanks for following up on this :)

I am currently traveling, will rebase at the start of next week.

@olcbean
Copy link
Contributor Author

olcbean commented Aug 23, 2017

@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.

@dakrone
Copy link
Member

dakrone commented Aug 23, 2017

@elasticmachine test this please

@olcbean
Copy link
Contributor Author

olcbean commented Sep 23, 2017

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
  ...
Copy link
Member

@jasontedor jasontedor left a 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;
Copy link
Member

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.

Copy link
Member

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasontedor good point! Thanks.

@olcbean
Copy link
Contributor Author

olcbean commented Oct 16, 2017

@jasontedor thank you for picking up this PR. Can you have another look?

Copy link
Member

@jasontedor jasontedor left a 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) {
Copy link
Member

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();
Copy link
Member

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) {
Copy link
Member

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();
Copy link
Member

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.

@olcbean
Copy link
Contributor Author

olcbean commented Oct 16, 2017

@jasontedor can you have another look?

@jasontedor
Copy link
Member

test this please

@olcbean
Copy link
Contributor Author

olcbean commented Oct 25, 2017

@jasontedor so how does it look?

Copy link
Member

@jasontedor jasontedor left a 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]]
Copy link
Member

@jasontedor jasontedor Oct 30, 2017

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?

@olcbean
Copy link
Contributor Author

olcbean commented Oct 30, 2017

@jasontedor just pushed the latest changes. Take another look?

@jasontedor
Copy link
Member

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
  ...
@jasontedor
Copy link
Member

test this please

Copy link
Member

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@jasontedor jasontedor added :Search/Search Search-related issues that do not fall into other categories v7.0.0 >enhancement labels Nov 2, 2017
@jasontedor jasontedor merged commit b989646 into elastic:master Nov 2, 2017
@jasontedor
Copy link
Member

Thanks @olcbean.

@olcbean olcbean deleted the msearch_took branch November 2, 2017 08:53
@clintongormley clintongormley changed the title Introducing "took" time (in ms) for _msearch #23131 Introducing "took" time (in ms) for _msearch Nov 6, 2017
@elasticmachine
Copy link
Collaborator

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?

@jimczi jimczi added v7.0.0-beta1 and removed v7.0.0 labels Feb 7, 2019
codebrain added a commit to elastic/elasticsearch-net that referenced this pull request Jun 20, 2019
Mpdreamz pushed a commit to elastic/elasticsearch-net that referenced this pull request Jun 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search/Search Search-related issues that do not fall into other categories v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants