]> git.maquefel.me Git - brevno-suite/hugo/commit
hugolib: Improve performance of content trees with many sections
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 12 Nov 2025 11:55:27 +0000 (12:55 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Fri, 14 Nov 2025 10:24:31 +0000 (11:24 +0100)
commit26f31ff6ce6c69f663b4ea1e62cae95cd6ab7b6d
tree05dc1277e1c3dc5cc9fa20d0de193e4ee380f4fb
parentbca171b691815ff6b8ef4bb4710817a323453170
hugolib: Improve performance of content trees with many sections

Hugo's build process is roughly divided into three steps:

1. Process content (walk file system and insert source nodes into content tree)
2. Assemble content (assemble pages and resources according to sites matrix)
3. Render content

In #13679 we consolidated the page creation logic into one place (the assemble step). This made it much simpler to reason about, but it lost us some performance esp. in big content trees.

This commit re-introduces parallelization in the first step in the assemble step by handling each top level section in its own goroutine. This gives significant performance improvements for content trees with many sections.

Compared to master:

```
AssembleDeepSiteWithManySections/depth=1/sectionsPerLevel=6/pagesPerSection=100-10    19.26m ± ∞ ¹   14.54m ± ∞ ¹  -24.52% (p=0.029 n=4)
AssembleDeepSiteWithManySections/depth=2/sectionsPerLevel=2/pagesPerSection=100-10    19.74m ± ∞ ¹   16.45m ± ∞ ¹  -16.71% (p=0.029 n=4)
AssembleDeepSiteWithManySections/depth=2/sectionsPerLevel=6/pagesPerSection=100-10   106.18m ± ∞ ¹   71.23m ± ∞ ¹  -32.91% (p=0.029 n=4)
AssembleDeepSiteWithManySections/depth=3/sectionsPerLevel=2/pagesPerSection=100-10    38.85m ± ∞ ¹   30.47m ± ∞ ¹  -21.59% (p=0.029 n=4)
```
common/collections/stack.go
common/hiter/iter.go
hugolib/content_map_page_assembler.go
hugolib/content_map_page_contentnodeshifter.go
hugolib/doctree/nodeshiftree_test.go
hugolib/doctree/nodeshifttree.go
hugolib/doctree/support.go
hugolib/hugo_sites_build.go
hugolib/hugo_sites_build_test.go
hugolib/sitesmatrix/sitematrix_integration_test.go