diff --git a/CHANGELOG.md b/CHANGELOG.md index bf0a51a..b0196ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# Release 1.3.6 (2023-09-25) + +## 🎄 Enhancements +* avoid resetting pool to optimize the memory usage +* no need to return err in pendingWrites +* fix benchmark error +## 🎠 Community +* Thanks to @akiozihao + * check ErrPendingSizeTooLarge first (https://github.com/rosedblabs/wal/pull/32) + # Release 1.3.5 (2023-09-19) ## 🎄 Enhancements diff --git a/README.md b/README.md index 54be6ae..e2198e0 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,11 @@ Write Ahead Log for LSM or bitcask storage, with block cache. ## Key Features * Disk based, support large data volume * Append only write, high performance -* Fast read, one disk seek to retrieve any data +* Fast read, one disk seek to retrieve any value * Support Block Cache, improve read performance * Support batch write, all data in a batch will be written in a single disk seek -* Iterate all data in wal with NewReader +* Iterate all data in wal with `NewReader` function * Support concurrent write and read, all functions are thread safe -* Support data compression, use Snappy and ZSTD(Coming soon) ## Design Overview diff --git a/benchmark/bench_test.go b/benchmark/bench_test.go index bff75d7..a1e363a 100644 --- a/benchmark/bench_test.go +++ b/benchmark/bench_test.go @@ -17,7 +17,7 @@ func init() { opts := wal.Options{ DirPath: dir, SegmentFileExt: ".SEG", - SegmentSize: 32 * 1024 * 1024, + SegmentSize: wal.GB, } var err error walFile, err = wal.Open(opts) @@ -51,14 +51,12 @@ func BenchmarkWAL_WriteBatch(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { for j := 0; j < 31; j++ { - err := walFile.PendingWrites([]byte(strings.Repeat("X", wal.MB))) - assert.Nil(b, err) + walFile.PendingWrites([]byte(strings.Repeat("X", wal.MB))) } - err := walFile.PendingWrites([]byte(strings.Repeat("X", wal.MB))) - assert.Equal(b, wal.ErrPendingSizeTooLarge, err) + walFile.PendingWrites([]byte(strings.Repeat("X", wal.MB))) pos, err := walFile.WriteAll() assert.Nil(b, err) - assert.Equal(b, 0, len(pos)) + assert.Equal(b, 32, len(pos)) } } diff --git a/wal.go b/wal.go index 8a34de8..5e27e49 100644 --- a/wal.go +++ b/wal.go @@ -315,14 +315,13 @@ func (wal *WAL) ClearPendingWrites() { // PendingWrites add data to wal.pendingWrites and wait for batch write. // If the data in pendingWrites exceeds the size of one segment, // it will return a 'ErrPendingSizeTooLarge' error and clear the pendingWrites. -func (wal *WAL) PendingWrites(data []byte) error { +func (wal *WAL) PendingWrites(data []byte) { wal.pendingWritesLock.Lock() defer wal.pendingWritesLock.Unlock() size := wal.maxDataWriteSize(int64(len(data))) wal.pendingSize += size wal.pendingWrites = append(wal.pendingWrites, data) - return nil } // rotateActiveSegment create a new segment file and replace the activeSegment. diff --git a/wal_test.go b/wal_test.go index 6342845..682f921 100644 --- a/wal_test.go +++ b/wal_test.go @@ -190,8 +190,7 @@ func TestWAL_Reader(t *testing.T) { func testWriteAllIterate(t *testing.T, wal *WAL, size, valueSize int) { for i := 0; i < size; i++ { val := strings.Repeat("wal", valueSize) - err := wal.PendingWrites([]byte(val)) - assert.Nil(t, err) + wal.PendingWrites([]byte(val)) } positions, err := wal.WriteAll() assert.Nil(t, err)