This repository was archived by the owner on Jun 27, 2023. It is now read-only.
gomock: fix matcher's degenerate quadratic path. #103
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed several tests timing out when attempting to integrate HEAD
into our mainline branch. The reason was the accidental introduction of
a quadratic call path in callSet.FindMatch, which performed string
concatenation in a tight loop.
This was corroborated by PProf reporting 23 seconds out of 30 seconds
being spent in runtime.concatstrings, which backs onto runtime.memmove.
The host I instrumented this on was not the same as the ones for which
the data is shown below.
The error accumulation routine has been replaced with bytes.Buffer, which
exponentially grows its underlying buffer to amortize the cost. After
converting a prototype changelist to this pull request you see here, the
total runtime of this test that demonstrated the defect fell from 80
seconds to 15. This was just one run on a noisy cluster.
This is change introduced the defect:
https://github.com/golang/mock/blame/4187d4d04aa043124750c9250259ceafdc5f7380/gomock/callset.go#L68