Skip to content

Commit

Permalink
Move runLoopsIfPossible goroutine creation to a function
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed Nov 18, 2021
1 parent c0f7e06 commit 4bb561d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/executor/ramping_vus.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,9 @@ func (vlv *RampingVUs) Run(ctx context.Context, _ chan<- stats.SampleContainer,
go trackProgress(ctx, maxDurationCtx, regularDurationCtx, vlv, progressFn)

defer runState.wg.Wait()
runState.populateVUHandles(maxDurationCtx, cancel)
for i := uint64(0); i < runState.maxVUs; i++ {
go runState.vuHandles[i].runLoopsIfPossible(runState.runIteration)
}
// this will populate stopped VUs and run runLoopsIfPossible on each VU
// handle in a new goroutine
runState.runLoopsIfPossible(maxDurationCtx, cancel)

var (
handleNewMaxAllowedVUs = runState.maxAllowedVUsHandlerStrategy()
Expand Down Expand Up @@ -603,7 +602,7 @@ func (rs *rampingVUsRunState) makeProgressFn(regular time.Duration) (progressFn
}
}

func (rs *rampingVUsRunState) populateVUHandles(ctx context.Context, cancel func()) {
func (rs *rampingVUsRunState) runLoopsIfPossible(ctx context.Context, cancel func()) {
getVU := func() (lib.InitializedVU, error) {
pvu, err := rs.executor.executionState.GetPlannedVU(rs.executor.logger, false)
if err != nil {
Expand All @@ -626,6 +625,7 @@ func (rs *rampingVUsRunState) populateVUHandles(ctx context.Context, cancel func
rs.vuHandles[i] = newStoppedVUHandle(
ctx, getVU, returnVU, rs.executor.nextIterationCounters,
&rs.executor.config.BaseConfig, rs.executor.logger.WithField("vuNum", i))
go rs.vuHandles[i].runLoopsIfPossible(rs.runIteration)
}
}

Expand Down

0 comments on commit 4bb561d

Please sign in to comment.