From b73e88fe6aa670034fae83f7216f7fd38ae21dfd Mon Sep 17 00:00:00 2001 From: roseduan Date: Sat, 23 Sep 2023 18:45:45 +0800 Subject: [PATCH 1/3] no need to return err in pendingWrites --- benchmark/bench_test.go | 6 ++---- wal.go | 3 +-- wal_test.go | 3 +-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/benchmark/bench_test.go b/benchmark/bench_test.go index bff75d7..e666412 100644 --- a/benchmark/bench_test.go +++ b/benchmark/bench_test.go @@ -51,11 +51,9 @@ 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)) 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) From 3202245af020c71b3c45d160bb7260fe530bd430 Mon Sep 17 00:00:00 2001 From: roseduan Date: Sun, 24 Sep 2023 10:25:28 +0800 Subject: [PATCH 2/3] fix bench error --- benchmark/bench_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmark/bench_test.go b/benchmark/bench_test.go index e666412..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) @@ -56,7 +56,7 @@ func BenchmarkWAL_WriteBatch(b *testing.B) { 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)) } } From 8de919049e2859973403f45d11920f383e43a0e8 Mon Sep 17 00:00:00 2001 From: roseduan Date: Mon, 25 Sep 2023 21:30:06 +0800 Subject: [PATCH 3/3] add changelog for v1.3.6 --- CHANGELOG.md | 10 ++++++++++ README.md | 5 ++--- 2 files changed, 12 insertions(+), 3 deletions(-) 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