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

Optimisation "partialCached" #165

Merged
merged 4 commits into from
Mar 21, 2019
Merged

Optimisation "partialCached" #165

merged 4 commits into from
Mar 21, 2019

Conversation

echarp
Copy link
Contributor

@echarp echarp commented Mar 19, 2019

Some partials are mostly static, and could be rendered once and reused.

This uses a powerful cache mechanism, documented here: https://gohugo.io/functions/partialcached/

@budparr
Copy link
Member

budparr commented Mar 20, 2019

Thank you @echarp I'll give this a look. PartialChached can be tricky on some templates. Did you select those templates via templateMetricsHints?

@echarp
Copy link
Contributor Author

echarp commented Mar 21, 2019

I did look into templateMetricsHints, but really I mostly analyzed what could be cached.

It seems those partials are fixed, at least in my circumstances, and thus are proper candidates.

Note, I'm using your theme on a tool with more than 12k pages, have a look => https://filsdu.net

@budparr budparr merged commit 1754826 into theNewDynamic:master Mar 21, 2019
@budparr
Copy link
Member

budparr commented Mar 21, 2019

Thanks, @echarp I'd be interested in your before and after build times are for a site that size.

@echarp
Copy link
Contributor Author

echarp commented Mar 22, 2019

with non cached partial

hugo --renderToMemory --templateMetrics --logFile partial.txt
LOG:   2019/03/22 19:57:29 
Template Metrics:

LOG:   2019/03/22 19:57:29      cumulative       average       maximum         
       duration      duration      duration  count  template
     ----------      --------      --------  -----  --------
   55.99859089s    8.749779ms   60.266864ms   6400  article/single.html
   42.66242535s     9.39908ms  108.978797ms   4539  taxonomy/taxonomy.html
  29.528809719s    4.613876ms   50.762521ms   6400  partials/menu-contextual.html
  18.920556903s   53.147631ms  162.055461ms    356  _default/list.html
  16.607884057s     467.366µs   32.799173ms  35535  partials/summary-with-image.html
  11.751293525s     519.141µs   30.136921ms  22636  partials/social-follow.html
    9.19453971s     812.382µs   30.564489ms  11318  partials/site-navigation.html
   7.379123946s     651.981µs   23.282555ms  11318  partials/site-footer.html
   6.271951908s     979.533µs   33.788226ms   6403  partials/page-header.html
   5.801784229s     119.822µs   16.351324ms  48420  partials/date.html
   4.257862343s     866.299µs   20.092843ms   4915  partials/site-header.html
   3.775193399s      55.592µs   29.407884ms  67908  partials/new-window-icon.html
   3.672306193s      75.976µs    25.24412ms  48335  partials/authors.html
   2.735878044s      56.512µs   12.099978ms  48412  partials/sites.html
   2.564887398s     400.763µs   18.926342ms   6400  partials/summary.html
   2.177925813s      48.935µs   20.232508ms  44506  partials/author.html
   2.023401878s      683.12µs   12.580863ms   2962  _internal/_default/rss.xml
   1.944865174s      28.639µs    29.36849ms  67908  partials/svg/new-window.svg
   1.894463311s     296.009µs   24.137278ms   6400  partials/tags.html
   1.766548193s      36.381µs   18.545028ms  48556  partials/href.html
   1.691319186s  112.754612ms  235.258142ms     15  series/series.html
   1.306725432s      56.048µs   23.979564ms  23314  partials/tag.html
   749.936724ms       33.13µs   21.257615ms  22636  partials/svg/twitter.svg
   696.069165ms      61.501µs   17.790938ms  11318  partials/site-scripts.html
   617.523421ms       27.28µs   20.055006ms  22636  partials/svg/mastodon.svg
   571.855171ms      50.526µs   10.171017ms  11318  partials/site-favicon.html
   453.827381ms  453.827381ms  453.827381ms      1  _internal/_default/sitemap.xml
   429.462964ms      18.972µs   18.498808ms  22636  partials/svg/gitlab.svg
   288.571738ms   96.190579ms  210.344045ms      3  taxonomy/list.html
   158.382643ms      13.993µs   12.007046ms  11318  partials/i18nlist.html
    58.832291ms   58.832291ms   58.832291ms      1  index.html
    13.521369ms   13.521369ms   13.521369ms      1  series/list.html
     6.089812ms    3.044906ms     3.75827ms      2  page/single.html
     4.406189ms    4.406189ms    4.406189ms      1  rss.xml
        2.217ms       2.217ms       2.217ms      1  404.html
