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

Use rustc_lexer as fallback lexer #202

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

CAD97
Copy link

@CAD97 CAD97 commented Oct 7, 2019

Migrates the fallback parser to use rustc_lexer. WIP proof of concept currently.

Closes #201, closes #126, impacts #55, #5.

Failing tests:

@alexcrichton
Copy link
Contributor

FWIW one of the goals of this crate is to compile as fast as possible, so mind taking some measurements of that for both before/after this change? (build time afterwards including that of rustc_lexer

@CAD97
Copy link
Author

CAD97 commented Oct 7, 2019

Very unscientific test:

cad97@DESKTOP-HIBC3H1:/mnt/d/usr/Documents/Code/Rust/proc-macro2$ git.exe checkout master
Switched to branch 'master'
Your branch is up to date with 'upstream/master'.
cad97@DESKTOP-HIBC3H1:/mnt/d/usr/Documents/Code/Rust/proc-macro2$ cargo.exe clean
cad97@DESKTOP-HIBC3H1:/mnt/d/usr/Documents/Code/Rust/proc-macro2$ time cargo.exe build --release
   Compiling proc-macro2 v1.0.5 (D:\usr\Documents\Code\Rust\proc-macro2)
   Compiling unicode-xid v0.2.0
    Finished release [optimized] target(s) in 6.57s

real    0m6.678s
user    0m0.000s
sys     0m0.000s
cad97@DESKTOP-HIBC3H1:/mnt/d/usr/Documents/Code/Rust/proc-macro2$ git.exe checkout rustc_lexer
Switched to branch 'rustc_lexer'
Your branch is up to date with 'origin/rustc_lexer'.
cad97@DESKTOP-HIBC3H1:/mnt/d/usr/Documents/Code/Rust/proc-macro2$ time cargo.exe build --release
   Compiling rustc_lexer v0.1.0
   Compiling proc-macro2 v1.0.5 (D:\usr\Documents\Code\Rust\proc-macro2)
    Finished release [optimized] target(s) in 2.96s

real    0m3.036s
user    0m0.000s
sys     0m0.000s

So it looks like the removal of strnom is a notable benefit.

@CAD97
Copy link
Author

CAD97 commented Oct 7, 2019

Whoops, just realized I missed a cargo clean there, so here it is with a clean:

cad97@DESKTOP-HIBC3H1:/mnt/d/usr/Documents/Code/Rust/proc-macro2$ cargo.exe clean
cad97@DESKTOP-HIBC3H1:/mnt/d/usr/Documents/Code/Rust/proc-macro2$ time cargo.exe build --release
   Compiling unicode-xid v0.2.0
   Compiling proc-macro2 v1.0.5 (D:\usr\Documents\Code\Rust\proc-macro2)
   Compiling rustc_lexer v0.1.0
    Finished release [optimized] target(s) in 3.53s

real    0m3.598s
user    0m0.000s
sys     0m0.016s

(measurements done with beta-x86_64-pc-windows-gnu / rustc 1.39.0-beta.5 (fa5c2f3e5 2019-10-02))

@CAD97
Copy link
Author

CAD97 commented Oct 7, 2019

Second test (with procmacro2_semver_exempt) shows an increase, so it's probably all within noise without controlling better.

cad97@DESKTOP-HIBC3H1:/mnt/d/usr/Documents/Code/Rust/proc-macro2$ git checkout master
Switched to branch 'master'
Your branch is up to date with 'upstream/master'.
cad97@DESKTOP-HIBC3H1:/mnt/d/usr/Documents/Code/Rust/proc-macro2$ cargo.exe clean
cad97@DESKTOP-HIBC3H1:/mnt/d/usr/Documents/Code/Rust/proc-macro2$ RUSTFLAGS="--cfg procmacro2_semver_exempt" time cargo.exe build --release
   Compiling proc-macro2 v1.0.5 (D:\usr\Documents\Code\Rust\proc-macro2)
   Compiling unicode-xid v0.2.0
    Finished release [optimized] target(s) in 4.32s
0.00user 0.00system 0:04.39elapsed 0%CPU (0avgtext+0avgdata 232maxresident)k
0inputs+0outputs (0major+72minor)pagefaults 0swaps
cad97@DESKTOP-HIBC3H1:/mnt/d/usr/Documents/Code/Rust/proc-macro2$ git checkout rustc_lexer
Switched to branch 'rustc_lexer'
Your branch is up to date with 'origin/rustc_lexer'.
cad97@DESKTOP-HIBC3H1:/mnt/d/usr/Documents/Code/Rust/proc-macro2$ cargo.exe clean
cad97@DESKTOP-HIBC3H1:/mnt/d/usr/Documents/Code/Rust/proc-macro2$ RUSTFLAGS="--cfg procmacro2_semver_exempt" time cargo.exe build --release
    Updating crates.io index
   Compiling proc-macro2 v1.0.5 (D:\usr\Documents\Code\Rust\proc-macro2)
   Compiling unicode-xid v0.2.0
   Compiling rustc_lexer v0.1.0
    Finished release [optimized] target(s) in 5.19s
0.00user 0.00system 0:05.29elapsed 0%CPU (0avgtext+0avgdata 236maxresident)k
0inputs+0outputs (0major+72minor)pagefaults 0swaps

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.

Consider using rustc_lexer Optimize strnom::whitespace
2 participants