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

make compaction worker count configurable #803

Merged
merged 1 commit into from
Nov 13, 2024
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
26 changes: 15 additions & 11 deletions bgs/bgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,22 @@ type SocketConsumer struct {
}

type BGSConfig struct {
SSL bool
CompactInterval time.Duration
DefaultRepoLimit int64
ConcurrencyPerPDS int64
MaxQueuePerPDS int64
SSL bool
CompactInterval time.Duration
DefaultRepoLimit int64
ConcurrencyPerPDS int64
MaxQueuePerPDS int64
NumCompactionWorkers int
}

func DefaultBGSConfig() *BGSConfig {
return &BGSConfig{
SSL: true,
CompactInterval: 4 * time.Hour,
DefaultRepoLimit: 100,
ConcurrencyPerPDS: 100,
MaxQueuePerPDS: 1_000,
SSL: true,
CompactInterval: 4 * time.Hour,
DefaultRepoLimit: 100,
ConcurrencyPerPDS: 100,
MaxQueuePerPDS: 1_000,
NumCompactionWorkers: 2,
}
}

Expand Down Expand Up @@ -168,7 +170,9 @@ func NewBGS(db *gorm.DB, ix *indexer.Indexer, repoman *repomgr.RepoManager, evtm
return nil, err
}

compactor := NewCompactor(nil)
cOpts := DefaultCompactorOptions()
cOpts.NumWorkers = config.NumCompactionWorkers
compactor := NewCompactor(cOpts)
compactor.requeueInterval = config.CompactInterval
compactor.Start(bgs)
bgs.compactor = compactor
Expand Down
6 changes: 6 additions & 0 deletions cmd/bigsky/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ func run(args []string) error {
EnvVars: []string{"RELAY_EVENT_PLAYBACK_TTL"},
Value: 72 * time.Hour,
},
&cli.IntFlag{
Name: "num-compaction-workers",
EnvVars: []string{"RELAY_NUM_COMPACTION_WORKERS"},
Value: 2,
},
}

app.Action = runBigsky
Expand Down Expand Up @@ -413,6 +418,7 @@ func runBigsky(cctx *cli.Context) error {
bgsConfig.ConcurrencyPerPDS = cctx.Int64("concurrency-per-pds")
bgsConfig.MaxQueuePerPDS = cctx.Int64("max-queue-per-pds")
bgsConfig.DefaultRepoLimit = cctx.Int64("default-repo-limit")
bgsConfig.NumCompactionWorkers = cctx.Int("num-compaction-workers")
bgs, err := libbgs.NewBGS(db, ix, repoman, evtman, cachedidr, rf, hr, bgsConfig)
if err != nil {
return err
Expand Down
Loading