LOG:   2019/03/22 19:57:29 
LOG:   2019/03/22 19:57:29 Total in 40475 ms

with partialCached:

hugo --renderToMemory --templateMetrics --logFile partialCached.txt
LOG:   2019/03/22 21:20:33 
Template Metrics:

LOG:   2019/03/22 21:20:33      cumulative       average       maximum         
       duration      duration      duration  count  template
     ----------      --------      --------  -----  --------
  44.892119346s    7.014393ms  102.414219ms   6400  article/single.html
  36.694767931s    8.084328ms   132.84283ms   4539  taxonomy/taxonomy.html
  29.428822744s    4.598253ms   72.979599ms   6400  partials/menu-contextual.html
  17.731134342s   49.806557ms  170.897916ms    356  _default/list.html
  17.122216577s      481.84µs   53.049223ms  35535  partials/summary-with-image.html
   5.913151909s     122.122µs   20.623611ms  48420  partials/date.html
   3.668933772s      75.906µs   20.456571ms  48335  partials/authors.html
    2.83472341s      58.554µs    17.88621ms  48412  partials/sites.html
   2.456012594s     383.751µs   15.412213ms   6400  partials/summary.html
   2.259192254s      50.761µs   20.402341ms  44506  partials/author.html
    1.85801836s      38.265µs   20.213535ms  48556  partials/href.html
   1.834376022s     286.621µs   23.482806ms   6400  partials/tags.html
     1.7062027s      576.03µs     3.26937ms   2962  _internal/_default/rss.xml
   1.431243503s   95.416233ms  166.422346ms     15  series/series.html
   1.268648946s      54.415µs   18.172071ms  23314  partials/tag.html
   645.177671ms     131.267µs    2.199887ms   4915  partials/site-header.html
   490.144369ms      76.549µs   23.087595ms   6403  partials/page-header.html
     446.0089ms    446.0089ms    446.0089ms      1  _internal/_default/sitemap.xml
   286.038057ms   95.346019ms   213.94181ms      3  taxonomy/list.html
    59.370311ms   59.370311ms   59.370311ms      1  index.html
    21.952602ms    7.317534ms   18.326557ms      3  partials/social-follow.html
    21.113157ms   10.556578ms   18.612347ms      2  partials/site-footer.html
    12.377763ms   12.377763ms   12.377763ms      1  series/list.html
     7.631455ms    3.815727ms    5.585825ms      2  page/single.html
     3.749934ms    3.749934ms    3.749934ms      1  rss.xml
     3.229502ms    3.229502ms    3.229502ms      1  partials/site-navigation.html
      1.42968ms     158.853µs     494.311µs      9  partials/new-window-icon.html
     1.351976ms    1.351976ms    1.351976ms      1  404.html
     1.137019ms    1.137019ms    1.137019ms      1  partials/site-scripts.html
      771.042µs      85.671µs     285.674µs      9  partials/svg/new-window.svg
      662.655µs     220.885µs     250.652µs      3  partials/svg/twitter.svg
      484.843µs     161.614µs     333.391µs      3  partials/svg/mastodon.svg
      364.979µs     121.659µs     280.869µs      3  partials/svg/gitlab.svg
       319.24µs      319.24µs      319.24µs      1  partials/i18nlist.html
      131.409µs     131.409µs     131.409µs      1  partials/site-favicon.html
LOG:   2019/03/22 21:20:33 
LOG:   2019/03/22 21:20:33 Total in 36395 ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants