-
Notifications
You must be signed in to change notification settings - Fork 25.7k
ESQL: Add times to topn status #131555
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
ESQL: Add times to topn status #131555
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -308,6 +308,9 @@ public String describe() { | |
|
|
||
| private Iterator<Page> output; | ||
|
|
||
| private long receiveNanos; | ||
| private long emitNanos; | ||
|
|
||
| /** | ||
| * Count of pages that have been received by this operator. | ||
| */ | ||
|
|
@@ -387,6 +390,7 @@ public boolean needsInput() { | |
|
|
||
| @Override | ||
| public void addInput(Page page) { | ||
| long start = System.nanoTime(); | ||
| /* | ||
| * Since row tracks memory we have to be careful to close any unused rows, | ||
| * including any rows that fail while constructing because they allocate | ||
|
|
@@ -423,6 +427,7 @@ public void addInput(Page page) { | |
| pagesReceived++; | ||
| rowsReceived += page.getPositionCount(); | ||
| } | ||
| receiveNanos += System.nanoTime() - start; | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -548,9 +553,11 @@ public Page getOutput() { | |
| if (output == null || output.hasNext() == false) { | ||
| return null; | ||
| } | ||
| long start = System.nanoTime(); | ||
|
||
| Page ret = output.next(); | ||
| pagesEmitted++; | ||
| rowsEmitted += ret.getPositionCount(); | ||
| emitNanos += System.nanoTime() - start; | ||
| return ret; | ||
| } | ||
|
|
||
|
|
@@ -588,7 +595,16 @@ public long ramBytesUsed() { | |
|
|
||
| @Override | ||
| public Status status() { | ||
| return new TopNOperatorStatus(inputQueue.size(), ramBytesUsed(), pagesReceived, pagesEmitted, rowsReceived, rowsEmitted); | ||
| return new TopNOperatorStatus( | ||
| receiveNanos, | ||
| emitNanos, | ||
| inputQueue.size(), | ||
| ramBytesUsed(), | ||
| pagesReceived, | ||
| pagesEmitted, | ||
| rowsReceived, | ||
| rowsEmitted | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -25,6 +25,8 @@ public class TopNOperatorStatus implements Operator.Status { | |||||||||
| "topn", | ||||||||||
| TopNOperatorStatus::new | ||||||||||
| ); | ||||||||||
| private final long receiveNanos; | ||||||||||
| private final long emitNanos; | ||||||||||
| private final int occupiedRows; | ||||||||||
| private final long ramBytesUsed; | ||||||||||
| private final int pagesReceived; | ||||||||||
|
|
@@ -33,13 +35,17 @@ public class TopNOperatorStatus implements Operator.Status { | |||||||||
| private final long rowsEmitted; | ||||||||||
|
|
||||||||||
| public TopNOperatorStatus( | ||||||||||
| long receiveNanos, | ||||||||||
| long emitNanos, | ||||||||||
| int occupiedRows, | ||||||||||
| long ramBytesUsed, | ||||||||||
| int pagesReceived, | ||||||||||
| int pagesEmitted, | ||||||||||
| long rowsReceived, | ||||||||||
| long rowsEmitted | ||||||||||
| ) { | ||||||||||
| this.receiveNanos = receiveNanos; | ||||||||||
| this.emitNanos = emitNanos; | ||||||||||
| this.occupiedRows = occupiedRows; | ||||||||||
| this.ramBytesUsed = ramBytesUsed; | ||||||||||
| this.pagesReceived = pagesReceived; | ||||||||||
|
|
@@ -49,6 +55,13 @@ public TopNOperatorStatus( | |||||||||
| } | ||||||||||
|
|
||||||||||
| TopNOperatorStatus(StreamInput in) throws IOException { | ||||||||||
| if (in.getTransportVersion().onOrAfter(TransportVersions.ESQL_TOPN_TIMINGS)) { | ||||||||||
| this.receiveNanos = in.readVLong(); | ||||||||||
| this.emitNanos = in.readVLong(); | ||||||||||
| } else { | ||||||||||
| this.receiveNanos = 0; | ||||||||||
| this.emitNanos = 0; | ||||||||||
| } | ||||||||||
| this.occupiedRows = in.readVInt(); | ||||||||||
| this.ramBytesUsed = in.readVLong(); | ||||||||||
|
|
||||||||||
|
|
@@ -67,6 +80,11 @@ public TopNOperatorStatus( | |||||||||
|
|
||||||||||
| @Override | ||||||||||
| public void writeTo(StreamOutput out) throws IOException { | ||||||||||
| if (out.getTransportVersion().onOrAfter(TransportVersions.ESQL_TOPN_TIMINGS)) { | ||||||||||
| out.writeVLong(receiveNanos); | ||||||||||
| out.writeVLong(emitNanos); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| out.writeVInt(occupiedRows); | ||||||||||
| out.writeVLong(ramBytesUsed); | ||||||||||
|
|
||||||||||
|
|
@@ -83,6 +101,14 @@ public String getWriteableName() { | |||||||||
| return ENTRY.name; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| public long receiveNanos() { | ||||||||||
| return receiveNanos; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| public long emitNanos() { | ||||||||||
| return emitNanos; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| public int occupiedRows() { | ||||||||||
| return occupiedRows; | ||||||||||
| } | ||||||||||
|
|
@@ -110,6 +136,8 @@ public long rowsEmitted() { | |||||||||
| @Override | ||||||||||
| public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||||||||||
| builder.startObject(); | ||||||||||
| builder.field("receive_nanos", receiveNanos); | ||||||||||
| builder.field("emit_nanos", emitNanos); | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Other statuses also add the "X_time" with the readable time. For example: Lines 436 to 439 in 59df1bf
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah. Makes sense. Something I'd have asked for I think. |
||||||||||
| builder.field("occupied_rows", occupiedRows); | ||||||||||
| builder.field("ram_bytes_used", ramBytesUsed); | ||||||||||
| builder.field("ram_used", ByteSizeValue.ofBytes(ramBytesUsed)); | ||||||||||
|
|
@@ -126,7 +154,9 @@ public boolean equals(Object o) { | |||||||||
| return false; | ||||||||||
| } | ||||||||||
| TopNOperatorStatus that = (TopNOperatorStatus) o; | ||||||||||
| return occupiedRows == that.occupiedRows | ||||||||||
| return receiveNanos == that.receiveNanos | ||||||||||
| && emitNanos == that.emitNanos | ||||||||||
| && occupiedRows == that.occupiedRows | ||||||||||
| && ramBytesUsed == that.ramBytesUsed | ||||||||||
| && pagesReceived == that.pagesReceived | ||||||||||
| && pagesEmitted == that.pagesEmitted | ||||||||||
|
|
@@ -136,7 +166,7 @@ public boolean equals(Object o) { | |||||||||
|
|
||||||||||
| @Override | ||||||||||
| public int hashCode() { | ||||||||||
| return Objects.hash(occupiedRows, ramBytesUsed, pagesReceived, pagesEmitted, rowsReceived, rowsEmitted); | ||||||||||
| return Objects.hash(receiveNanos, emitNanos, occupiedRows, ramBytesUsed, pagesReceived, pagesEmitted, rowsReceived, rowsEmitted); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| @Override | ||||||||||
|
|
||||||||||
This file was deleted.
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 be in the finally, in case of exception (?)
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.
May as well, yeah. I think the exception here is generally terminal to the process and we don't return the status, but may as well put it there so it's possible.