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

Compress operator parsing hierarchy #601

Merged
merged 1 commit into from
Sep 27, 2018

Conversation

Gabriella439
Copy link
Collaborator

This groups operators that work on different types into a single precedence
level to improve parsing performance. Parsing the precedence of these groups
of operators incorrectly doesn't matter since any expression that mixes them is
ill-typed

This improves performance by about 15% on the benchmark expression from #108

Before:

time                 334.4 ms   (308.6 ms .. 375.3 ms)
                     0.998 R²   (0.995 R² .. 1.000 R²)
mean                 349.8 ms   (340.4 ms .. 364.3 ms)
std dev              14.35 ms   (5.761 ms .. 19.71 ms)
variance introduced by outliers: 19% (moderately inflated)

After:

time                 289.9 ms   (274.6 ms .. 297.9 ms)
                     0.999 R²   (0.998 R² .. 1.000 R²)
mean                 309.3 ms   (301.0 ms .. 318.3 ms)
std dev              11.08 ms   (8.083 ms .. 14.31 ms)

This groups operators that work on different types into a single precedence
level to improve parsing performance.  Parsing the precedence of these groups
of operators incorrectly doesn't matter since any expression that mixes them is
ill-typed

This improves performance by about 15% on the benchmark expression from #108

Before:

```
time                 334.4 ms   (308.6 ms .. 375.3 ms)
                     0.998 R²   (0.995 R² .. 1.000 R²)
mean                 349.8 ms   (340.4 ms .. 364.3 ms)
std dev              14.35 ms   (5.761 ms .. 19.71 ms)
variance introduced by outliers: 19% (moderately inflated)
```

After:

```
time                 289.9 ms   (274.6 ms .. 297.9 ms)
                     0.999 R²   (0.998 R² .. 1.000 R²)
mean                 309.3 ms   (301.0 ms .. 318.3 ms)
std dev              11.08 ms   (8.083 ms .. 14.31 ms)
```
@Gabriella439
Copy link
Collaborator Author

Note that I also tried using Text.Parser.Expression.buildOperatorExpression as well and that made things slower (even slower than the original code)

@Gabriella439
Copy link
Collaborator Author

This also improves heap residency, which goes down from ~5.5 MB to ~4 MB

@Gabriella439 Gabriella439 merged commit 98d4089 into master Sep 27, 2018
@Gabriella439 Gabriella439 deleted the gabriel/consolidate_operator_precedence branch September 27, 2018 00:17
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

1 participant