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

update the progress bar only 20 times per second #1734

Merged
merged 2 commits into from
Mar 23, 2016
Merged

update the progress bar only 20 times per second #1734

merged 2 commits into from
Mar 23, 2016

Conversation

mkuhn
Copy link
Contributor

@mkuhn mkuhn commented Mar 23, 2016

I noticed that RStudio has a high CPU load while running do on data frames with many groups and short operations. I traced this to the fact that the progress bar is re-drawn for each tick, even if it hasn't changed since the last update.

I therefore added a check for when the progress bar has been drawn the last time, and update only if this is more than 50 ms ago. A simple test revealed that this can save a lot of overhead without noticeable changes (first run: normal dplyr, second run: with last_update check):

> d <- data.frame(x=1:100000)
> system.time(invisible(d %>% group_by(x) %>% do(x=0)))
|==========================================================================================|100% ~0 s remaining        
user  system elapsed
 33.535   2.976  28.715 

Restarting R session...

> library(dplyr)
> system.time(invisible(d %>% group_by(x) %>% do(x=0)))
|========================================================================================= | 99% ~0 s remaining
user  system elapsed 
  3.845   0.109   4.009 

@hadley
Copy link
Member

hadley commented Mar 23, 2016

Ooops. Thanks for the fix!

Could you please also add a bullet to NEWS?

@mkuhn
Copy link
Contributor Author

mkuhn commented Mar 23, 2016

You're welcome! I added a line to NEWS.md.

@mkuhn
Copy link
Contributor Author

mkuhn commented Mar 23, 2016

The Travis build failed early on something unrelated:

Downloading GitHub repo hadley/testthat@master
from URL https://api.github.com/repos/hadley/testthat/zipball/master
Error in download(dest, src, auth) : Forbidden (HTTP 403).
Calls: <Anonymous> ... remote_download.github_remote -> download -> <Anonymous>
Execution halted

@hadley hadley merged commit a7528c2 into tidyverse:master Mar 23, 2016
@hadley
Copy link
Member

hadley commented Mar 23, 2016

Awesome - thanks!

@lock
Copy link

lock bot commented Jan 19, 2019

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants