Skip to content

Conversation

@pcriadoperez
Copy link
Collaborator

@pcriadoperez pcriadoperez commented Nov 10, 2025

  • This PR adds to each service a DoSBE() that does the request using SBE
  • Uses the schema provided togehter with a generator from git clone https://github.com/aeron-io/simple-binary-encoding.git to generate the types and decode from binary

Steps for this PR:

  • Files in SBE generated using aeron-io
  • Moved current request builder to a build request function
  • Created in each service a DoSBE() that uses the buildRequest function

Performance test:

to run:

BINANCE_API_KEY="" BINANCE_SECRET_KEY=""  go test -timeout 30s -run ^TestTickerServiceSBEIntegration$/^Benchmark_JSON_vs_SBE_10_Iterations$ github.com/adshao/go-binance/v2 -count=1 -v```
Results show a lot of variation, but in general there does seem to be an improvement using SBE over JSON
```bash
=== Benchmark Results (50 iterations) ===
JSON:
  Total time: 14.67101304s
  Average time: 293.42026ms
  Min time: 226.179667ms
  Max time: 693.168625ms
  Range: 466.988958ms
  Result: Symbol=BTCUSDT, BidPrice=104935.99000000

SBE:
  Total time: 13.088622793s
  Average time: 261.772455ms
  Min time: 223.128459ms
  Max time: 723.094333ms
  Range: 499.965874ms
  Result: Symbol=BTCUSDT, BidPrice=104913.79000000

Performance: SBE is 1.12x faster
Average difference: 31.647805ms
Total time saved: 1.582390247s

@pcriadoperez pcriadoperez requested a review from Copilot November 11, 2025 03:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces support for Simple Binary Encoding (SBE) protocol by adding generated SBE codec files for the Binance Spot API v3.1 schema. The generated code provides efficient binary serialization/deserialization for exchange messages.

Key Changes:

  • Added generated SBE codec files for various message types (filters, responses, events)
  • Added enumeration types for trading primitives
  • Added documentation for SBE code generation process

Reviewed Changes

Copilot reviewed 36 out of 135 changed files in this pull request and generated 1 comment.

File Description
v2/sbe/spot_3_1/*.go Generated SBE message codecs for exchange filters, order responses, events, and enumerations
v2/sbe/README.md Documentation on generating SBE code from schema

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

```
Run following command to generate golang code:
```bash
java --add-opens java.base/jdk.internal.misc=ALL-UNNAMED -Dsbe.generate.ir=true -Dsbe.target.language=Cpp -Dsbe.target.namespace=sbe -Dsbe.output.dir=include/gen -Dsbe.errorLog=yes -jar sbe-all/build/libs/sbe-all-${SBE_TOOL_VERSION}.jar {SBE_SCHEMA}.xml
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

The command specifies -Dsbe.target.language=Cpp but this PR adds Go code. The target language should be corrected to match the actual generated code, or the documentation should clarify the generation process for Go.

Suggested change
java --add-opens java.base/jdk.internal.misc=ALL-UNNAMED -Dsbe.generate.ir=true -Dsbe.target.language=Cpp -Dsbe.target.namespace=sbe -Dsbe.output.dir=include/gen -Dsbe.errorLog=yes -jar sbe-all/build/libs/sbe-all-${SBE_TOOL_VERSION}.jar {SBE_SCHEMA}.xml
java --add-opens java.base/jdk.internal.misc=ALL-UNNAMED -Dsbe.generate.ir=true -Dsbe.target.language=Go -Dsbe.target.namespace=sbe -Dsbe.output.dir=include/gen -Dsbe.errorLog=yes -jar sbe-all/build/libs/sbe-all-${SBE_TOOL_VERSION}.jar {SBE_SCHEMA}.xml

Copilot uses AI. Check for mistakes.
@pcriadoperez pcriadoperez marked this pull request as ready for review November 12, 2025 14:15
@pcriadoperez pcriadoperez self-assigned this Nov 12, 2025
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.

2 participants