-
Notifications
You must be signed in to change notification settings - Fork 211
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
Parse whitespace more precisely #1483
Conversation
So far, the parser is still quite broken. For example:
|
1575a46
to
10740cc
Compare
@sjakobi: I pushed a change with some fixes that illustrates what went wrong. Many of the remaining fixes are due to the import parser needing to be fixed to not consume trailing whitespace |
Thanks a lot @Gabriel439! :) This is the last parser test failure:
There are a bunch of other test failures remaining though. |
CI should turn green now. I'll do some cleanup. |
A few test failures in dhall-lsp-server:
|
_arrow | ||
whitespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder whether we should add aliases whsp
and whsp1
to reduce the noise a bit.
@EggBaconAndSpam Do you have some advice on how to best update |
It took me way too long to figure out why my changes to
So you have to include the executable in the targets and run
😱 😱 😱 |
I've modified |
While looking at
My understanding is that this should be the type of
Shouldn't the type be
then? (CC @mujx) |
@sjakobi: It's a bug in |
@Gabriel439 I have made a new issue for this: #1510 Would you mind giving this a final review, so we can get this merged? |
parseDirectory </> "failure/unit/ImportEnvWrongEscape.dhall" | ||
|
||
-- Other spacing related unexpected successes: | ||
, parseDirectory </> "failure/spacing/AnnotationNoSpace.dhall" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's great that these are finally fixed! 🙂
7c622cb
to
42e7240
Compare
I remembered that we should look at the performance impact: I've benchmarked
|
, benchExprFromText "Line comment" ("x -- " <> T.replicate 1000000 " ") | |
, benchExprFromText "Block comment" ("x {- " <> T.replicate 1000000 " " <> "-}") |
master
benchmarked Line comment
time 11.86 ms (11.69 ms .. 11.98 ms)
0.999 R² (0.999 R² .. 1.000 R²)
mean 11.84 ms (11.79 ms .. 11.89 ms)
std dev 129.4 μs (107.2 μs .. 164.1 μs)
benchmarked Block comment
time 13.20 ms (13.00 ms .. 13.41 ms)
0.999 R² (0.998 R² .. 1.000 R²)
mean 13.59 ms (13.41 ms .. 13.94 ms)
std dev 600.0 μs (142.2 μs .. 953.7 μs)
variance introduced by outliers: 15% (moderately inflated)
This branch
benchmarked Line comment
time 228.6 ms (225.6 ms .. 231.1 ms)
1.000 R² (0.999 R² .. 1.000 R²)
mean 230.3 ms (228.9 ms .. 233.8 ms)
std dev 3.631 ms (1.668 ms .. 5.820 ms)
benchmarking Block comment ... took 14.31 s, total 56 iterations
benchmarked Block comment
time 260.9 ms (234.1 ms .. 298.2 ms)
0.976 R² (0.940 R² .. 0.997 R²)
mean 255.3 ms (243.2 ms .. 273.0 ms)
std dev 25.54 ms (17.55 ms .. 35.68 ms)
variance introduced by outliers: 29% (moderately inflated)
This got about 20x slower!
@sjakobi: The reason it is slower is because of backtracking. After it parses the This can be fixed by left-factoring the parsers so that they no longer need to wrap the |
Right. Is this good to merge anyways or do you want to try left-factoring it first? I suspect that I won't be of much help with the parser performance. :/ |
@sjakobi: You can go ahead and merge. I can work on the parsing performance |
This undoes some of the performance regression introduced in #1483 Before #1483: ``` benchmarked Line comment time 11.86 ms (11.69 ms .. 11.98 ms) 0.999 R² (0.999 R² .. 1.000 R²) mean 11.84 ms (11.79 ms .. 11.89 ms) std dev 129.4 μs (107.2 μs .. 164.1 μs) benchmarked Block comment time 13.20 ms (13.00 ms .. 13.41 ms) 0.999 R² (0.998 R² .. 1.000 R²) mean 13.59 ms (13.41 ms .. 13.94 ms) std dev 600.0 μs (142.2 μs .. 953.7 μs) ``` After #1483: ``` benchmarked Line comment time 288.7 ms (282.8 ms .. 294.7 ms) 1.000 R² (0.999 R² .. 1.000 R²) mean 292.3 ms (290.8 ms .. 294.6 ms) std dev 3.156 ms (2.216 ms .. 4.546 ms) benchmarked Block comment time 286.2 ms (280.9 ms .. 292.6 ms) 0.999 R² (0.998 R² .. 1.000 R²) mean 290.6 ms (288.3 ms .. 292.9 ms) std dev 3.875 ms (2.866 ms .. 5.500 ms) ``` After this change: ``` benchmarked Line comment time 61.44 ms (60.37 ms .. 63.03 ms) 0.999 R² (0.997 R² .. 1.000 R²) mean 61.41 ms (60.74 ms .. 62.25 ms) std dev 1.341 ms (945.0 μs .. 1.901 ms) benchmarked Block comment time 61.83 ms (60.97 ms .. 63.14 ms) 0.999 R² (0.998 R² .. 1.000 R²) mean 61.16 ms (60.33 ms .. 61.85 ms) std dev 1.396 ms (1.011 ms .. 1.907 ms) ```
* Partially fix whitespace parsing performance regression This undoes some of the performance regression introduced in #1483 Before #1483: ``` benchmarked Line comment time 11.86 ms (11.69 ms .. 11.98 ms) 0.999 R² (0.999 R² .. 1.000 R²) mean 11.84 ms (11.79 ms .. 11.89 ms) std dev 129.4 μs (107.2 μs .. 164.1 μs) benchmarked Block comment time 13.20 ms (13.00 ms .. 13.41 ms) 0.999 R² (0.998 R² .. 1.000 R²) mean 13.59 ms (13.41 ms .. 13.94 ms) std dev 600.0 μs (142.2 μs .. 953.7 μs) ``` After #1483: ``` benchmarked Line comment time 288.7 ms (282.8 ms .. 294.7 ms) 1.000 R² (0.999 R² .. 1.000 R²) mean 292.3 ms (290.8 ms .. 294.6 ms) std dev 3.156 ms (2.216 ms .. 4.546 ms) benchmarked Block comment time 286.2 ms (280.9 ms .. 292.6 ms) 0.999 R² (0.998 R² .. 1.000 R²) mean 290.6 ms (288.3 ms .. 292.9 ms) std dev 3.875 ms (2.866 ms .. 5.500 ms) ``` After this change: ``` benchmarked Line comment time 61.44 ms (60.37 ms .. 63.03 ms) 0.999 R² (0.997 R² .. 1.000 R²) mean 61.41 ms (60.74 ms .. 62.25 ms) std dev 1.341 ms (945.0 μs .. 1.901 ms) benchmarked Block comment time 61.83 ms (60.97 ms .. 63.14 ms) 0.999 R² (0.998 R² .. 1.000 R²) mean 61.16 ms (60.33 ms .. 61.85 ms) std dev 1.396 ms (1.011 ms .. 1.907 ms) ``` * Correctly parse `https://example.com usingBla` ... as caught by @sjakobi
This is preparatory work for #1454.