@@ -62,8 +62,6 @@ const (
62
62
DefaultLevelMultiplier = 10 // Multiplier for the number of levels
63
63
// 64MB -> 640MB -> 6.4GB -> 64GB -> 640GB -> 6.4TB
64
64
DefaultBlockManagerLRUSize = 1024 // Size of the LRU cache for block managers
65
- DefaultBlockManagerLRUEvictRatio = 0.20 // Eviction ratio for the LRU cache
66
- DefaultBlockManagerLRUAccessWeight = 0.8 // Access weight for the LRU cache
67
65
DefaultPermission = 0750 // Default permission for created files
68
66
DefaultMaxCompactionConcurrency = 4 // Default max compaction concurrency
69
67
DefaultCompactionCooldownPeriod = 5 * time .Second // Default cooldown period for compaction
@@ -97,8 +95,6 @@ type Options struct {
97
95
LevelCount int // Number of levels in the LSM tree
98
96
LevelMultiplier int // Multiplier for the number of levels
99
97
BlockManagerLRUSize int // Size of the LRU cache for block managers
100
- BlockManagerLRUEvictRatio float64 // Eviction ratio for the LRU cache
101
- BlockManagerLRUAccesWeight float64 // Access weight for the LRU cache
102
98
Permission os.FileMode // Permission for created files
103
99
LogChannel chan string // Channel for logging
104
100
STDOutLogging bool // Enable logging to standard output (default is false and if set, channel is ignored)
@@ -178,12 +174,12 @@ func Open(opts *Options) (*DB, error) {
178
174
}
179
175
180
176
db := & DB {
181
- lru : lru .New (int64 ( opts .BlockManagerLRUSize ), opts . BlockManagerLRUEvictRatio , opts . BlockManagerLRUAccesWeight ), // New block manager LRU cache
182
- wg : & sync.WaitGroup {}, // Wait group for background operations
183
- opts : opts , // Set the options
184
- txnBuffer : buff , // Create a new buffer for transactions with the specified cap
185
- closeCh : make (chan struct {}), // Channel for closing the database
186
- txnTSGenerator : newIDGeneratorWithTimestamp (), // We use timestamp generator for monotonic generation (1579134612000000004, next ID will be 1579134612000000005)
177
+ lru : lru .New (opts .BlockManagerLRUSize ), // New block manager LRU cache
178
+ wg : & sync.WaitGroup {}, // Wait group for background operations
179
+ opts : opts , // Set the options
180
+ txnBuffer : buff , // Create a new buffer for transactions with the specified cap
181
+ closeCh : make (chan struct {}), // Channel for closing the database
182
+ txnTSGenerator : newIDGeneratorWithTimestamp (), // We use timestamp generator for monotonic generation (1579134612000000004, next ID will be 1579134612000000005)
187
183
}
188
184
189
185
// Initialize flusher and compactor
@@ -360,14 +356,6 @@ func (opts *Options) setDefaults() error {
360
356
opts .BlockManagerLRUSize = DefaultBlockManagerLRUSize
361
357
}
362
358
363
- if opts .BlockManagerLRUEvictRatio <= 0 {
364
- opts .BlockManagerLRUEvictRatio = DefaultBlockManagerLRUEvictRatio
365
- }
366
-
367
- if opts .BlockManagerLRUAccesWeight <= 0 {
368
- opts .BlockManagerLRUAccesWeight = DefaultBlockManagerLRUAccessWeight
369
- }
370
-
371
359
if opts .SSTableBTreeOrder <= 0 {
372
360
opts .SSTableBTreeOrder = DefaultSSTableBTreeOrder
373
361
} else {
@@ -433,7 +421,7 @@ func (db *DB) Close() error {
433
421
db .wg .Wait ()
434
422
435
423
// Close open block managers
436
- db .lru .ForEach (func (key , value interface {}, accessCount uint64 ) bool {
424
+ db .lru .ForEach (func (key string , value interface {}) bool {
437
425
if bm , ok := value .(* blockmanager.BlockManager ); ok {
438
426
_ = bm .Close ()
439
427
}
@@ -501,7 +489,7 @@ func (db *DB) reinstate() error {
501
489
}
502
490
503
491
// Add the WAL to the LRU cache
504
- db .lru .Put (newWalPath , walBm , func (key , value interface {}) {
492
+ db .lru .Put (newWalPath , walBm , func (key string , value interface {}) {
505
493
// Close the block manager when evicted from LRU
506
494
if bm , ok := value .(* blockmanager.BlockManager ); ok {
507
495
_ = bm .Close ()
@@ -536,7 +524,7 @@ func (db *DB) reinstate() error {
536
524
}
537
525
538
526
// Add WAL to LRU cache
539
- db .lru .Put (walPath , walBm , func (key , value interface {}) {
527
+ db .lru .Put (walPath , walBm , func (key string , value interface {}) {
540
528
// Close the block manager when evicted from LRU
541
529
if bm , ok := value .(* blockmanager.BlockManager ); ok {
542
530
_ = bm .Close ()
@@ -698,7 +686,7 @@ func (db *DB) reinstate() error {
698
686
}
699
687
700
688
// Update or add to LRU cache
701
- db .lru .Put (activeWALPath , activeWalBm , func (key , value interface {}) {
689
+ db .lru .Put (activeWALPath , activeWalBm , func (key string , value interface {}) {
702
690
// Close the block manager when evicted from LRU
703
691
if bm , ok := value .(* blockmanager.BlockManager ); ok {
704
692
_ = bm .Close ()
@@ -1003,7 +991,6 @@ func (db *DB) Stats() string {
1003
991
"Compaction Size Ratio" , "Compaction Threshold" , "Score Size Weight" ,
1004
992
"Score Count Weight" , "Flusher Interval" , "Compactor Interval" , "Bloom FPR" ,
1005
993
"WAL Retry" , "WAL Backoff" , "SSTable B-Tree Order" , "LRU Size" ,
1006
- "LRU Evict Ratio" , "LRU Access Weight" ,
1007
994
"File Version" ,
1008
995
"Magic Number" ,
1009
996
"Directory" ,
@@ -1014,8 +1001,7 @@ func (db *DB) Stats() string {
1014
1001
db .opts .CompactionSizeRatio , db .opts .CompactionSizeThreshold , db .opts .CompactionScoreSizeWeight ,
1015
1002
db .opts .CompactionScoreCountWeight , db .opts .FlusherTickerInterval , db .opts .CompactorTickerInterval ,
1016
1003
db .opts .BloomFilterFPR , db .opts .WalAppendRetry , db .opts .WalAppendBackoff ,
1017
- db .opts .SSTableBTreeOrder , db .opts .BlockManagerLRUSize , db .opts .BlockManagerLRUEvictRatio ,
1018
- db .opts .BlockManagerLRUAccesWeight ,
1004
+ db .opts .SSTableBTreeOrder , db .opts .BlockManagerLRUSize ,
1019
1005
blockmanager .Version ,
1020
1006
blockmanager .MagicNumber ,
1021
1007
db .opts .Directory ,
0 commit comments