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

Implement re_grpc_server #8622

Merged
merged 27 commits into from
Jan 9, 2025
Merged

Implement re_grpc_server #8622

merged 27 commits into from
Jan 9, 2025

Conversation

jprochazk
Copy link
Member

@jprochazk jprochazk commented Jan 8, 2025

Related

What

This PR introduces a new gRPC service which behaves similarly to our existing TCP and WS comms.

  • Any messages logged via the WriteMessages rpc will be stored in a buffer, and broadcast to all callers of ReadMessages.
  • Any calls to ReadMessages will also yield the full history.
  • If the buffer fills up beyond server_memory_limit, then messages are dropped from history in oldest first order (FIFO).

@jprochazk jprochazk marked this pull request as draft January 8, 2025 20:12
Copy link

github-actions bot commented Jan 8, 2025

Web viewer built successfully. If applicable, you should also test it:

  • I have tested the web viewer
Result Commit Link Manifest
6aaa103 https://rerun.io/viewer/pr/8622 +nightly +main

Note: This comment is updated whenever you push a commit.

@jprochazk jprochazk added the 🪵 Log & send APIs Affects the user-facing API for all languages label Jan 8, 2025
@jprochazk jprochazk marked this pull request as ready for review January 9, 2025 12:52
@emilk emilk self-requested a review January 9, 2025 13:55
Copy link
Member

@emilk emilk left a comment

Choose a reason for hiding this comment

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

Looks amazing!

It would be nice with a full integration test with re_grpc_client, but that can wait

@@ -0,0 +1,370 @@
// This file is @generated by prost-build.
Copy link
Member

Choose a reason for hiding this comment

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

Then it should be marked as linguist-generated=true in a .gitattributes file!

Copy link
Member Author

@jprochazk jprochazk Jan 9, 2025

Choose a reason for hiding this comment

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

It seems like it is? All files in src/v0 should have that attribute already. I think GitHub is just confused, and is showing the "large diff" warning instead of "generated file" warning.

$ git check-attr -a -- crates/store/re_protos/src/v0/rerun.common.v0.rs
crates/store/re_protos/src/v0/rerun.common.v0.rs: text: auto
crates/store/re_protos/src/v0/rerun.common.v0.rs: eol: lf
crates/store/re_protos/src/v0/rerun.common.v0.rs: linguist-generated: true

$ git check-attr -a -- crates/store/re_protos/src/v0/rerun.sdk_comms.v0.rs
crates/store/re_protos/src/v0/rerun.sdk_comms.v0.rs: text: auto
crates/store/re_protos/src/v0/rerun.sdk_comms.v0.rs: eol: lf
crates/store/re_protos/src/v0/rerun.sdk_comms.v0.rs: linguist-generated: true

crates/store/re_grpc_server/src/lib.rs Outdated Show resolved Hide resolved
crates/store/re_grpc_server/src/lib.rs Outdated Show resolved Hide resolved
crates/store/re_grpc_server/src/lib.rs Outdated Show resolved Hide resolved
crates/store/re_grpc_server/src/lib.rs Outdated Show resolved Hide resolved
crates/store/re_grpc_server/src/lib.rs Show resolved Hide resolved
let store_id = StoreId::random(StoreKind::Blueprint);

let mut messages = Vec::new();
messages.push(LogMsg::SetStoreInfo(SetStoreInfo {
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it make sense to have this after the ArrowMsg:s to test that it still arrives first for late-connecting client? 🤔 (saying this without having read any further than this)

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is already being tested, but implicitly. SetStoreInfo goes into persistent_message_queue, which is then merged back into ordered_message_queue by prepending it in the resulting stream. So if it wasn't always being sent first, it wouldn't have the same order as it does in fake_log_stream. I'll add a comment about that.

crates/store/re_log_types/src/lib.rs Show resolved Hide resolved
Message(LogMsgProto),
}

struct QueueState {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder about the naming of Queue and QueueState below. We have spawn on one and run_in_place on the other, so I wonder if there's some better names for them as they are quite generic.
Queue seems to be responsible for 1/ passing messages to the underlying queue state and 2/ creating client streams.

This all is not terribly important as the code and especially logic in QueueState is quite clear, but I just wonder if there's actually value in having Queue at all and if that logic should be on the MessageProxy. And then perhaps renaming QueueState to MemoryBoundEventLoop (just the first thing that came to mind) would also help.

(just a thought, feel free to ignore if you don't think it makes sense)

Copy link
Member Author

Choose a reason for hiding this comment

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

I think you're right, I inlined Queue into MessageProxy and renamed QueueState.

Copy link
Contributor

@zehiko zehiko left a comment

Choose a reason for hiding this comment

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

+1, nice work, really like the good unit test coverage

@jprochazk jprochazk merged commit 0dda8a1 into main Jan 9, 2025
10 of 16 checks passed
@jprochazk jprochazk deleted the jan/grpc-server branch January 9, 2025 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
include in changelog 🪵 Log & send APIs Affects the user-facing API for all languages remote-store remote store gRPC API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement re_grpc_server
3 participants