ggsave taking long - is Rstudio cloud super fast or is something perhaps wrong with my local machines?

SOLVED: I changed device to Cairo, ran in 1.2secs

ggsave(
  filename = filename,
  path = here("img"),
  plot = art_pic,
  width = pixels_wide/300,
  height = pixels_high/300,
  dpi = 300,
  type = "cairo"
)

UPDATE: I'm hearing that the issue is known as Windows being slow with graphics devices. I will also be testing if there's any improvement in speed using device=cairo

I'm trying to narrow down my issue. Should I expect that ggsave can be super fast on Rstudio cloud whereas it might be MUCH slower on my local machine?

Ive looked at this issue and its not the same thing from what I can tell: ggsave very slow

When running this project in Rstudio cloud, the ggsave takes about 1.5 seconds:

But when running the same code on either of my Windows laptops, the save takes so long, many minutes at least, that I've terminated R instead of waiting for it to save. I mananged to get it to save on the one machine, but took ~1200 seconds to do so.

I have tested on my machine with a very simple plot and it does render and save correctly.

I've tested this on two systems, both running Windows 10.

The one has Rstudio 1.4.x, 8GB of ram and lowly intel graphics card of some sort
The second has has Rstudio 1.2.x. 16GB Ram, Nvidia geforce GTX (oldish but its there!)

To repeat my question: Should I expect that ggsave can be super fast on Rstudio cloud whereas it might be MUCH slower on my local machine? Or should it be sort of comparable? I'm not aware of Rstudio cloud be hyper tuned to execute ggsaves efficiently.

I would expect similar timings.
you can use sessionInfo() to understand version differences across environments.
You can use profiling techniques to determine performance issues in code, though this might be less usefull if the issue is on a pure ggsave call.

Some form of reprex, that forum users on the forum could use to ggsave locally and on cloud would be useful.
I've attempted the code on my local pc

library(tictoc)
library(ggplot2)
tic()
ggplot(mtcars, aes(mpg, wt)) + geom_point()
ggsave("mtcars.png")
toc()
sessionInfo()
> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

other attached packages:
[1] ggplot2_3.3.0 tictoc_1.0   

timing is roughly half a second

On cloud it took roughly the same time.
the sessionInfo is

> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS

other attached packages:
[1] ggplot2_3.3.3 tictoc_1.0  
1 Like

solved with changing device to cario

ggsave(
  filename = filename,
  path = here("img"),
  plot = art_pic,
  width = pixels_wide/300,
  height = pixels_high/300,
  dpi = 300,
  type = "cairo"
)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.