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

fix(html/parser): perf and fixes #6543

Merged
merged 22 commits into from Dec 1, 2022

Conversation

alexander-akait
Copy link
Collaborator

@alexander-akait alexander-akait commented Nov 30, 2022

Description:

Here:

  • perf improvement - avoid new string allocation and use only two buffers
  • fix broken span in recovery mode
  • fix bug with raw and newlines in attribute values
  • simplify code - avoid using LexResult where it is unnecessary
  • update tests

Perf:

Benchmarking html/parser_document/css_2021_spec: Collecting 100 samples in estimated 5.0453 s (200 itera                                                                                                        html/parser_document/css_2021_spec                        
                        time:   [24.893 ms 24.993 ms 25.102 ms]
                        change: [-9.3727% -8.5518% -7.7744%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 9 outliers among 100 measurements (9.00%)
  6 (6.00%) high mild
  3 (3.00%) high severe

Benchmarking html/parser_document/github_com_17_05_2022: Collecting 100 samples in estimated 5.6538 s (6                                                                                                        html/parser_document/github_com_17_05_2022                        
                        time:   [9.3805 ms 9.4121 ms 9.4473 ms]
                        change: [-12.224% -10.727% -9.2354%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 6 outliers among 100 measurements (6.00%)
  4 (4.00%) high mild
  2 (2.00%) high severe

Benchmarking html/parser_document/stackoverflow_com_17_05_2022: Collecting 100 samples in estimated 5.03                                                                                                        html/parser_document/stackoverflow_com_17_05_2022                        
                        time:   [8.3459 ms 8.4242 ms 8.5158 ms]
                        change: [-12.482% -10.492% -8.5345%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 9 outliers among 100 measurements (9.00%)
  6 (6.00%) high mild
  3 (3.00%) high severe

Benchmarking html/parser_document_fragment/css_2021_spec: Collecting 100 samples in estimated 5.0795 s (                                                                                                        html/parser_document_fragment/css_2021_spec                        
                        time:   [24.988 ms 25.257 ms 25.612 ms]
                        change: [-7.4636% -6.3417% -5.0886%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 14 outliers among 100 measurements (14.00%)
  6 (6.00%) high mild
  8 (8.00%) high severe

Benchmarking html/parser_document_fragment/github_com_17_05_2022: Collecting 100 samples in estimated 5.                                                                                                        html/parser_document_fragment/github_com_17_05_2022                        
                        time:   [9.4571 ms 9.5606 ms 9.6936 ms]
                        change: [-3.2604% -2.2218% -0.6482%] (p = 0.00 < 0.05)
                        Change within noise threshold.
Found 15 outliers among 100 measurements (15.00%)
  7 (7.00%) high mild
  8 (8.00%) high severe

Benchmarking html/parser_document_fragment/stackoverflow_com_17_05_2022: Collecting 100 samples in estim                                                                                                        html/parser_document_fragment/stackoverflow_com_17_05_2022                        
                        time:   [8.4049 ms 8.4661 ms 8.5385 ms]
                        change: [-5.4380% -4.3263% -3.2211%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 6 outliers among 100 measurements (6.00%)
  4 (4.00%) high mild
  2 (2.00%) high severe

BREAKING CHANGE:

Yes, if you will use Lexer directly

Related issue (if exists):

No

@@ -3,31 +3,31 @@
,-[$DIR/tests/recovery/attribute/duplicate/input.html:6:1]
6 | <body>
7 | <div class="test" class="test-1" class="test-2"></div>
: ^^^^^^^^^^^^^^
: ^^^^^
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use only attribute name for error reporting

@alexander-akait alexander-akait marked this pull request as draft November 30, 2022 02:39
@alexander-akait alexander-akait marked this pull request as ready for review November 30, 2022 04:12
@kdy1 kdy1 self-assigned this Nov 30, 2022
@kdy1 kdy1 added this to the Planned milestone Nov 30, 2022
@alexander-akait
Copy link
Collaborator Author

@kdy1 Ready for review, there are many changes, but most of them just rewriting String::new()/String::with_capacity(number) on buffers

Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!


swc-bump:

  • swc_html_parser

@kdy1 kdy1 enabled auto-merge (squash) December 1, 2022 04:44
Copy link
Collaborator

@swc-bot swc-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment generated by auto-rebase script

@kdy1 kdy1 merged commit 49b7e9e into swc-project:main Dec 1, 2022
@alexander-akait alexander-akait deleted the perf-html-parser branch December 1, 2022 14:37
@kdy1 kdy1 modified the milestones: Planned, v1.3.22 Dec 9, 2022
@swc-project swc-project locked as resolved and limited conversation to collaborators Jan 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants