Skip to content

Conversation

@Tsukikage7
Copy link
Contributor

What this PR does

This PR unifies the IDL definitions and modernizes the API in tools/benchmark module.

Closes #835

Background

The benchmark module previously had three separate IDL definitions:

  • api/samples_api.proto - for Triple protocol with Greeter service
  • protocol/grpc/proto/hello_grpc.proto - for gRPC protocol with UserProvider service
  • Go structs with Hessian serialization - for Dubbo protocol

This inconsistency made it difficult to compare performance across protocols fairly.

Changes

Unified IDL Definition

Created a single benchmark.proto defining BenchmarkService with consistent message types:

service BenchmarkService {
  rpc GetUser(GetUserRequest) returns (GetUsersResponse);
  rpc GetUsers(GetUsersRequest) returns (GetUsersResponse);
  rpc GetUserByName(GetUserByNameRequest) returns (GetUsersResponse);
  rpc SayHello(HelloRequest) returns (HelloResponse);
}

Protocol-Specific Stubs

  • Triple: Stubs generated in api/ using protoc-gen-go-triple/v3 (new programmatic API)
  • gRPC: Stubs generated in api/grpcstub/ using standard protoc-gen-go-grpc
  • Dubbo: Continues to use Hessian serialization with updated provider implementation

Server Implementations Updated

Protocol Changes
gRPC Uses grpcstub.BenchmarkServiceServer with standard google.golang.org/grpc
Triple Uses new dubbo-go v3 programmatic API (server.NewServer() + RegisterBenchmarkServiceHandler())
Dubbo Cleaned up UserProvider with simplified structure

Triple Protocol Modernization

Migrated from config-based API to new dubbo-go v3 programmatic API:

Server (before):

config.SetProviderService(&pkg.BenchmarkProvider{})
config.Load()

Server (after):

srv, _ := server.NewServer(
    server.WithServerProtocol(
        protocol.WithPort(20000),
        protocol.WithTriple(),
    ),
)
api.RegisterBenchmarkServiceHandler(srv, pkg.NewBenchmarkProvider())
srv.Serve()

Client (before):

config.SetConsumerService(grpcBenchmarkService)
config.Load()

Client (after):

cli, _ := client.NewClient(client.WithClientURL("tri://127.0.0.1:20000"))
benchmarkService, _ := api.NewBenchmarkService(cli)

Dependencies

  • Upgraded google.golang.org/grpc to v1.78.0
  • Updated dubbo.apache.org/dubbo-go/v3 to v3.3.1

Removed Files

  • api/samples_api.proto and generated files
  • protocol/grpc/proto/hello_grpc.proto and generated files

Benchmark Results

Test environment: macOS, Apple Silicon, N=500 samples per method

gRPC Protocol (Direct)

Method Min Median Mean StdDev Max
GetUser 100µs 200µs 400µs 1.1ms 8.2ms
GetUsers 100µs 200µs 200µs 100µs 400µs
GetUserByName 100µs 200µs 200µs 100µs 600µs
SayHello 100µs 200µs 200µs 100µs 400µs

gRPC via Pixiu

Method Min Median Mean StdDev Max
GetUser 600µs 1.4ms 1.8ms 1.8ms 12.7ms
GetUsers 500µs 1.4ms 1.7ms 1.2ms 14.6ms
GetUserByName 500µs 1.3ms 2ms 2ms 17.1ms
SayHello 600µs 1.3ms 1.8ms 2ms 32.8ms

Triple Protocol (Direct)

Method Min Median Mean StdDev Max
GetUser 200µs 1.8ms 2.5ms 2.4ms 14.5ms
SayHello 200µs 900µs 1.4ms 1.3ms 12.5ms

Triple via Pixiu

Method Min Median Mean StdDev Max
GetUser 1ms 2.1ms 2.8ms 3.1ms 24.4ms
SayHello 700µs 2ms 2.5ms 1.4ms 12ms

Dubbo via Pixiu

Method Min Median Mean StdDev Max
GetUser 700µs 2ms 3ms 5.9ms 44.7ms
GetGender 300µs 800µs 1ms 500µs 3.1ms
GetUser0 300µs 700µs 800µs 500µs 4.2ms
GetUsers 100µs 500µs 600µs 400µs 3.2ms

Summary

Pixiu proxy adds approximately 0.3-1.1ms overhead compared to direct protocol calls. Performance comparison (median latency):

Protocol Direct via Pixiu Overhead
gRPC ~200µs ~1.3ms ~1.1ms
Triple ~1.4ms ~2ms ~0.6ms
Dubbo - ~700µs -

How to verify

cd tools/benchmark

# Build all packages
go build ./...

# Run import formatter
cd ../.. && make import-format

