-
Notifications
You must be signed in to change notification settings - Fork 206
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
feat: Support remote engine server with flatbuffer write #1539
Conversation
code: header.code, | ||
msg: header.error.clone(), | ||
code: header.code(), | ||
msg: header.error().unwrap().to_string(), |
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 unwrap is safe here?
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.
Change to unwrap_or() and also update server side to response None if error message if empty.
.await?; | ||
match result { | ||
TonicWriteResponseExt::Flatbuffer(v) => Ok(v), | ||
TonicWriteResponseExt::Proto(_) => Err(Status::new(Code::Internal, "logic error")), |
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.
TonicWriteResponseExt::Proto(_) => Err(Status::new(Code::Internal, "logic error")), | |
TonicWriteResponseExt::Proto(_) => Err(Status::new(Code::Internal, "only support flatbuffer payload")), |
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.
Okay.
src/components/fb_util/src/common.rs
Outdated
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.
common.rs
is not suitable here, the file is only designed for remote_service, so remote_service.rs
maybe better name.
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.
Okay.
src/server/src/grpc/mod.rs
Outdated
@@ -165,6 +166,7 @@ pub struct RpcServices { | |||
rpc_server: InterceptedService<StorageServiceServer<StorageServiceImpl>, AuthWithFile>, | |||
meta_rpc_server: Option<MetaEventServiceServer<MetaServiceImpl>>, | |||
remote_engine_server: RemoteEngineServiceServer<RemoteEngineServiceImpl>, | |||
remote_engine_server_ext: RemoteEngineFbServiceServer<RemoteEngineServiceImpl>, |
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.
remote_engine_fb_server
?
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.
Okay.
})?; | ||
let mut rpc_client = RemoteEngineServiceClient::<Channel>::new(route_context.channel); | ||
|
||
let mut rpc_client = RemoteEngineFbServiceClient::<Channel>::new(route_context.channel); |
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.
Does this mean remote server will only have request with fb payload?
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.
Adding a REQUEST_TYPE environment variable to support both protobuf and flatbuffer protocol.
fe5b4e8
to
eea24f8
Compare
} | ||
TonicWriteBatchRequestExt::Flatbuffer(v) => { | ||
let request = Arc::new(v.into_inner()); | ||
let req = request.deserialize::<FBWriteBatchRequest>().unwrap(); |
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 several unwrap in this block, are they all safe?
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.
- FlatBufferBytes::deserialize is changed to unsafe function call as internal request routing is supposed to be safe among servers.
- Other unwraps are all based on batch() which cannot be None in internal procedure.
- Always follow the backwards compatibility solution for the schema design (https://flatbuffers.dev/flatbuffers_guide_tutorial.html)
|
||
fn build_fb_write_response(resp: WriteResponse) -> FlatBufferBytes { | ||
let mut builder = flatbuffers::FlatBufferBuilder::with_capacity(1024); | ||
let header = resp.header.unwrap(); |
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.
Remove this unwrap?
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.
Change it to unwrap_or_default?
src/table_engine/src/remote/model.rs
Outdated
@@ -109,6 +130,16 @@ pub struct TableIdentifier { | |||
pub table: String, | |||
} | |||
|
|||
impl From<FBTableIdentifier<'_>> for TableIdentifier { |
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.
Impl TryFrom to remove those unwrap?
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.
Done.
As said in description, the improvement after introduce Flatbuffer is not what we originally expected, the reason is that this PR only refactor upper layer of the put request, the But ContiguousRow is a heavily used structure in write path, refactor it would introduce much more changes, so I suggest we stop working on this, sorry for not find this earlier. Really appreciated your work on this. |
Rationale
Our benchmarks show flatbuffers has the best perf, thus we replace the remote server write operation from protobuf to flatbuffers protocol.
#1515
Detailed Changes
Test Plan
Manual test as follows:
Write request serialization benchmark test:
pb encode: 131.916µs, pb decode: 63µs, fb encode: 174.459µs, fb decode: 83ns
pb encode: 131.583µs, pb decode: 71.292µs, fb encode: 376.5µs, fb decode: 42ns