Skip to content

Some optimization for LZ4 compression#48

Open
everyx wants to merge 2 commits intodarkweak:mainfrom
everyx:perf/lz4-write-optimization
Open

Some optimization for LZ4 compression#48
everyx wants to merge 2 commits intodarkweak:mainfrom
everyx:perf/lz4-write-optimization

Conversation

@everyx
Copy link

@everyx everyx commented Feb 28, 2026

Changes

  1. Replace ReadFrom with Write - Avoid unnecessary bytes.Reader allocation
    - Changed from writer.ReadFrom(bytes.NewReader(value)) to writer.Write(value)
    - Applied to all 9 storage providers: badger, etcd, go-redis, nats, nuts, olric, otter, redis, simplefs
  2. Move LZ4 compression outside Badger transaction - Reduce lock contention
    - Compression is CPU-intensive and was previously done inside the Badger Update transaction
    - Moved compression before the transaction to avoid holding the database lock during compression

everyx added 2 commits March 1, 2026 00:40
Replace writer.ReadFrom(bytes.NewReader(value)) with writer.Write(value)
across all 9 storage providers to avoid unnecessary bytes.Reader allocation.
Move LZ4 compression to outside of the Badger Update transaction
to avoid holding the database lock during CPU-intensive compression.
@everyx everyx changed the title Perf/lz4 write optimization Some optimization for LZ4 compression Feb 28, 2026
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