-
Notifications
You must be signed in to change notification settings - Fork 71
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
Remove unused transformers before processing #711
Merged
lorenzwalthert
merged 31 commits into
r-lib:master
from
lorenzwalthert:subset-transformers
Jan 25, 2021
Merged
Remove unused transformers before processing #711
lorenzwalthert
merged 31 commits into
r-lib:master
from
lorenzwalthert:subset-transformers
Jan 25, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report
@@ Coverage Diff @@
## master #711 +/- ##
==========================================
+ Coverage 90.49% 90.67% +0.17%
==========================================
Files 47 47
Lines 2273 2326 +53
==========================================
+ Hits 2057 2109 +52
- Misses 216 217 +1
Continue to review full report at Codecov.
|
Now we see it's working, we should do a real implementation This reverts commit f048a33.
lorenzwalthert
force-pushed
the
subset-transformers
branch
from
January 23, 2021 20:54
3061e30
to
4c1f95a
Compare
lorenzwalthert
changed the title
Benchmark study: remove edge case transformers
Remove unused transformers before processing
Jan 23, 2021
they will almost allways be present unless the expression is like 1+1 which is pretty quick to style anyways
…he element (instead of not assigning anything
lorenzwalthert
force-pushed
the
subset-transformers
branch
from
January 25, 2021 11:08
51a0fee
to
96ede0b
Compare
lorenzwalthert
force-pushed
the
subset-transformers
branch
from
January 25, 2021 18:56
578c491
to
3f3ab1c
Compare
This was referenced Mar 25, 2021
Open
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some transformers like the one turning
a;b
->a\nb
are rarely used, as the token;
rarely ocurrs in data. But we apply the associated transformerforce_assignment_op()
on every nest, knowing in advance that we'll never use it. This is expensive. There are quite some transformers that we know will be used infrequently. The idea of this PR is to extendcreate_style_guide()
to take a newsubset_transformer
transformers_drop
argument, which is a list that contains the names of the transformers and which token must be missing for the rule to be included in the final set of transformers used:If the parse table contains no
EQ_ASSIGN
token for example, theforce_asignment_op
transformer will be removed from the set of transformers before these are applied at every nest.Idea originated in #558 (comment).
Todo:
create_style_guide()
.create_style_guide()
.specify_*()
instead oflist()
as input forsubset_transformers()
.transformers_drop = specify_transformer_dropping()
NoohhHere is how a stupid removal of the edge case rules would change the timings:
Remove all edge case transformers (f048a33):
Bump CI (3fdea5a):
First draft implementation for touchstone (a87c7f9):
fix tests (6624000) (includes use more elegant approach with reduce and some tests):
bump CI (3061e30):
replace loop with walk for speed (3061e30):
resort to simple loop (4c1f95a):
loop 2, no material change (04c609c)
loop 3, no material change (781f796)
also include indent (f71deae):
another hack for old R version (5523a8f):
cache_applying: 0.04 -> 0.05 (18.7%)
cache_recording: 1.45 -> 1.97 (35.8%)
without_cache: 4.17 -> 3.62 (-13.2%)
if over ifelse (35976ef):
save another assignment (fd4440c):
get rid of condition that always holds (4e7d97f):
don't remove some transformers that won't ever be used (1b5498e):
cache_applying: 0.03 -> 0.03 (-7.2%)
cache_recording: 1.06 -> 0.95 (-10.4%)
without_cache: 3.07 -> 2.88 (-6.3%)
list is so much faster than lst (62ebd4b):
bump CI (b80a0f2):
can't use if condition in assignment because it will assign NULL to (c430adc):
cache_applying: 0.03 -> 0.03 (-18%)
cache_recording: 1 -> 0.94 (-6.3%)
without_cache: 2.96 -> 2.73 (-7.7%)
cache_applying: 0.03 -> 0.03 (-18.9%)
cache_recording: 0.99 -> 0.92 (-6.6%)
without_cache: 2.23 -> 2.08 (-6.6%)
more docs (96ede0b);
(4e8a248):
This is promising. Now we'll see if the overhead from filtering the rules is smaller so we are left with some interesting gain.
transformer_subset()
directly.subset_transformers
to beNULL
or similar.subset_transformers()
(must match names of rules).