Skip to content

Conversation

@jnumainville
Copy link
Contributor

Server side PR for DH-19382
Adds server side timing to JsCommandResult for query execution time
Tested in deephaven/web-client-ui#2526

@jnumainville jnumainville requested a review from mofojed September 2, 2025 20:43
message ExecuteCommandResponse {
string error_message = 1;
io.deephaven.proto.backplane.grpc.FieldsChangeUpdate changes = 2;
string start_timestamp = 3;
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer to use actual nanos since the epoch than something that needs parsing/interpretation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Note, I realize that JS sucks at numbers; but the proto is a generic thing. Anytime we add a field, we should also add a comment for the protodocs.

Copy link
Member

Choose a reason for hiding this comment

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

We already have wiring to handle int64 in a format we can get it to js - the following change will make it still be a string in the browser, but we can expose as a DateWrapper so that JS can truncate to number, format to string, or ask for it as a js Date:

Suggested change
string start_timestamp = 3;
int64 start_timestamp = 3 [jstype=JS_STRING];

In theory proto also has a well known date types, but i'd vote just stick to nanos like we do for logs etc
https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/timestamp.proto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Modified types to the jstype and added a comment

Comment on lines 232 to 236
diff.setChanges(fieldChanges);
diff.setStartTimestamp(startTimestamp);
diff.setEndTimestamp(endTimestamp);

return diff.build();
Copy link
Member

Choose a reason for hiding this comment

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

nothing at all wrong with this style, but can also be a builder style as before:

Suggested change
diff.setChanges(fieldChanges);
diff.setStartTimestamp(startTimestamp);
diff.setEndTimestamp(endTimestamp);
return diff.build();
return diff.setChanges(fieldChanges)
.setStartTimestamp(startTimestamp)
.setEndTimestamp(endTimestamp)
.build();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Modified back to builder style

* @return long
*/
@JsProperty
public LongWrapper getStartTimestamp() {
Copy link
Member

Choose a reason for hiding this comment

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

Probably DateWrapper instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to DateWrapper

@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2025

No docs changes detected for 63c9150

@jnumainville jnumainville added the NoReleaseNotesNeeded No release notes are needed. label Oct 6, 2025
Comment on lines 125 to 127
// Time it took to run the command, in nanoseconds
int64 start_timestamp = 3 [jstype=JS_STRING];
int64 end_timestamp = 4 [jstype=JS_STRING];
Copy link
Member

Choose a reason for hiding this comment

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

This comment is incorrect; if you were providing a single duration field, the comment would make sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Improved comment

throw new UnsupportedOperationException(
"Unrecognized systemic option: " + systemicOption);
}
long endTimestamp = Clock.system().currentTimeNanos();
Copy link
Member

Choose a reason for hiding this comment

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

Note: if you actually only care about the duration (and not the timestamps), the difference between java.lang.System.nanoTime() would be more appropriate than the difference between Clock.system().currentTimeNanos().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Although we are ultimately interested in the duration on the UI, I think the timestamps are sufficient for us #7145 (comment)

io.deephaven.proto.backplane.grpc.FieldsChangeUpdate changes = 2;

// Time it took to run the command, in nanoseconds
int64 start_timestamp = 3 [jstype=JS_STRING];
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little sad when I see this; maybe Colin has more context, but we are still not able to use google.protobuf.Timestamp and/or google.protobuf.Duration?

Copy link
Member

Choose a reason for hiding this comment

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

Colin suggested this in a previous comment: #7145 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As per Colin's comment sticking with this jstype syntax, further discussion of protobuf types seems like a broader discussion beyond the scope of this ticket

Copy link
Member

Choose a reason for hiding this comment

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

the jstype option and using one of the built in types are sort of unrelated - but yes, we can't (yet) use other semi "built-in" types.

string error_message = 1;
io.deephaven.proto.backplane.grpc.FieldsChangeUpdate changes = 2;

// Start and end timestamps for command execution, in nanoseconds since the unix epoch.
Copy link
Member

Choose a reason for hiding this comment

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

This comment is documentation for the start_timestamp field, not a general code comment. As such, probably makes sense to document each field as appropriate (I don't actually know if there is a way to add a "general" comment that doesn't effect resulting protobuf documentation).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did not realize that, thanks, made it two comments

@jnumainville jnumainville enabled auto-merge (squash) October 9, 2025 21:12
@jnumainville jnumainville merged commit 45fe6f3 into deephaven:main Oct 17, 2025
24 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Oct 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants