rstudio / blogdown

Create Blogs and Websites with R Markdown
https://pkgs.rstudio.com/blogdown/
1.73k stars 335 forks source link

Build time is high for a specific blogdown post #646

Closed arungop closed 2 years ago

arungop commented 3 years ago

I created a blog post in hugo using Rmd. It's a post with some plotly plots and kable- tables. Issue is build time is large after this post. I ran hugo --templateMetrics and obtained:

Template Metrics:

     cumulative       average       maximum         
       duration      duration      duration  count  template
     ----------      --------      --------  -----  --------
   1.626120227s   36.957277ms  408.339555ms     44  _internal/_default/rss.xml
   763.027157ms    9.782399ms  215.337825ms     78  partials/header.html
   752.749185ms   22.810581ms   235.07645ms     33  _default/single.html
   123.590753ms    2.942636ms   14.004466ms     42  _default/list.html
   102.945311ms    1.319811ms   22.201224ms     78  partials/footer.html
    54.573706ms   27.286853ms   32.341717ms      2  shortcodes/gallery.html
    51.821561ms     664.378µs   19.904674ms     78  partials/menu.html
    33.233383ms   16.616691ms   29.040813ms      2  _default/terms.html
    33.040902ms    1.835605ms   32.462647ms     18  shortcodes/blogdown/postref.html
    22.397632ms     287.149µs   10.191932ms     78  partials/disqus.html
    13.181183ms     168.989µs     1.99331ms     78  partials/tagline.html
     7.055061ms      90.449µs     601.916µs     78  partials/meta.html
     6.827928ms      87.537µs     1.20014ms     78  partials/footer_highlightjs.html
     6.130999ms      78.602µs     722.423µs     78  partials/head_highlightjs.html
     6.107096ms    6.107096ms    6.107096ms      1  _internal/_default/sitemap.xml
     6.104973ms      78.268µs     297.706µs     78  partials/head_custom.html
      2.13701ms     2.13701ms     2.13701ms      1  404.html
      1.81565ms     259.378µs     478.508µs      7  _internal/shortcodes/youtube.html
     1.232103ms     616.051µs     746.914µs      2  shortcodes/leaflet-simple.html
     1.117634ms      93.136µs     356.447µs     12  _internal/shortcodes/figure.html
      837.184µs      10.733µs     616.463µs     78  partials/menu_extra.html
      679.337µs     679.337µs     679.337µs      1  _internal/shortcodes/ref.html
      621.455µs     621.455µs     621.455µs      1  shortcodes/audio.html
       506.79µs     126.697µs     295.357µs      4  _internal/shortcodes/gist.html
      415.489µs     207.744µs     411.983µs      2  shortcodes/load-leaflet.html
      258.359µs       3.312µs       120.1µs     78  partials/foot_custom.html
      144.421µs     144.421µs     144.421µs      1  _internal/_default/robots.txt

                   | EN   
-------------------+------
  Pages            | 123  
  Paginator pages  |   0  
  Non-page files   |  88  
  Static files     | 118  
  Processed images |  64  
  Aliases          |   0  
  Sitemaps         |   1  
  Cleaned          |   0 

After that I removed folder containing this post and it's back to normal.

Template Metrics:

     cumulative       average       maximum         
       duration      duration      duration  count  template
     ----------      --------      --------  -----  --------
   288.051518ms    3.740928ms   40.470004ms     77  partials/header.html
   268.815666ms    8.400489ms   41.277647ms     32  _default/single.html
   142.936834ms    3.403257ms    9.490356ms     42  _default/list.html
   125.747075ms    2.857888ms   26.382857ms     44  _internal/_default/rss.xml
    90.812114ms    1.179378ms   11.984544ms     77  partials/footer.html
    42.745283ms     555.133µs    6.644937ms     77  partials/menu.html
    35.339083ms   17.669541ms   27.867713ms      2  shortcodes/gallery.html
    16.536801ms     214.763µs    2.029638ms     77  partials/tagline.html
    15.394061ms    3.848515ms   15.140267ms      4  _internal/shortcodes/gist.html
    12.566134ms     163.196µs      484.49µs     77  partials/disqus.html
    12.112386ms    6.056193ms     7.41368ms      2  _default/terms.html
     8.228001ms     106.857µs     893.874µs     77  partials/meta.html
     6.701799ms      87.036µs       233.8µs     77  partials/head_custom.html
     6.117496ms      79.448µs     703.296µs     77  partials/footer_highlightjs.html
     5.793611ms    5.793611ms    5.793611ms      1  _internal/_default/sitemap.xml
     5.759488ms      74.798µs     750.785µs     77  partials/head_highlightjs.html
     2.915229ms     242.935µs    1.042134ms     12  _internal/shortcodes/figure.html
      2.10813ms     2.10813ms     2.10813ms      1  404.html
     2.048238ms     292.605µs         903µs      7  _internal/shortcodes/youtube.html
     1.613002ms     806.501µs     1.15953ms      2  shortcodes/leaflet-simple.html
      572.428µs     286.214µs     540.294µs      2  shortcodes/blogdown/postref.html
      564.534µs     282.267µs     560.076µs      2  shortcodes/load-leaflet.html
      545.795µs     545.795µs     545.795µs      1  shortcodes/audio.html
      436.922µs     436.922µs     436.922µs      1  _internal/shortcodes/ref.html
      373.815µs       4.854µs     198.946µs     77  partials/foot_custom.html
      338.772µs     338.772µs     338.772µs      1  _internal/_default/robots.txt
      333.219µs       4.327µs     118.989µs     77  partials/menu_extra.html

                   | EN   
-------------------+------
  Pages            | 122  
  Paginator pages  |   0  
  Non-page files   |  66  
  Static files     | 118  
  Processed images |  64  
  Aliases          |   0  
  Sitemaps         |   1  
  Cleaned          |   0  

Total in 601 ms

What's wrong here? Any suggestions?

yihui commented 3 years ago

Could you provide a minimal reproducible example as requested by the issue guide? Thanks!

The first set of metrics didn't show the total time (the second set did), so we don't know how slow it was.

arungop commented 3 years ago

It was about 32 s. I missed that line while copying. Following the guides I added "framewidget" options in these chunks and now the build time is under 7s. But still its a long time considering the speed of hugo. .Rmd file.

yihui commented 3 years ago

That's not a minimal example. If the example is not minimal, there could be many other reasons that cause the problem. If you think plotly and kable are the culprit, it will be more convincing to provide a minimal website project that contains a post that uses only plotly and kable.

Anyway, I tested your repo and wasn't able to reproduce the problem.

With the post data-exploration-of-covid-19-data-india:

> blogdown::hugo_build()

Start building sites … 

                   | EN   
-------------------+------
  Pages            | 123  
  Paginator pages  |   0  
  Non-page files   |  98  
  Static files     | 118  
  Processed images |  64  
  Aliases          |   0  
  Sitemaps         |   1  
  Cleaned          |   0  

Total in 288 ms

Without the post:

> blogdown::hugo_build()
Start building sites … 

                   | EN   
-------------------+------
  Pages            | 122  
  Paginator pages  |   0  
  Non-page files   |  66  
  Static files     | 118  
  Processed images |  64  
  Aliases          |   0  
  Sitemaps         |   1  
  Cleaned          |   0  

Total in 324 ms

The build times are fairly close.