-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
rowwise()
with a mutate() call with warnings is very slow
#6236
Comments
It has to do with the warnings. You get the same problem without any use of c_across:
|
I'm having this issue; it's fairly debilitating some code that use to run without issues. Is there any status update on this? |
Looks like it got slower after this pr. Example above goes from 1.6s to 15s for me and profvis shows all the time is spent in Goes to 0.05s if you change |
Minimal reprex: library(dplyr, warn.conflicts = FALSE)
df <- tibble(id = 1:100)
f <- function() {
warning()
1
}
bench::system_time(
df %>%
rowwise() %>%
mutate(x = f())
)
#> process real
#> 3s 3.6s (Note that you can't run this with the reprex package because something about the way rmarkdown handles warnings makes the problem go away) @lionel- could you take a look to see if there's any obvious way to speed up the warning wrapping in |
rowwise()
with a mutate() call with warnings is very slow
One possible way to go about this would be to collect warnings until all computations are done, and then emit the first few warnings and suggest to use something like Edit: Would also help with #6005. |
@lionel- I like that idea. |
Wooo, much faster now! library(dplyr, warn.conflicts = FALSE)
df <- tibble(id = 1:100)
f <- function() {
warning()
1
}
bench::system_time(
df %>%
rowwise() %>%
mutate(x = f())
)
#> Warning: There were 100 warnings in a `mutate()` step.
#> The first warning was:
#> ! Problem in row 1 while computing `x = f()`.
#> Caused by warning in `f()`:
#> ℹ Run `dplyr::last_dplyr_warnings()` to see the 99 remaining warnings.
#> process real
#> 66.8ms 65.8ms Created on 2022-09-21 with reprex v2.0.2 |
Sorry: has this been added to 1.0.10 yet? I'm not clear. How do I get this fix into my version of dplyr? |
@sjkiss it's in the dev version |
dplyr 1.1.2 is still slow on it |
@vak please file a new issue with reprex. |
As identified by @debruine here #6236 (comment) this issue is actually caused when mutate() is used after rowwise() and generates warnings.
This code takes ~11 seconds to run in a clean R session
Please note that weirdly the same code takes <1second when run with the {reprex} addin.
Many thanks to debruine for figuring this out.
The text was updated successfully, but these errors were encountered: