Skip to content

Conversation

@tamirms
Copy link
Contributor

@tamirms tamirms commented Jan 6, 2026

Regenerate XDR bindings and update handwritten code with multiple performance optimizations for XDR decoding.

Key changes:

  1. Buffer-based decoding

    • xdr.Unmarshal now takes []byte instead of io.Reader
    • Direct buffer access eliminates io.Reader dispatch overhead
    • Use xdr.Decoder directly for primitive decoding in strkey package
    • New Decoder.Decode() method simplifies decode calls
  2. Union value-type optimization

    • Primitive union arms (Bool, Int32, Uint32, Int64, Uint64, etc.) stored as values instead of pointers, reducing allocations
    • Complex union arms (ScVec, ScMap, structs) remain as pointers
    • Direct field access for union arms instead of accessor methods
  3. Generated accessor improvements

    • GetX() accessors return (value, bool) for optional handling
    • MustX() accessors for cases where arm is known to be set
  4. Object pooling support

    • XDR types support pooling via Pool[T] generic type
    • Enables reuse of decoded objects to reduce GC pressure

Performance improvement (LedgerCloseMeta decode, 100 varied ledgers):

Without pooling:

  • Latency: 5.31ms → 3.45ms (-35%)
  • Throughput: 277 MB/s → 426 MB/s (+54%)
  • Memory: 8.06 MB → 7.46 MB (-7.5%)
  • Allocations: 107.7k → 90.7k (-16%)

With pooling:

  • Latency: 5.31ms → 2.58ms (-51%)
  • Throughput: 277 MB/s → 570 MB/s (+106%)
  • Memory: 8.06 MB → 2.64 MB (-67%)
  • Allocations: 107.7k → 33.6k (-69%)

🤖 Generated with Claude Code

@socket-security
Copy link

socket-security bot commented Jan 6, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedgithub.com/​stellar/​go-xdr@​v0.0.0-20231122183749-b53fb00bcac2 ⏵ v0.0.0-20260106211653-82e681bfd3f398 +1100100100100

View full report

@tamirms tamirms force-pushed the xdr-optimize branch 3 times, most recently from 45d3678 to 1a6769a Compare January 6, 2026 21:20
Regenerate XDR bindings and update handwritten code with multiple
performance optimizations for XDR decoding.

Key changes:

1. Buffer-based decoding
   - xdr.Unmarshal now takes []byte instead of io.Reader
   - Direct buffer access eliminates io.Reader dispatch overhead
   - Use xdr.Decoder directly for primitive decoding in strkey package
   - New Decoder.Decode() method simplifies decode calls

2. Union value-type optimization
   - Primitive union arms (Bool, Int32, Uint32, Int64, Uint64, etc.)
     stored as values instead of pointers, reducing allocations
   - Complex union arms (ScVec, ScMap, structs) remain as pointers
   - Direct field access for union arms instead of accessor methods

3. Generated accessor improvements
   - GetX() accessors return (value, bool) for optional handling
   - MustX() accessors for cases where arm is known to be set

4. Object pooling support
   - XDR types support pooling via Pool[T] generic type
   - Enables reuse of decoded objects to reduce GC pressure

Performance improvement (LedgerCloseMeta decode, 100 varied ledgers):

Without pooling:
- Latency:     5.31ms → 3.45ms (-35%)
- Throughput:  277 MB/s → 426 MB/s (+54%)
- Memory:      8.06 MB → 7.46 MB (-7.5%)
- Allocations: 107.7k → 90.7k (-16%)

With pooling:
- Latency:     5.31ms → 2.58ms (-51%)
- Throughput:  277 MB/s → 570 MB/s (+106%)
- Memory:      8.06 MB → 2.64 MB (-67%)
- Allocations: 107.7k → 33.6k (-69%)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there going to be xdrgen changes to match the new decoding patterns?

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