@@ -272,8 +272,15 @@ func getSmoothFactor(dur time.Duration) float64 {
272272// of guess-and-test and intuition. Someone who knows about this stuff
273273// is likely to laugh at the naivete. Point him to where someone intelligent
274274// has thought about this stuff and he will gladly do something smart.
275+ // Merges that took less than 5 minutes are ignored completely for the rate
276+ // calculation.
275277func calcMergeRate (oldRate float64 , last , now time.Time ) float64 {
276278 since := now .Sub (last )
279+ if since <= 5 * time .Minute {
280+ // retest-not-required PR merges shouldn't affect our best
281+ // guess about the rate.
282+ return oldRate
283+ }
277284 var rate float64
278285 if since == 0 {
279286 rate = 96
@@ -285,15 +292,15 @@ func calcMergeRate(oldRate float64, last, now time.Time) float64 {
285292 return toFixed (mergeRate )
286293}
287294
288- // updates a smoothed rate at which PRs are merging per day.
289- // returns 'Now()' and the rate.
290- // Should be called once after every merge. Also updates sq.totalMerges.
295+ // Updates a smoothed rate at which PRs are merging per day.
296+ // Updates merge stats. Should be called once for every merge.
291297func (sq * SubmitQueue ) updateMergeRate () {
292298 now := sq .clock .Now ()
293-
294299 sq .mergeRate = calcMergeRate (sq .mergeRate , sq .lastMergeTime , now )
295- sq .lastMergeTime = now
300+
301+ // Update stats
296302 atomic .AddInt32 (& sq .totalMerges , 1 )
303+ sq .lastMergeTime = now
297304}
298305
299306// This calculated the smoothed merge rate BUT it looks at the time since
@@ -1028,6 +1035,7 @@ func (sq *SubmitQueue) handleGithubE2EAndMerge() {
10281035func (sq * SubmitQueue ) mergePullRequest (obj * github.MungeObject ) {
10291036 obj .MergePR ("submit-queue" )
10301037 sq .SetMergeStatus (obj , merged )
1038+ sq .updateMergeRate ()
10311039}
10321040
10331041func (sq * SubmitQueue ) selectPullRequest () * github.MungeObject {
@@ -1088,7 +1096,6 @@ func (sq *SubmitQueue) doGithubE2EAndMerge(obj *github.MungeObject) bool {
10881096 }
10891097
10901098 if obj .HasLabel (retestNotRequiredLabel ) {
1091- // Do not update mergeRate when we don't do e2e tests
10921099 sq .mergePullRequest (obj )
10931100 return true
10941101 }
@@ -1139,7 +1146,6 @@ func (sq *SubmitQueue) doGithubE2EAndMerge(obj *github.MungeObject) bool {
11391146 return true
11401147 }
11411148
1142- sq .updateMergeRate ()
11431149 sq .mergePullRequest (obj )
11441150 return true
11451151}
0 commit comments