Skip to content
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

feat(options): add NumGoroutines option for default Stream.numGo #1656

Merged
merged 2 commits into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ type Options struct {
Logger Logger
Compression options.CompressionType
InMemory bool
// Sets the Stream.numGo field
NumGoroutines int

// Fine tuning options.

Expand Down Expand Up @@ -125,6 +127,7 @@ func DefaultOptions(path string) Options {
TableSizeMultiplier: 2,
LevelSizeMultiplier: 10,
MaxLevels: 7,
NumGoroutines: 8,

NumCompactors: 4, // Run at least 2 compactors. Zero-th compactor prioritizes L0.
NumLevelZeroTables: 5,
Expand Down Expand Up @@ -252,6 +255,14 @@ func (opt Options) WithNumVersionsToKeep(val int) Options {
return opt
}

// WithNumGoroutines sets the number of goroutines to be used in Stream.
//
// The default value of NumGoroutines is 8.
func (opt Options) WithNumGoroutines(val int) Options {
opt.NumGoroutines = val
return opt
}

// WithReadOnly returns a new Options value with ReadOnly set to the given value.
//
// When ReadOnly is true the DB will be opened on read-only mode.
Expand Down
2 changes: 1 addition & 1 deletion stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ func (st *Stream) Orchestrate(ctx context.Context) error {
func (db *DB) newStream() *Stream {
return &Stream{
db: db,
NumGo: 8,
NumGo: db.opt.NumGoroutines,
LogPrefix: "Badger.Stream",
}
}
Expand Down