Bei meinem aktuellen Drupal nach Hugo Migrationsprojekt habe ich das Problem, dass die Site nicht in vernünfitger Zeit generiert wurde (viel länger als 4 min).
Was kann man dagegen tun?
Als erstes habe ich mal wild drauf los geraten (wild guess), dass es entweder die Pagination oder die Tags sein könnten. Das Hochsetzen von .Paginatevon 5 bzw. 13 auf 20 hat auf einem abgespeckten System schon ein bisschen etwas gebracht:
{{ range (.Paginate $pages 20).Pages }}
Leider habe ich hier noch keine Zeiten festgehalten. Und wildes Raten ist jetzt auch nicht State of the Art beim Performance Tuning.
Als nächstes, immer noch im wilden Ratemodus, habe ich das public Directory auf eine RAM-Disk gelegt. Ich musste ein paar mal probieren, bis ich die richtige Grösse der RAM-Disk raus hatte. Am Schluss bin ich bei einer RAM-Disk von 6 G Grösse gelandet, wovon dann auch ca. 4.8 G genutzt wurden:
$ df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 6.0G 4.8G 1.3G 80% /mnt/public
Das Anlegen der RAM-Disk habe ich wie folgt gemacht:
$ rm -rf /mnt/public/*
$ sudo mount -t tmpfs -o size=6G tmpfs /mnt/public
$ sudo chown oli:oli /mnt/public
$ hugo server
$ sudo umount /mnt/public
Damit bin ich auf Build-Zeiten von um die 4 min gekommen.
Dann habe ich zum Glück auch noch rausgefunden, wie man Hugo dazu bewegen kann, Performance-Metriken herzugeben:
$ hugo server --printUnusedTemplates --templateMetrics --templateMetricsHints --logLevel debug
Mit diesen Informationen ging es dann schon wesentlich besser:
Template Metrics:
cumulative average maximum cache percent cached total
duration duration duration potential cached count count template
---------- -------- -------- --------- ------- ------ ----- --------
6m47.967921916s 7.405077ms 107.636941ms 0 0 0 55093 tags/list.html
1m56.549549975s 2.021744ms 74.568509ms 0 0 0 57648 _partials/pagination.html
25.33711023s 434.018µs 71.493784ms 17 0 0 58378 _partials/header.html
21.728267913s 372.199µs 20.913224ms 48 0 0 58378 _partials/secondary-menu.html
14.603773877s 5.867325ms 56.975002ms 0 0 0 2489 blog/list.html
13.663109559s 234.045µs 492.692928ms 94 0 0 58378 _partials/head.html
6.020665541s 103.132µs 17.095981ms 23 0 0 58378 _partials/primary-menu.html
4.047814641s 69.338µs 39.061138ms 28 0 0 58378 _partials/language-switcher.html
1.845461936s 31.612µs 405.523695ms 100 100 58374 58378 _partials/head/css.html
1.090371636s 272.592909ms 546.14847ms 0 0 0 4 aggregator/list.html
975.969392ms 51.36681ms 526.204209ms 0 0 0 19 aggregator/categories/10/list.html
876.620985ms 487.011µs 91.534012ms 0 0 0 1800 rss.xml
657.303371ms 1.441454ms 22.42719ms 0 0 0 456 blog/single.html
621.419135ms 2.344977ms 40.454651ms 0 0 0 265 list.html
511.136507ms 127.784126ms 496.825869ms 0 0 0 4 home.html
509.959705ms 127.489926ms 490.99319ms 0 0 0 4 aggregator/categories/3/list.html
455.275986ms 26.78094ms 62.87611ms 0 0 0 17 aggregator/categories/4/list.html
445.816398ms 7.636µs 87.57835ms 100 100 58374 58378 _partials/head/js.html
204.094772ms 61.418µs 22.386073ms 0 0 0 3323 _markup/render-link.html
109.770602ms 18.2951ms 51.894813ms 0 0 0 6 aggregator/categories/5/list.html
104.114495ms 1.783µs 3.027599ms 100 0 0 58378 _partials/footer.html
92.081366ms 15.346894ms 43.386465ms 0 0 0 6 aggregator/categories/6/list.html
89.764033ms 11.220504ms 21.728461ms 0 0 0 8 aggregator/categories/9/list.html
77.616448ms 1.329µs 3.023557ms 100 0 0 58378 _partials/search-form.html
69.700144ms 69.700144ms 69.700144ms 0 0 0 1 aggregator/categories/list.html
67.745234ms 23.384µs 2.957546ms 0 0 0 2897 alias.html
62.92369ms 10.487281ms 32.601198ms 0 0 0 6 aggregator/categories/8/list.html
60.153541ms 15.038385ms 46.326052ms 0 0 0 4 sitemap.xml
28.454014ms 330.86µs 22.706576ms 0 0 0 86 _markup/render-image.html
456.855µs 456.855µs 456.855µs 0 0 0 1 sitemapindex.xml
│ DE │ EN │ FR │ IT
──────────────┼──────┼───────┼──────┼──────
Pages │ 237 │ 3284 │ 44 │ 44
Paginator │ 326 │ 56242 │ 3 │ 3
pages │ │ │ │
Non-page │ 0 │ 0 │ 0 │ 0
files │ │ │ │
Static files │ 1140 │ 1140 │ 1140 │ 1140
Processed │ 0 │ 0 │ 0 │ 0
images │ │ │ │
Aliases │ 192 │ 2637 │ 34 │ 34
Cleaned │ 0 │ 0 │ 0 │ 0
Built in 204587 ms
Zumindest habe ich richtig geraten: Schuld an den langen Build-Zeiten sind die Pagination und die Tags. Ich habe mich nur in der Reihenfolge vertan… :-(
Nachdem ich die Tags ganz deaktiviert habe, lief ein Hugo-Build dann auch in vernünftiger Zeit durch:
Template Metrics:
cumulative average maximum cache percent cached total
duration duration duration potential cached count count template
---------- -------- -------- --------- ------- ------ ----- --------
13.997433489s 5.623717ms 58.638966ms 0 0 0 2489 blog/list.html
1.736771816s 432.678µs 30.871171ms 16 0 0 4014 _partials/header.html
1.382840456s 344.504µs 7.971872ms 49 0 0 4014 _partials/secondary-menu.html
1.371739057s 536.884µs 20.877972ms 7 0 0 2555 _partials/pagination.html
1.230479069s 1.687899ms 31.855525ms 0 0 0 729 tags/list.html
1.096285178s 273.115µs 64.676244ms 73 0 0 4014 _partials/head.html
750.708255ms 1.64629ms 32.195851ms 0 0 0 456 blog/single.html
538.565422ms 134.641355ms 432.320888ms 0 0 0 4 aggregator/list.html
481.032711ms 267.24µs 16.395291ms 0 0 0 1800 rss.xml
442.999121ms 23.315743ms 94.872299ms 0 0 0 19 aggregator/categories/10/list.html
413.333386ms 1.559748ms 13.656589ms 0 0 0 265 list.html
384.064301ms 22.592017ms 59.546703ms 0 0 0 17 aggregator/categories/4/list.html
383.615935ms 95.569µs 1.992594ms 25 0 0 4014 _partials/primary-menu.html
266.172438ms 66.311µs 3.328387ms 26 0 0 4014 _partials/language-switcher.html
149.609934ms 37.272µs 35.06112ms 100 100 4010 4014 _partials/head/css.html
131.120736ms 39.458µs 4.944508ms 0 0 0 3323 _markup/render-link.html
122.007233ms 30.395µs 29.020918ms 100 100 4010 4014 _partials/head/js.html
81.163457ms 10.145432ms 19.733192ms 0 0 0 8 aggregator/categories/9/list.html
77.897654ms 19.474413ms 67.213496ms 0 0 0 4 home.html
71.414857ms 11.902476ms 27.865375ms 0 0 0 6 aggregator/categories/6/list.html
68.781019ms 17.195254ms 59.899216ms 0 0 0 4 aggregator/categories/3/list.html
67.282625ms 16.820656ms 56.25392ms 0 0 0 4 sitemap.xml
65.533937ms 10.922322ms 24.105709ms 0 0 0 6 aggregator/categories/5/list.html
42.761637ms 42.761637ms 42.761637ms 0 0 0 1 aggregator/categories/list.html
42.219601ms 19.473µs 188.353µs 0 0 0 2168 alias.html
41.936727ms 6.989454ms 14.154317ms 0 0 0 6 aggregator/categories/8/list.html
6.299404ms 1.569µs 65.731µs 100 0 0 4014 _partials/footer.html
5.397807ms 62.765µs 111.716µs 0 0 0 86 _markup/render-image.html
4.858107ms 1.21µs 17.496µs 100 0 0 4014 _partials/search-form.html
168.296µs 168.296µs 168.296µs 0 0 0 1 sitemapindex.xml
Built in 9942 ms
Und ein positiver Nebeneffekt davon: Es braucht jetzt auch nur noch 400 M Disk-Platz statt 4.8 G:
$ df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 6.0G 367M 5.7G 6% /mnt/public
Jetzt muss ich nur noch rauskriegen, wie ich die Tags schnell kriege…
Quelle: