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

perf(lexer): use portable-SIMD to speed up multiline comment scanning #23

Merged
merged 1 commit into from
Feb 20, 2023

Conversation

Boshen
Copy link
Member

@Boshen Boshen commented Feb 17, 2023

No description provided.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 17, 2023

Parser Benchmark Results

group                    main                                   pr
-----                    ----                                   --
parser/babylon.max.js    1.06    150.8±2.27ms    68.5 MB/sec    1.00    142.4±2.67ms    72.5 MB/sec
parser/d3.js             1.00     18.1±0.36ms    30.2 MB/sec    1.01     18.3±0.32ms    29.8 MB/sec
parser/lodash.js         1.24      6.4±0.13ms    80.5 MB/sec    1.00      5.1±0.12ms   100.2 MB/sec
parser/pdf.js            1.00     10.3±0.17ms    39.1 MB/sec    1.01     10.4±0.20ms    38.7 MB/sec
parser/typescript.js     1.00    143.9±2.59ms    66.9 MB/sec    1.00    143.8±2.32ms    66.9 MB/sec

@Boshen Boshen changed the title fix(lexer): fix simd multiline comment scanner with '*' on the boundary perf(lexer): use portable-SIMD to speed up multiline comment scanning Feb 20, 2023
@Boshen Boshen marked this pull request as draft February 20, 2023 09:27
@Boshen Boshen marked this pull request as ready for review February 20, 2023 13:57
@Boshen Boshen merged commit 83c3f34 into main Feb 20, 2023
@Boshen Boshen deleted the simd-multi branch February 20, 2023 13:58
@Boshen Boshen added this to the AST / Lexer / Parser milestone Feb 21, 2023
Comment on lines +150 to +151
let star_mask = any_star.to_bitmask();
let slash_mask = any_slash.to_bitmask();
Copy link
Contributor

Choose a reason for hiding this comment

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

I have found that to_bitmask on ARM NEON can be cause parsing to be slower compared to a scalar version. My block comment parser only uses SIMD on x86, not ARM. Do you run your benchmarks on ARM NEON or just Intel SSE?

On x86_64, to_bitmask is one instruction. On AArch64, there is no instruction and to_bitmask needs to be emulated. See: https://godbolt.org/z/531oEo5d1 It looks like the Rust compiler currently does a terrible job on AArch64. You can definitely do better by hand, but it still might not be faster than the scalar version.

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.

None yet

2 participants