Skip to content

Commit

Permalink
fix vu creation races and atomic ratelimit deref
Browse files Browse the repository at this point in the history
  • Loading branch information
skudasov committed Dec 19, 2024
1 parent 70bd176 commit 573794e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions wasp/wasp.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,9 @@ func (g *Generator) runExecuteLoop() {
for i := 0; i < int(vus); i++ {
inst := g.vu.Clone(g)
g.runVU(inst)
g.currentSegmentMu.Lock()
g.vus = append(g.vus, inst)
g.currentSegmentMu.Unlock()
}
}
}
Expand Down Expand Up @@ -508,6 +510,7 @@ func (g *Generator) processSegment() bool {
if oldVUs == newVUs {
return false
}
g.currentSegmentMu.Lock()
if oldVUs > g.currentSegment.From {
for i := 0; i < vusToSpawn; i++ {
g.vus[i].Stop(g)
Expand All @@ -520,6 +523,7 @@ func (g *Generator) processSegment() bool {
g.vus = append(g.vus, inst)
}
}
g.currentSegmentMu.Unlock()
}
return false
}
Expand Down Expand Up @@ -624,8 +628,10 @@ func (g *Generator) pacedCall() {
if !g.Stats().RunStarted.Load() {
return
}
l := *g.rl.Load()
l.Take()
if &g.rl == nil {
return
}
(*g.rl.Load()).Take()
if g.stats.RunPaused.Load() {
return
}
Expand Down

0 comments on commit 573794e

Please sign in to comment.