-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pump/: Add syn-log option #509
Merged
+54
−40
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,8 @@ func NewAppendWithResolver(dir string, options *Options, tiStore kv.Storage, tiL | |
options = DefaultOptions() | ||
} | ||
|
||
log.Infof("options: %+v", options) | ||
|
||
valueDir := path.Join(dir, "value") | ||
err = os.MkdirAll(valueDir, 0755) | ||
if err != nil { | ||
|
@@ -113,7 +115,7 @@ func NewAppendWithResolver(dir string, options *Options, tiStore kv.Storage, tiL | |
} | ||
|
||
kvDir := path.Join(dir, "kv") | ||
metadata, err := openMetadataDB(kvDir, options.Storage) | ||
metadata, err := openMetadataDB(kvDir, options.KVConfig) | ||
if err != nil { | ||
return nil, errors.Trace(err) | ||
} | ||
|
@@ -992,7 +994,17 @@ func getStorageSize(dir string) (size storageSize, err error) { | |
|
||
// Config holds the configuration of storage | ||
type Config struct { | ||
KVConfig `toml:"kv" json:"kv"` | ||
SyncLog *bool `toml:"sync-log" json:"sync-log"` | ||
KV *KVConfig `toml:"kv" json:"kv"` | ||
} | ||
|
||
// GetSyncLog return sync-log config option | ||
func (c *Config) GetSyncLog() bool { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could also handle the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WithSync accept |
||
if c.SyncLog == nil { | ||
return true | ||
} | ||
|
||
return *c.SyncLog | ||
} | ||
|
||
// KVConfig if the configuration of goleveldb | ||
|
@@ -1009,57 +1021,55 @@ type KVConfig struct { | |
WriteL0SlowdownTrigger int `toml:"write-L0-slowdown-trigger" json:"write-L0-slowdown-trigger"` | ||
} | ||
|
||
var defaultStorageConfig = &Config{ | ||
KVConfig: KVConfig{ | ||
BlockCacheCapacity: 8388608, | ||
BlockRestartInterval: 16, | ||
BlockSize: 4096, | ||
CompactionL0Trigger: 8, | ||
CompactionTableSize: 67108864, | ||
CompactionTotalSize: 536870912, | ||
CompactionTotalSizeMultiplier: 8, | ||
WriteBuffer: 67108864, | ||
WriteL0PauseTrigger: 24, | ||
WriteL0SlowdownTrigger: 17, | ||
}, | ||
var defaultStorageKVConfig = &KVConfig{ | ||
BlockCacheCapacity: 8388608, | ||
BlockRestartInterval: 16, | ||
BlockSize: 4096, | ||
CompactionL0Trigger: 8, | ||
CompactionTableSize: 67108864, | ||
CompactionTotalSize: 536870912, | ||
CompactionTotalSizeMultiplier: 8, | ||
WriteBuffer: 67108864, | ||
WriteL0PauseTrigger: 24, | ||
WriteL0SlowdownTrigger: 17, | ||
} | ||
|
||
func setDefaultStorageConfig(cf *Config) { | ||
func setDefaultStorageConfig(cf *KVConfig) { | ||
if cf.BlockCacheCapacity <= 0 { | ||
cf.BlockCacheCapacity = defaultStorageConfig.BlockCacheCapacity | ||
cf.BlockCacheCapacity = defaultStorageKVConfig.BlockCacheCapacity | ||
} | ||
if cf.BlockRestartInterval <= 0 { | ||
cf.BlockRestartInterval = defaultStorageConfig.BlockRestartInterval | ||
cf.BlockRestartInterval = defaultStorageKVConfig.BlockRestartInterval | ||
} | ||
if cf.BlockSize <= 0 { | ||
cf.BlockSize = defaultStorageConfig.BlockSize | ||
cf.BlockSize = defaultStorageKVConfig.BlockSize | ||
} | ||
if cf.CompactionL0Trigger <= 0 { | ||
cf.CompactionL0Trigger = defaultStorageConfig.CompactionL0Trigger | ||
cf.CompactionL0Trigger = defaultStorageKVConfig.CompactionL0Trigger | ||
} | ||
if cf.CompactionTableSize <= 0 { | ||
cf.CompactionTableSize = defaultStorageConfig.CompactionTableSize | ||
cf.CompactionTableSize = defaultStorageKVConfig.CompactionTableSize | ||
} | ||
if cf.CompactionTotalSize <= 0 { | ||
cf.CompactionTotalSize = defaultStorageConfig.CompactionTotalSize | ||
cf.CompactionTotalSize = defaultStorageKVConfig.CompactionTotalSize | ||
} | ||
if cf.CompactionTotalSizeMultiplier <= 0 { | ||
cf.CompactionTotalSizeMultiplier = defaultStorageConfig.CompactionTotalSizeMultiplier | ||
cf.CompactionTotalSizeMultiplier = defaultStorageKVConfig.CompactionTotalSizeMultiplier | ||
} | ||
if cf.WriteBuffer <= 0 { | ||
cf.WriteBuffer = defaultStorageConfig.WriteBuffer | ||
cf.WriteBuffer = defaultStorageKVConfig.WriteBuffer | ||
} | ||
if cf.WriteL0PauseTrigger <= 0 { | ||
cf.WriteL0PauseTrigger = defaultStorageConfig.WriteL0PauseTrigger | ||
cf.WriteL0PauseTrigger = defaultStorageKVConfig.WriteL0PauseTrigger | ||
} | ||
if cf.WriteL0SlowdownTrigger <= 0 { | ||
cf.WriteL0SlowdownTrigger = defaultStorageConfig.WriteL0SlowdownTrigger | ||
cf.WriteL0SlowdownTrigger = defaultStorageKVConfig.WriteL0SlowdownTrigger | ||
} | ||
} | ||
|
||
func openMetadataDB(kvDir string, cf *Config) (*leveldb.DB, error) { | ||
func openMetadataDB(kvDir string, cf *KVConfig) (*leveldb.DB, error) { | ||
if cf == nil { | ||
cf = defaultStorageConfig | ||
cf = defaultStorageKVConfig | ||
} else { | ||
setDefaultStorageConfig(cf) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do we get when this is changed from pointer to value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just no need to check if
Storage
is nil (when noStorage**
is config in file)