-
Notifications
You must be signed in to change notification settings - Fork 81
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
Some operations are much slower than base #295
Comments
Performance was not a specific goal of fs. In general In this particular case the performance difference is exacerbated because the implementation of tibble construction does seem to cause non-negligible slowdown, perhaps it would be worth adding an option so it could be disabled for performance critical code. |
Construction of tibbles can add non-negligible overhead to some operations, so we now support an option to disable them for performance critical code. Part of #295
In the library(fs)
system.time({
for (i in 1:1000) file_exists('DESCRIPTION')
})
#> user system elapsed
#> 0.018 0.002 0.020
system.time({
for (i in 1:1000) file.exists('DESCRIPTION')
})
#> user system elapsed
#> 0.002 0.001 0.003 Created on 2020-09-18 by the reprex package (v0.3.0) I don't think it is really possible to get much faster, as I said we start running into |
|
For example:
Similarly, replacing an instance of
dir_copy
with equivalent base code results in a significant speedup. For this test, the time spent in the copying code went from 370ms to 10ms. This is a real-world case where the speed impact is noticeable. rstudio/sass#53It is harder to get the code right with base functions, so it would be nice to use fs.
Sorry this isn't more specific about exactly which operations are slow. However, when I profiled it, it looked like a lot of time for
file_exists
was spent dealing with tibbles. (Note that it had to be profiled on R 3.6, since the profiler in R 4.0 has a bug and doesn't generate useful data.)The text was updated successfully, but these errors were encountered: