Skip to content

perf: add buffer pool for packet encoding to reduce allocations - #209

Merged
DrmagicE merged 1 commit into
masterfrom
feat/buffer-pool-optimization
Apr 4, 2026
Merged

DrmagicE merged 1 commit into
masterfrom
feat/buffer-pool-optimization

Conversation

@DrmagicE

@DrmagicE DrmagicE commented Apr 4, 2026

Copy link
Copy Markdown
Owner

Use sync.Pool to reuse bytes.Buffer objects in Pack() methods, significantly reducing memory allocations and GC pressure.

Performance improvement (parallel benchmark):

  • Connect: 30.08 ns/op → 13.81 ns/op (54% faster)
  • Publish: 65.64 ns/op → 4.54 ns/op (93% faster)

Use sync.Pool to reuse bytes.Buffer objects in Pack() methods,
significantly reducing memory allocations and GC pressure.

Performance improvement (parallel benchmark):
- Connect:  30.08 ns/op → 13.81 ns/op (54% faster)
- Publish:  65.64 ns/op →  4.54 ns/op (93% faster)

Co-Authored-By: Claude <noreply@anthropic.com>
@DrmagicE
DrmagicE merged commit e87974a into master Apr 4, 2026
1 of 7 checks passed
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.

1 participant