Skip to content

Commit

Permalink
stellar#5099: use parallelJobSize as the alternate default for reinge…
Browse files Browse the repository at this point in the history
…st max flush size if lower than default of 100
  • Loading branch information
sreuland committed Nov 28, 2023
1 parent 80c9747 commit 386891a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
8 changes: 3 additions & 5 deletions services/horizon/cmd/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,9 @@ func runDBReingestRange(ledgerRanges []history.LedgerRange, reingestForce bool,
return errors.New("--force is incompatible with --parallel-workers > 1")
}

// set to 0 to allow system default to be applied for flush max,
// unless parallel workers are define, then set flush size to the number of workers.
maxLedgersPerFlush := uint32(0)
if parallelWorkers > 0 {
maxLedgersPerFlush = uint32(parallelWorkers)
maxLedgersPerFlush := ingest.MaxLedgersPerFlush
if parallelJobSize < maxLedgersPerFlush {
maxLedgersPerFlush = parallelJobSize
}

ingestConfig := ingest.Config{
Expand Down
8 changes: 5 additions & 3 deletions services/horizon/internal/ingest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ const (

defaultCoreCursorName = "HORIZON"
stateVerificationErrorThreshold = 3

// 100 ledgers per flush has shown in stress tests
// to be best point on performance curve, default to that.
MaxLedgersPerFlush uint32 = 100
)

var log = logpkg.DefaultLogger.WithField("service", "ingest")
Expand Down Expand Up @@ -282,9 +286,7 @@ func NewSystem(config Config) (System, error) {

maxLedgersPerFlush := config.MaxLedgerPerFlush
if maxLedgersPerFlush < 1 {
// 100 ledgers per flush has shown in stress tests
// to be best point on performance curve, default to that.
maxLedgersPerFlush = 100
maxLedgersPerFlush = MaxLedgersPerFlush
}

system := &system{
Expand Down
1 change: 1 addition & 0 deletions services/horizon/internal/ingest/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func TestNewSystem(t *testing.T) {

assert.Equal(t, config, system.runner.(*ProcessorRunner).config)
assert.Equal(t, system.ctx, system.runner.(*ProcessorRunner).ctx)
assert.Equal(t, system.maxLedgerPerFlush, MaxLedgersPerFlush)
}

func TestStateMachineRunReturnsUnexpectedTransaction(t *testing.T) {
Expand Down

0 comments on commit 386891a

Please sign in to comment.