You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(parser): fix bad perf and wrong precedece of await
We sometimes parse await expresesions twice if we suspect that the
'await' should have been 'async' instead. This can lead to a lot of
backtracking, causing very bad performance on inputs like the following:
await a => await a => await a => await a => await a => await a =>
await a => await a => await a => await a => await a => await a =>
await a => await a => await a => await a => await a => a
Fix this performance issue by rewriting the logic to avoid backtracking
altogether. Instead, interweave the logic in parse_async_expression.
As a side effect, this change fixes a bug where binary operators after
the 'await' were incorrectly consumed as part of the await expression.
Benchmark Time CPU Time Old Time New CPU Old CPU New
----------------------------------------------------------------------------------------------------------------------------------------------
benchmark_parse/pathological_await_arrow -1.0000 -1.0000 213495925 1672 213458684 1672
benchmark_parse/pathological_await_arrow -1.0000 -1.0000 213580205 1672 213542936 1672
benchmark_parse/pathological_await_arrow -1.0000 -1.0000 213228540 1680 213188854 1679
benchmark_parse/pathological_await_arrow -1.0000 -1.0000 212768030 1690 212733692 1690
benchmark_parse/pathological_await_arrow -1.0000 -1.0000 213213714 1689 213173590 1689
benchmark_parse/pathological_await_arrow -1.0000 -1.0000 213519479 1696 213483344 1696
benchmark_parse/pathological_await_arrow -1.0000 -1.0000 213759724 1698 213724009 1698
benchmark_parse/pathological_await_arrow -1.0000 -1.0000 214259949 1695 214218748 1695
benchmark_parse/pathological_await_arrow -1.0000 -1.0000 213101099 1690 213062912 1690
benchmark_parse/pathological_await_arrow -1.0000 -1.0000 213137875 1717 213100767 1717
benchmark_parse/pathological_await_arrow_pvalue 0.0002 0.0002 U Test, Repetitions: 10 vs 10
benchmark_parse/pathological_await_arrow_mean -1.0000 -1.0000 213406454 1690 213368753 1690
benchmark_parse/pathological_await_arrow_median -1.0000 -1.0000 213362232 1690 213323769 1690
benchmark_parse/pathological_await_arrow_stddev -1.0000 -1.0000 414459 13 413571 13
benchmark_parse/pathological_await_arrow_cv +3.0919 +3.0997 0 0 0 0
OVERALL_GEOMEAN -1.0000 -1.0000 0 0 0 0
0 commit comments