Skip to content

Speed up processor initialization #789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2024
Merged

Conversation

milseman
Copy link
Member

@milseman milseman commented Nov 9, 2024

Moves register initialization to the program where it can be done once. Speeds
up use cases where the same regex is applied to many small inputs.

@milseman milseman requested a review from natecook1000 November 9, 2024 19:05
@milseman
Copy link
Member Author

milseman commented Nov 9, 2024

Perf improvements on top of #787

Comparing against saved benchmark result before_me_registers
=== Regressions ======================================================================
- DiceRollsInText_All                     28.8ms	28.5ms	255µs		0.9%
- DiceRollsInText_All_Scalar              27.2ms	27ms	161µs		0.6%
- LiteralSearchNotFound_All_Scalar        1.71ms	1.62ms	85.9µs		5.3%
- LiteralSearch_All                       2.65ms	2.58ms	76.6µs		3.0%
- LiteralSearch_All_Scalar                1.71ms	1.66ms	51.5µs		3.1%
=== Improvements =====================================================================
- CompilerMessages_All_Scalar             74.6ms	77.3ms	-2.68ms		-3.5%
- CompilerMessages_All                    83.8ms	85ms	-1.25ms		-1.5%
- EmojiRegex_All                          75.6ms	76.7ms	-1.03ms		-1.3%
- InvertedCCC_All                         5.73ms	6.72ms	-986µs		-14.7%
- EmailLookaheadNoMatches_All_Scalar      18.4ms	19.3ms	-904µs		-4.7%
- InvertedCCC_All_Scalar                  5.69ms	6.54ms	-842µs		-12.9%
- DiceNotation                            3.59ms	4.37ms	-780µs		-17.9%
- DiceNotation_Scalar                     3.46ms	4.22ms	-757µs		-17.9%
- FSPathsRegexFound_Scalar                2.99ms	3.7ms	-711µs		-19.2%
- FSPathsRegex                            3.35ms	4.05ms	-698µs		-17.2%
- FSPathsRegex_Scalar                     3.25ms	3.93ms	-675µs		-17.2%
- FSPathsRegexFound                       3.07ms	3.74ms	-674µs		-18.0%
- FSPathsRegexNotFound                    3.09ms	3.73ms	-643µs		-17.2%
- EmailLookaheadList                      3.5ms	4.14ms	-640µs		-15.5%
- EmailLookaheadList_Scalar               3.38ms	4.02ms	-636µs		-15.8%
- FSPathsRegexNotFound_Scalar             3ms	3.6ms	-605µs		-16.8%
- MACAddress                              1.88ms	2.41ms	-526µs		-21.9%
- IPv4Address                             1.57ms	2.08ms	-513µs		-24.7%
- IPv4Address_Scalar                      1.5ms	2ms	-504µs		-25.2%
- IPv6Address                             1.94ms	2.44ms	-501µs		-20.5%
- MACAddress_Scalar                       1.84ms	2.34ms	-500µs		-21.4%
- IPv6Address_Scalar                      1.82ms	2.32ms	-492µs		-21.2%
- EmailRFCNoMatches_All_Scalar            43.2ms	43.7ms	-470µs		-1.1%
- EmailRFCNoMatches_All                   45.3ms	45.8ms	-463µs		-1.0%
- EmailLookaheadNoMatches_All             20.1ms	20.5ms	-440µs		-2.1%
- EmailRFC_All_Scalar                     30.4ms	30.8ms	-415µs		-1.3%
- EmailRFC_All                            31ms	31.3ms	-318µs		-1.0%
- symDiffCCC_All                          16.1ms	16.4ms	-298µs		-1.8%
- SubtractionCCC_All_Scalar               5.47ms	5.73ms	-260µs		-4.5%
- SubtractionCCC_All                      5.47ms	5.73ms	-253µs		-4.4%
- Words_All                               4.64ms	4.88ms	-243µs		-5.0%
- BasicBuiltinCharacterClass_All_Scalar   2.39ms	2.61ms	-227µs		-8.7%
- symDiffCCC_All_Scalar                   16.2ms	16.4ms	-206µs		-1.3%
- AnchoredNotFound_All_Scalar             5.7ms	5.88ms	-183µs		-3.1%
- EmailBuiltinCharacterClass_All_Scalar   8.71ms	8.9ms	-182µs		-2.0%
- Words_All_Scalar                        4.54ms	4.71ms	-165µs		-3.5%
- ReluctantQuantWithTerminal_Whole_Scalar 5.68ms	5.82ms	-147µs		-2.5%
- BasicRangeCCC_All                       2.97ms	3.11ms	-144µs		-4.6%
- EmailBuiltinCharacterClass_All          8.85ms	8.98ms	-130µs		-1.4%
- AnchoredNotFound_First                  7.94ms	8.07ms	-125µs		-1.6%
- AnchoredNotFound_All                    7.94ms	8.07ms	-121µs		-1.5%
- BasicRangeCCC_All_Scalar                2.97ms	3.09ms	-121µs		-3.9%
- ReluctantQuantWithTerminal_Whole        5.71ms	5.83ms	-115µs		-2.0%
- ReluctantQuant_Whole                    3.37ms	3.48ms	-112µs		-3.2%
- ReluctantQuant_Whole_Scalar             3.37ms	3.48ms	-112µs		-3.2%
- EmailLookahead_All_Scalar               17.5ms	17.6ms	-106µs		-0.6%
- BasicCCC_All                            2.84ms	2.94ms	-106µs		-3.6%
- BasicCCC_All_Scalar                     2.84ms	2.94ms	-98.5µs		-3.4%
- CaseInsensitiveCCC_All_Scalar           3.17ms	3.27ms	-95.4µs		-2.9%
- CaseInsensitiveCCC_All                  3.17ms	3.27ms	-94.1µs		-2.9%
- EmailLookahead_All                      18.6ms	18.7ms	-82.1µs		-0.4%
- HangulSyllable_All                      2.6ms	2.67ms	-74µs		-2.8%
- HangulSyllable_All_Scalar               1.88ms	1.95ms	-72.3µs		-3.7%
- Numbers_All_Scalar                      2.04ms	2.11ms	-72µs		-3.4%
- IntersectionCCC_All                     5.09ms	5.15ms	-64.3µs		-1.2%
- Lines_All_Scalar                        763µs	823µs	-60.2µs		-7.3%
- GraphemeBreakNoCap_All                  1.58ms	1.64ms	-54.2µs		-3.3%
- GraphemeBreakNoCap_All_Scalar           1.52ms	1.57ms	-54µs		-3.4%
- BasicBuiltinCharacterClass_All          3.04ms	3.09ms	-45.4µs		-1.5%
- Lines_All                               806µs	847µs	-41.3µs		-4.9%
- Numbers_All                             2.55ms	2.57ms	-19.1µs		-0.7%
- Css_All_Scalar                          2.07ms	2.09ms	-19.1µs		-0.9%
- IntersectionCCC_All_Scalar              5.08ms	5.1ms	-16.8µs		-0.3%
- Css_All                                 2.31ms	2.32ms	-14.9µs		-0.6%
- URLWithWordBoundaries_All               1.75ms	1.76ms	-11.7µs		-0.7%
- URLWithWordBoundaries_All_SimpleWordBoundaries 555µs	558µs	-3.33µs		-0.6%

@milseman
Copy link
Member Author

milseman commented Nov 9, 2024

(Part of this speedup is we happen to now hit a happy path where a lot of the ARC gets eliminated.)

@milseman
Copy link
Member Author

@swift-ci please test

Moves register initialization to the program where it can be done once. Speeds
up use cases where the same regex is applied to many small inputs.
@milseman
Copy link
Member Author

@swift-ci please test

@milseman milseman merged commit a7592d9 into swiftlang:main Dec 14, 2024
3 checks passed
@milseman milseman deleted the init_faster branch December 14, 2024 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant