Slow server

I have a website with about 300 pages. Full builds take about 40 minutes, which is not surprising considering the large amount of images in the image processing pipeline. What bothers me is the 10-20s latency of the dev server. Based on the output of --templateMetrics it looks like Hugo is trying to rebuild the entire project on every change instead of simply changing the one page I am editing. Is there any way to speed up the server?

hugo v0.136.0+extended darwin/arm64 BuildDate=2024-10-15T13:17:24Z VendorInfo=brew


                   |  FI   
-------------------+-------
  Pages            |  358  
  Paginator pages  |   10  
  Non-page files   | 1164  
  Static files     |   21  
  Processed images | 7673  
  Aliases          |    7  
  Cleaned          |    0  

Built in 11089 ms
Environment: "development"
Serving pages from disk
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1515/ (bind address 127.0.0.1) 
Press Ctrl+C to stop

Change detected, rebuilding site (#1).
2024-10-17 02:41:59.434 +0300
Web Server is available at http://localhost:1515/ (bind address 127.0.0.1)
Rebuilt in 21118 ms

Change detected, rebuilding site (#2).
2024-10-17 02:45:26.437 +0300
Web Server is available at http://localhost:1515/ (bind address 127.0.0.1)
Rebuilt in 11671 ms

Change detected, rebuilding site (#3).
2024-10-17 02:45:42.437 +0300
Web Server is available at http://localhost:1515/ (bind address 127.0.0.1)
Rebuilt in 19048 ms

Change detected, rebuilding site (#4).
2024-10-17 02:46:05.938 +0300
Web Server is available at http://localhost:1515/ (bind address 127.0.0.1)
Rebuilt in 11522 ms

Change detected, rebuilding site (#5).
2024-10-17 02:46:38.937 +0300
Web Server is available at http://localhost:1515/ (bind address 127.0.0.1)
Rebuilt in 27430 ms
Template Metrics:

       cumulative       average       maximum         
         duration      duration      duration  count  template
       ----------      --------      --------  -----  --------
    13.456601744s   39.812431ms  230.264458ms    338  _default/single.html
     7.228429095s    7.185317ms  209.052125ms   1006  partials/h-card.html
     5.669120534s   16.772545ms  220.420459ms    338  partials/bottom-nav.html
     5.334397912s   12.014409ms  219.713958ms    444  shortcodes/img.html
     1.614305916s  100.894119ms  293.602833ms     16  _default/list.html

We don’t. The below is me changing a content file in the Hugo Docs site:

What’s happening in your setup is hard for me to guess. You have a single template that looks very slow/doing too much work, but that would not explain the rebuild time. But as I said, without the full source, it’s hard to guess.

The full source code of the theme is available here.

mmh, you might get some analyis or recommendations when you also provide example content that reflects your real usage and utilizes all your features of content files/ layouts/partials and shortcodes.

code based performance analysis is much work.

Just a side-question: hugo v0.136.0+extended darwin/arm64 sounds like a Raspberry Pi or some other “non-normal” computer. What exactly is your hardware situation? Certain toys tend to be slow. What RAM do you have, what harddrive do you have?

Your template metrics also look very selective. What is the full output between you running hugo server with template metrics on and the end of the CLI output?

What happens quite often in this forum is that people ask for actual files of your website. With a good reason, because nobody knows what is going on in your templates.

from what I see I have questions like: h-card.html does WHAT? if you have 338 single pages, why does that partial have to run three times? what is going on in your shortcode-image? Does your bottom navigation need to be recalculated for every single page?

1 Like

That is a modern Mac I believe.

Darwin is the open sourced core of macOS. The “arm64” part is for Apple Silicon CPUs like the M1.

1 Like