# Run tests (requires local environment setup)
go test ./test/...

Checklist

  • Code compiles correctly
  • Passes make import-format
  • Updated generate.sh for code generation
  • All three protocol servers use unified service definition
  • Test files updated to use new API

Copy link
Contributor

@Alanxtl Alanxtl left a comment

Choose a reason for hiding this comment

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

cool work!

  1. I notice in tools/benchmark/protocol/triple/ the server side have delete dubbogo.yml and use new api instead, why client side still remains a dubbogo.yml?
  2. update the performance part in the readme of tools/benchmark
  3. what about update go version to 1.25 in go.mod?
  4. why dubbo and grpc have 4 interfaces and triple only have 2?
  5. what about add a dubbo-driect so that we can compare it convientily

@Alanxtl Alanxtl added enhancement New feature or request 1.2.0 labels Jan 9, 2026
@Alanxtl
Copy link
Contributor

Alanxtl commented Jan 9, 2026

pls don't forget import-format before commit

@Tsukikage7 Tsukikage7 force-pushed the feature/benchmark-modernization-835 branch 3 times, most recently from 7a5b9df to dde725f Compare January 9, 2026 08:53
@codecov-commenter
Copy link

codecov-commenter commented Jan 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 19.71%. Comparing base (4d9a422) to head (dde725f).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #856      +/-   ##
===========================================
+ Coverage    19.69%   19.71%   +0.01%     
===========================================
  Files          255      255              
  Lines        18360    18360              
===========================================
+ Hits          3616     3619       +3     
+ Misses       14377    14375       -2     
+ Partials       367      366       -1     
Flag Coverage Δ
unittests 19.71% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@Alanxtl Alanxtl left a comment

Choose a reason for hiding this comment

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

excellent work, lgtm

@Alanxtl
Copy link
Contributor

Alanxtl commented Jan 10, 2026

@Similarityoung @nanjiek check this

Copy link
Contributor

@Alanxtl Alanxtl left a comment

Choose a reason for hiding this comment

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

  1. what's the difference between the proto file in tools/benchmark/api/grpcstub/benchmark.proto and the proto file in tools/benchmark/api/benchmark.proto can't we use the same proto file?
  2. why dubbo direct has 6 interfaces? why not delete GetUser2 and GetErr?

@Similarityoung
Copy link
Contributor

Wouldn't it be better if the contents of tools/benchmark/protocol/triple/pb could be put into tools/benchmark/protocol/triple, after all, the proto file is in a separate folder

@Tsukikage7 Tsukikage7 force-pushed the feature/benchmark-modernization-835 branch from dde725f to 9480d0a Compare January 23, 2026 10:39
@Tsukikage7
Copy link
Contributor Author

Wouldn't it be better if the contents of tools/benchmark/protocol/triple/pb could be put into tools/benchmark/protocol/triple, after all, the proto file is in a separate folder

Good suggestion! I've moved go-server and pixiu from protocol/triple/pb/ to protocol/triple/
to keep the directory structure consistent with other protocols (grpc, dubbo, dubbo-direct).
Thanks for the review!

- Consolidate scattered proto definitions into unified api/ directory
- Create shared benchmark.proto with User service definitions
- Add separate grpcstub/ for gRPC-specific generated code
- Migrate triple server/client to dubbo-go v3 programmatic API
- Remove legacy dubbogo.yml configuration files
- Update README with markdown tables and performance comparison
- Upgrade Go version to 1.25.0
- Add GetUsers and GetUserByName tests for triple protocol
- Fix import formatting across test files
@Tsukikage7 Tsukikage7 force-pushed the feature/benchmark-modernization-835 branch from 9480d0a to 16bd3c4 Compare January 23, 2026 10:49
@sonarqubecloud
Copy link

@Tsukikage7
Copy link
Contributor Author

  1. what's the difference between the proto file in tools/benchmark/api/grpcstub/benchmark.proto and the proto file in tools/benchmark/api/benchmark.proto can't we use the same proto file?
  2. why dubbo direct has 6 interfaces? why not delete GetUser2 and GetErr?

Thanks for the suggestions!

  1. Proto file: Removed the duplicate grpcstub/benchmark.proto. Now both gRPC and Triple stubs
    are generated from a single api/benchmark.proto using protoc's --go_opt=M... flag.
  2. Dubbo interfaces: Removed GetUser2, GetUser3, GetErr and other redundant methods. Now
    dubbo keeps only 4 core interfaces (GetUser, GetUser0, GetUsers, GetGender), aligned with the
    benchmark purpose.

@AlexStocks
Copy link
Contributor

please fix the ci failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.2.0 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Update tools/benchmark to a more modern way

5 participants