swiftlang / swift-experimental-string-processing

An early experimental general-purpose pattern matching engine for Swift.
Apache License 2.0
278 stars 47 forks source link

Speed up quantification optimizations by unswitching #706

Closed milseman closed 10 months ago

milseman commented 10 months ago

Unswitch the quant loop.

Comparing against saved benchmark result before_improvements
=== Regressions ======================================================================
- EmailRFCNoMatches_All_Scalar            124ms 122ms   1.97ms      1.6%
- Words_All_Scalar                        12.7ms    12.2ms  476µs       3.9%
- ReluctantQuantWithTerminal_Whole_Scalar 5.51ms    5.2ms   304µs       5.8%
- EmailLookaheadList                      4.07ms    3.91ms  168µs       4.3%
- Css_All                                 3.37ms    3.27ms  101µs       3.1%
- Css_All_Scalar                          2.98ms    2.92ms  56.5µs      1.9%
- EmailBuiltinCharacterClass_All_Scalar   10.1ms    10.1ms  52.2µs      0.5%
- EmailBuiltinCharacterClass_All          10.3ms    10.3ms  48µs        0.5%
- ReluctantQuantWithTerminal_Whole        5.22ms    5.18ms  40.3µs      0.8%
=== Improvements =====================================================================
- CompilerMessages_All                    86.7ms    92ms    -5.24ms     -5.7%
- CompilerMessages_All_Scalar             70ms  75.1ms  -5.14ms     -6.8%
- AnchoredNotFound_All                    13.5ms    14.6ms  -1.1ms      -7.5%
- BasicRangeCCC_All_Scalar                6.4ms 7.14ms  -736µs      -10.3%
- AnchoredNotFound_First                  9.12ms    9.85ms  -733µs      -7.4%
- DiceRollsInText_All_Scalar              38.5ms    39.2ms  -671µs      -1.7%
- EmojiRegex_All_Scalar                   40.5ms    41ms    -557µs      -1.4%
- NotFound_All                            7.18ms    7.56ms  -385µs      -5.1%
- AnchoredNotFound_First_Scalar           5.62ms    6ms -381µs      -6.4%
- EagarQuantWithTerminal_Whole_Scalar     441µs 783µs   -342µs      -43.7%
- EagarQuantWithTerminal_Whole            446µs 780µs   -334µs      -42.9%
- SubtractionCCC_All                      20.9ms    21.2ms  -264µs      -1.2%
- Words_All                               12.4ms    12.6ms  -259µs      -2.1%
- GraphemeBreakNoCap_All_Scalar           2.83ms    3.09ms  -254µs      -8.2%
- Numbers_All                             5.83ms    6.07ms  -240µs      -3.9%
- Numbers_All_Scalar                      5.09ms    5.33ms  -237µs      -4.5%
- CaseInsensitiveCCC_All                  6.35ms    6.56ms  -218µs      -3.3%
- GraphemeBreakNoCap_All                  2.99ms    3.2ms   -209µs      -6.5%
- NotFound_All_Scalar                     6.17ms    6.35ms  -177µs      -2.8%
- BasicBuiltinCharacterClass_All          8.09ms    8.27ms  -177µs      -2.1%
- LiteralSearchNotFound_All_Scalar        5.52ms    5.67ms  -154µs      -2.7%
- LiteralSearch_All_Scalar                5.72ms    5.87ms  -151µs      -2.6%
- BasicBuiltinCharacterClass_All_Scalar   7.09ms    7.23ms  -141µs      -2.0%
- EmailLookahead_All                      19.4ms    19.6ms  -132µs      -0.7%
- BasicCCC_All                            5.92ms    6.05ms  -123µs      -2.0%
- LiteralSearch_All                       6.69ms    6.82ms  -122µs      -1.8%
- BasicRangeCCC_All                       6.4ms 6.52ms  -121µs      -1.9%
- CaseInsensitiveCCC_All_Scalar           6.35ms    6.47ms  -116µs      -1.8%
- AnchoredNotFound_All_Scalar             9.56ms    9.68ms  -115µs      -1.2%
- HangulSyllable_All_Scalar               5.91ms    6.02ms  -112µs      -1.9%
- BasicCCC_All_Scalar                     5.93ms    6.04ms  -108µs      -1.8%
- HangulSyllable_First                    3.27ms    3.37ms  -92.4µs     -2.7%
- IntersectionCCC_All_Scalar              22ms  22.1ms  -89.7µs     -0.4%
- HangulSyllable_First_Scalar             2.84ms    2.92ms  -83.7µs     -2.9%
- HangulSyllable_All                      6.69ms    6.76ms  -78µs       -1.2%
- LiteralSearchNotFound_All               6.55ms    6.62ms  -68.8µs     -1.0%
- Lines_All_Scalar                        1.66ms    1.7ms   -44.8µs     -2.6%
- IPv4Address_Scalar                      2.05ms    2.1ms   -42.7µs     -2.0%
- DiceNotation                            4.51ms    4.55ms  -39.7µs     -0.9%
- DiceNotation_Scalar                     4.26ms    4.3ms   -37.7µs     -0.9%
- IPv6Address                             2.55ms    2.59ms  -35.5µs     -1.4%
- EmailLookaheadList_Scalar               3.66ms    3.69ms  -29.5µs     -0.8%
milseman commented 10 months ago

@swift-ci please test

milseman commented 10 months ago

This is now superseded by a larger PR that includes much more cleanup, refactoring, and preparation for more improvements.