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

RSDK-8081 Fix max message size limit #264

Merged
merged 8 commits into from
Jul 9, 2024

Conversation

lia-viam
Copy link
Contributor

@lia-viam lia-viam commented Jul 9, 2024

Fixes an issue where the gRPC 4mb message size limit was being hit despite #254

Per this issue discussion we now change the channel args as well: tensorflow/serving#1382 (comment)

This needs to be set every time we create a channel, so I introduced a helper which sets the parameters and passes the args. I believe this is the best we can do since grpc Channel is final and only constructible by a Create function and you can't set args on an already-created channel

cc @stuqdog @acmorrow

@lia-viam lia-viam requested a review from a team as a code owner July 9, 2024 14:11
@lia-viam lia-viam requested review from njooma and stuqdog and removed request for a team July 9, 2024 14:11
@lia-viam lia-viam changed the title Fix max message size limit RSDK-8081 Fix max message size limit Jul 9, 2024

namespace viam {
namespace sdk {

grpc::ChannelArguments default_channel_args();
Copy link
Member

Choose a reason for hiding this comment

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

This probably doesn't need to be in a public header - I'd expect all the callers to be in .cpp scope.

@@ -354,7 +354,7 @@ std::shared_ptr<RobotClient> RobotClient::at_local_socket(const std::string& add
const std::string addr = "unix://" + address;
const char* uri = addr.c_str();
const std::shared_ptr<grpc::Channel> channel =
grpc::CreateChannel(uri, grpc::InsecureChannelCredentials());
grpc::CreateCustomChannel(uri, grpc::InsecureChannelCredentials(), default_channel_args());
Copy link
Member

Choose a reason for hiding this comment

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

You could also introduce a (SDK private) CreateViamGrpcChannel that did this for you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like this idea. Do we have any SDK private modules outside of components/private ? Maybe this could be in rpc/private? Or whatever else you had in mind

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think rpc/private is the right place.

@@ -26,6 +26,14 @@ extern "C" char* dial(const char* uri,
namespace viam {
namespace sdk {

grpc::ChannelArguments default_channel_args() {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea about the named constant, should definitely be a constexpr somewhere. To your other point, yes these are the only max parameters in ChannelArguments: https://grpc.github.io/grpc/cpp/classgrpc_1_1_channel_arguments.html

auto test_server = TestServer(server);
auto grpc_channel = test_server.grpc_in_process_channel(args);
auto grpc_channel = test_server.grpc_in_process_channel(sdk::default_channel_args());
Copy link
Member

Choose a reason for hiding this comment

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

  • I think there is another call to this in test_robot.cpp.
  • Guessing now that this is why this function is exposed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching test_robot.cpp. Building off your other point, maybe we could do something like

  • SDK constant for default max message size
  • SDK private CreateViamChannel
  • Test utils CreateTestServerChannel which would be used here and in test_robot.cpp
    ?

Copy link
Member

Choose a reason for hiding this comment

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

That sounds like a good plan, yes.

Copy link
Member

@stuqdog stuqdog left a comment

Choose a reason for hiding this comment

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

lgtm, % conversation around Drew's comments.

@lia-viam
Copy link
Contributor Author

lia-viam commented Jul 9, 2024

Addressed Andrew's suggestions. Some minor stuff to flag for discussion

  • I chose impl as the nested namespace in rpc/private following the convention of components/private and services/private
  • I decided to remove the ChannelArguments argument of grpc_in_process_channel() since it was always being called with a default constructed instance anyway.

Copy link
Member

@acmorrow acmorrow left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -354,7 +354,7 @@ std::shared_ptr<RobotClient> RobotClient::at_local_socket(const std::string& add
const std::string addr = "unix://" + address;
const char* uri = addr.c_str();
const std::shared_ptr<grpc::Channel> channel =
grpc::CreateChannel(uri, grpc::InsecureChannelCredentials());
viam::sdk::impl::create_viam_channel(uri, grpc::InsecureChannelCredentials());
Copy link
Member

Choose a reason for hiding this comment

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

You probably don't need the full qualification here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you're right, I think I can get away with sdk::impl but impl alone was erroring out because RobotClient uses the pimpl idiom with struct impl

@lia-viam lia-viam merged commit 45477ae into viamrobotics:main Jul 9, 2024
3 checks passed
@lia-viam lia-viam deleted the fix/max-message-size branch September 20, 2024 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants