mirror of
https://github.com/dop251/goja.git
synced 2026-11-17 19:47:16 +00:00
Maintaining the hybrid approach was becoming increasingly hard due to the ever-increasing complexity of the translation code. And even when translation was possible it did not provide full compatibility as there are many [quirks](https://tc39.es/ecma262/#step-repeatmatcher-clear-captures) which were not
possible to emulate with the standard Go regexp library.
As the author of the regexp2 library has committed to full ECMAScript compatibility, rather than just porting the .NET library, migrating to regexp2 became the most viable option.
Also, with the recent [performance improvement](8dfb9760bc) the performance gap became acceptable:
```
│ benchmark_regexp_before_regexp2.txt │ benchmark_regexp_after_regexp2_opt_2.11.0_do_cache.txt │
│ sec/op │ sec/op vs base │
RegexpSplitWithBackRef-16 3.409µ ± 2% 2.206µ ± 1% -35.28% (p=0.002 n=6)
RegexpMatch-16 57.30µ ± 1% 50.80µ ± 28% ~ (p=0.065 n=6)
RegexpMatchCache-16 1.666m ± 1% 1.294m ± 1% -22.34% (p=0.002 n=6)
RegexpMatchAll-16 1.770m ± 1% 1.416m ± 1% -19.99% (p=0.002 n=6)
RegexpSingleExec/Re-ASCII-16 882.9n ± 1% 967.2n ± 4% +9.55% (p=0.002 n=6)
RegexpSingleExec/Re2-ASCII-16 1268.5n ± 2% 975.2n ± 4% -23.12% (p=0.002 n=6)
RegexpSingleExec/Re-Unicode-16 1.540µ ± 2% 1.003µ ± 1% -34.85% (p=0.002 n=6)
RegexpSingleExec/Re2-Unicode-16 1.302µ ± 5% 1.006µ ± 6% -22.73% (p=0.002 n=6)
geomean 13.77µ 10.87µ -21.03%
│ benchmark_regexp_before_regexp2.txt │ benchmark_regexp_after_regexp2_opt_2.11.0_do_cache.txt │
│ B/op │ B/op vs base │
RegexpSplitWithBackRef-16 6.508Ki ± 0% 1.955Ki ± 0% -69.96% (p=0.002 n=6)
RegexpMatch-16 48.76Ki ± 0% 60.61Ki ± 0% +24.31% (p=0.002 n=6)
RegexpMatchCache-16 1471.4Ki ± 0% 955.4Ki ± 0% -35.07% (p=0.002 n=6)
RegexpMatchAll-16 1511.1Ki ± 0% 1001.3Ki ± 0% -33.73% (p=0.002 n=6)
RegexpSingleExec/Re-ASCII-16 796.0 ± 0% 801.0 ± 0% +0.63% (p=0.002 n=6)
RegexpSingleExec/Re2-ASCII-16 1369.0 ± 0% 801.0 ± 0% -41.49% (p=0.002 n=6)
RegexpSingleExec/Re-Unicode-16 821.0 ± 0% 805.0 ± 0% -1.95% (p=0.002 n=6)
RegexpSingleExec/Re2-Unicode-16 1377.0 ± 0% 805.0 ± 0% -41.54% (p=0.002 n=6)
geomean 12.95Ki 8.995Ki -30.53%
│ benchmark_regexp_before_regexp2.txt │ benchmark_regexp_after_regexp2_opt_2.11.0_do_cache.txt │
│ allocs/op │ allocs/op vs base │
RegexpSplitWithBackRef-16 39.00 ± 0% 30.00 ± 0% -23.08% (p=0.002 n=6)
RegexpMatch-16 668.0 ± 0% 362.0 ± 0% -45.81% (p=0.002 n=6)
RegexpMatchCache-16 25.92k ± 0% 17.56k ± 0% -32.26% (p=0.002 n=6)
RegexpMatchAll-16 28.33k ± 0% 20.02k ± 0% -29.32% (p=0.002 n=6)
RegexpSingleExec/Re-ASCII-16 12.00 ± 0% 13.00 ± 0% +8.33% (p=0.002 n=6)
RegexpSingleExec/Re2-ASCII-16 21.00 ± 0% 13.00 ± 0% -38.10% (p=0.002 n=6)
RegexpSingleExec/Re-Unicode-16 14.00 ± 0% 14.00 ± 0% ~ (p=1.000 n=6) ¹
RegexpSingleExec/Re2-Unicode-16 22.00 ± 0% 14.00 ± 0% -36.36% (p=0.002 n=6)
geomean 186.8 137.3 -26.50%
¹ all samples are equal
```
Fixes #772, closes #785, closes #824.
235 lines
4.5 KiB
235 lines
4.5 KiB