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

Add separate enum for Tag ends #517

Merged
merged 16 commits into from
May 20, 2023

Conversation

marcusklaas
Copy link
Collaborator

Currently on master, all tag details are provided in both tag start and tag end events. For tags that contain allocated details like links, images and tables, this involves a lot of cloning. For most foreseeable use cases (such as HTML rendering), such details are only needed at tag start.

This PR introduces a different enum for tag ends that do not include any allocated tag details. For some tags like tables, this saves not one but two heap allocations per tag. Since the end tag won't include any details, the start tag can 'destructively' take the alignments vector from the allocation structure instead of cloning it.

Of course there are trade-offs. This is a breaking change, and it does add a little complexity (having the same data for tag opens and closes is conceptually satisfying). On the other hand, it does bring us closer to the project's ideals of high performance and avoiding unnecessary copies.

Below are some benchmarks of the current master compared to this branch (so a performance regression below is really a speedup!). The speedup seems to be between 5-10% overall.

crdt_total              time:   [357.33 us 357.66 us 358.04 us]                       
                        change: [+0.5834% +1.8516% +3.0928%] (p = 0.00 < 0.05)
                        Change within noise threshold.
Found 10 outliers among 100 measurements (10.00%)
  2 (2.00%) high mild
  8 (8.00%) high severe

crdt_html               time:   [149.75 us 149.88 us 150.02 us]                      
                        change: [+5.8839% +6.8578% +7.7651%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 10 outliers among 100 measurements (10.00%)
  2 (2.00%) high mild
  8 (8.00%) high severe

crdt_all_options_parse  time:   [264.94 us 266.59 us 269.49 us]                                   
                        change: [+3.1741% +5.4169% +7.2449%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 12 outliers among 100 measurements (12.00%)
  1 (1.00%) high mild
  11 (11.00%) high severe

crdt_parse              time:   [225.43 us 226.34 us 228.00 us]                       
                        change: [+3.2769% +5.4859% +7.7806%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 11 outliers among 100 measurements (11.00%)
  5 (5.00%) high mild
  6 (6.00%) high severe

smart_punctuation       time:   [2.5907 us 2.6083 us 2.6404 us]                               
                        change: [+5.0718% +7.1628% +9.5700%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 8 outliers among 100 measurements (8.00%)
  2 (2.00%) high mild
  6 (6.00%) high severe

links_n_emphasis        time:   [3.9355 us 3.9555 us 3.9871 us]                              
                        change: [+8.0929% +10.634% +13.465%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 16 outliers among 100 measurements (16.00%)
  5 (5.00%) high mild
  11 (11.00%) high severe

unescapes               time:   [12.983 us 13.042 us 13.151 us]                       
                        change: [+1.8415% +3.5265% +5.4521%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 11 outliers among 100 measurements (11.00%)
  5 (5.00%) high mild
  6 (6.00%) high severe

autolinks_n_html        time:   [4.8882 us 4.8931 us 4.8984 us]                              
                        change: [+3.3852% +4.7612% +6.0857%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 9 outliers among 100 measurements (9.00%)
  3 (3.00%) high mild
  6 (6.00%) high severe

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.

2 participants