fs2-grpc icon indicating copy to clipboard operation
fs2-grpc copied to clipboard

Use UnsafeBoundedQueue and avoid dispatcher

Open fredfp opened this issue 5 months ago • 3 comments

Leverage https://github.com/typelevel/cats-effect/pull/3975 (released with CE 3.6.0) to remove some dispatcher calls.

It seems to work, but I was hoping to measure the actual impact with benchmarks before submitting a PR.

fredfp avatar Oct 03 '25 10:10 fredfp

@seigert I'd love to run the benchmarks you mentioned here, could you do it or share the setup? I think instructions to bench the client side of fs2-grpc are sorely missing.

fredfp avatar Oct 03 '25 10:10 fredfp

@fredfp, I cannot push my test client/server right now as it uses our internal libraries for configuration, starup and stuff. But I'll try to cut them out in a few days and upload it to github.

Basically, it is just simple metrics for request/response times over server and client implementation of this gRPC API:

syntax = "proto3";

package fs2.grpc.bench;

service TestService {
  rpc Identity (Message) returns (Message);
  rpc IdentityStream (stream Message) returns (stream Message);

  rpc Unary (UnaryRequest) returns (Message);

  rpc ClientStreaming (stream UnaryRequest) returns (Message);
  rpc ServerStreaming (StreamingRequest) returns (stream Message);
  rpc BothStreaming (stream StreamingRequest) returns (stream Message);
}

message Message {
  bytes payload = 1;
}

message RequestParams {
  int32 length = 1;
  bool  random_length = 2;
  optional double random_factor_min = 3;
  optional double random_factor_max = 4;
}

message UnaryRequest {
  RequestParams params = 1;
}

message StreamingRequest {
  RequestParams stream_params = 1;
  RequestParams chunk_params = 2;
  RequestParams message_params = 3;
}

Server implementation receives request and either

  1. sends its back in case of Message;
  2. generates simngle message defined by UnaryRequest.RequestParams (length is payload length, random bytes);
  3. generates number of messages defined by StreamingRequest (RequestParams define number of total messages in a stream, messages in a single chunk, length of single payload).

seigert avatar Oct 06 '25 10:10 seigert

@fredfp, I've published our benchmark setup here: https://github.com/seigert/fs2-grpc-bench

seigert avatar Oct 13 '25 10:10 seigert