Skip to content
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

[Experiment] Trivialize save points #688

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

milseman
Copy link
Member

Make SavePoint a trivial value rather than one containing strong references.

@milseman
Copy link
Member Author

Long-term we want to move in this direction, but it will take some significant progress elsewhere before it makes sense. Currently yields lots of regressions.

=== Regressions ======================================================================
- EmailRFCNoMatches_All_Scalar            138ms	126ms	12.3ms		9.8%
- EmailRFC_All_Scalar                     55.8ms	47ms	8.78ms		18.7%
- EmailRFC_All                            72.1ms	63.7ms	8.45ms		13.3%
- EmailRFCNoMatches_All                   149ms	142ms	7.32ms		5.1%
- EmojiRegex_All_Scalar                   57ms	49.9ms	7.04ms		14.1%
- DiceRollsInText_All                     53.3ms	47ms	6.23ms		13.2%
- EmojiRegex_All                          79.2ms	73ms	6.17ms		8.5%
- DiceRollsInText_All_Scalar              50.4ms	44.3ms	6.16ms		13.9%
- IntersectionCCC_All_Scalar              23.7ms	21.9ms	1.8ms		8.2%
- IntersectionCCC_All                     23.7ms	21.9ms	1.8ms		8.2%
- SubtractionCCC_All                      23.2ms	21.4ms	1.79ms		8.4%
- SubtractionCCC_All_Scalar               23.1ms	21.5ms	1.69ms		7.9%
- EmailBuiltinCharacterClass_All_Scalar   13.8ms	12.6ms	1.27ms		10.1%
- EmailBuiltinCharacterClass_All          14ms	12.7ms	1.26ms		9.9%
- ReluctantQuant_Whole_Scalar             11.9ms	10.6ms	1.23ms		11.5%
- ReluctantQuant_Whole                    11.9ms	10.7ms	1.2ms		11.3%
- EmailLookahead_All_Scalar               23.8ms	22.7ms	1.14ms		5.0%
- symDiffCCC_All                          50.8ms	49.7ms	1.1ms		2.2%
- HangulSyllable_All_Scalar               7.47ms	6.38ms	1.09ms		17.1%
- EmailLookaheadNoMatches_All             42.3ms	41.3ms	1.02ms		2.5%
- BasicBuiltinCharacterClass_All          9.38ms	8.41ms	969µs		11.5%
- NotFound_All_Scalar                     7.45ms	6.51ms	942µs		14.5%
- EmailLookahead_All                      41.2ms	40.3ms	936µs		2.3%
- symDiffCCC_All_Scalar                   50.7ms	49.8ms	918µs		1.8%
- BasicBuiltinCharacterClass_All_Scalar   8.65ms	7.78ms	863µs		11.1%
- BasicCCC_All                            11.5ms	10.7ms	845µs		7.9%
- HangulSyllable_All                      7.97ms	7.12ms	843µs		11.8%
- ReluctantQuantWithTerminal_Whole        7.5ms	6.66ms	837µs		12.6%
- LiteralSearchNotFound_All_Scalar        6.78ms	5.96ms	820µs		13.8%
- LiteralSearch_All_Scalar                7.01ms	6.2ms	816µs		13.2%
- NotFound_All                            8.18ms	7.37ms	811µs		11.0%
- LiteralSearchNotFound_All               7.54ms	6.76ms	783µs		11.6%
- LiteralSearch_All                       7.75ms	6.98ms	771µs		11.1%
- EmailLookaheadNoMatches_All_Scalar      28.7ms	28ms	739µs		2.6%
- ReluctantQuantWithTerminal_Whole_Scalar 7.46ms	6.75ms	712µs		10.6%
- CaseInsensitiveCCC_All                  12.5ms	11.8ms	632µs		5.3%
- DiceNotation_Scalar                     5.29ms	4.66ms	628µs		13.5%
- BasicCCC_All_Scalar                     11.3ms	10.7ms	609µs		5.7%
- CaseInsensitiveCCC_All_Scalar           12.4ms	11.8ms	607µs		5.1%
- BasicRangeCCC_All                       11.7ms	11.1ms	578µs		5.2%
- BasicRangeCCC_All_Scalar                11.7ms	11.1ms	574µs		5.2%
- DiceNotation                            5.58ms	5.03ms	547µs		10.9%
- HangulSyllable_First                    3.85ms	3.41ms	440µs		12.9%
- HangulSyllable_First_Scalar             3.49ms	3.06ms	433µs		14.2%
- Words_All_Scalar                        13.5ms	13.1ms	371µs		2.8%
- EmailLookaheadList                      10ms	9.66ms	348µs		3.6%
- Numbers_All                             7.52ms	7.17ms	344µs		4.8%
- InvertedCCC_All                         20.9ms	20.6ms	332µs		1.6%
- MACAddress_Scalar                       2.82ms	2.5ms	320µs		12.8%
- EmailLookaheadList_Scalar               5.54ms	5.22ms	314µs		6.0%
- MACAddress                              3.19ms	2.89ms	301µs		10.4%
- Words_All                               13.9ms	13.7ms	257µs		1.9%
- Numbers_All_Scalar                      6.97ms	6.73ms	245µs		3.6%
- IPv6Address_Scalar                      3.02ms	2.8ms	221µs		7.9%
- IPv4Address_Scalar                      2.45ms	2.25ms	206µs		9.2%
- Css_All_Scalar                          3.39ms	3.23ms	163µs		5.0%
- IPv6Address                             4.06ms	3.9ms	160µs		4.1%
- IPv4Address                             2.67ms	2.52ms	153µs		6.1%
- Css_All                                 3.9ms	3.78ms	126µs		3.3%
- Lines_All_Scalar                        1.83ms	1.78ms	50.1µs		2.8%
- Lines_All                               1.88ms	1.84ms	40.7µs		2.2%
=== Improvements =====================================================================
- CompilerMessages_All_Scalar             79.1ms	85.4ms	-6.26ms		-7.3%
- CompilerMessages_All                    96.1ms	102ms	-5.98ms		-5.9%
- EagarQuantWithTerminal_Whole            793µs	1.42ms	-626µs		-44.1%
- EagarQuantWithTerminal_Whole_Scalar     789µs	1.4ms	-607µs		-43.5%
- AnchoredNotFound_Whole                  8.8ms	8.9ms	-107µs		-1.2%
- GraphemeBreakNoCap_All_Scalar           3.62ms	3.72ms	-98.8µs		-2.7%
- AnchoredNotFound_Whole_Scalar           5.58ms	5.67ms	-91µs		-1.6%
- GraphemeBreakNoCap_All                  4.24ms	4.31ms	-71.8µs		-1.7%

Things to address:

  • Quantified save points need an overhaul
    • We create save points that we never push back
    • Instead we should just locally update a range
    • This is what I'm looking at next
  • Bookkeeping logic to share saved states across saved points
    • Don't push if there's been no mutating in state
    • On restore, don't pop if still being used by some save point
    • Consider per-capture indices, per-register-bank indices, etc.
  • Tweaks
    • Optimizer can be especially finicky around ARC, especially as we migrate to structs and the inside of signalFailure()
      • This was the reason we have destructure rather than member access
    • Improve code layout so that a save point fits in a few words
    • Get off of mutable integer registers and/or COW them differently
  • Further architectural/design work around unique values
    • Look into ~Copyable or ~Escaping types and non-escaping parameters
    • Shrink Processor or otherwise eliminate struct copies and retains

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