v1.8.0
ghemawat
tagged this
13 Jan 22:03
Currently regexp2 can be quite slow when a MatchTimeout is supplied (a micro-benchmark shows 3000ns compared to 45ns when no timeout is supplied). This slowdown is caused by repeated timeout checks which call time.Now(). The new approach introduces a fast but approximate clock that is just an atomic variable updated by a goroutine once very 100ms. The new timeout check just compares this variable to the precomputed deadline. Removed "timeout check skip" mechanism since a timeout check is now very cheap. Added a simple micro-benchmark that compares the speed of searching 100 byte text with and without a timeout. Performance impact: 1. A micro-benchmark that looks for an "easy" regexp in a 100 byte string goes from ~3000ns to ~45ns. 2. Chroma (syntax highlighter) speeds up from ~500ms to ~50ms on a 24KB source file. 3. A background CPU load of ~0.15% is present until the end of of all match deadlines (even for matches that have finished).
Assets 2
-
2023-01-13T22:03:14Z -
2023-01-13T22:03:14Z -