I am considering switching from Hugo to Gutenberg (the big draw is the sane template system—thanks so much for that!). I'm also planning to write about the comparison between the two.
As part of that process, I've been running benchmarks on my site using hyperfine. I was expecting that Gutenberg would be faster, since Rust is generally a bit faster than Go. However, to my surprise, Gutenberg took nearly 3 times as long to build my (small) site: 151.8 ms vs Hugo's 57.8 ms. Based on that, I have a few questions.
Thanks again for your work on this project. I really like it, an may well switch even if it really isn't as fast. But I wanted to give you a chance to weigh in before I write a post saying it's much slower than Hugo at the moment.
Do you have a sample repo to see the difference? Is that the full build or only the rebuild time?
I haven't spent that much time improving performances as my sites are in the ms range as well and didn't feel the need to optimize more so there are quite a few clone() around the codebase. Another possible explanation for the speed difference for the site is that Tera needs to serialize the context to JSON and I don't believe the Go template engine does any kind of serialization. The syntax highlighting that Hugo uses is also way simpler than Gutenberg which is actually using the same syntax highlighting as Sublime Text and therefore slower (rendering markdown with highlighting is about 4x slower than without in Gutenberg).
Almsot everything in Gutenberg is already parallelised so I think so the best improvement would come from reducing the number of clones.
I'm not planning to work on any perf improvement for a bit as there are still important features missing like i18n that are way more needed than gaining a few ms.
Thanks for the reply. I don't (yet) have a sample repo for a Gutenberg version of the site, since I'm still working on converting it. I'll update this thread when I do. The Hugo version of the repo is at codesections/codesections.
After a bit more testing, it looks like you're right about the syntax highlighting being a main culprit, though it looks like creating the search index contributes even more. I've listed out the times I've gotten below:
(Note: I don't currently use sass for my site, so I didn't test the speed of the sass compilation. I did turn it on a few times to make sure that checking for sass files did not take any measurable time; as expected, that option had no impact on speed).
I am a little confused by what you meant when you asked "Is that the full build or only the rebuild time". I would have thought that it was the rebuild time: it was the time I got from running gutenberg build. But I also ran rm -rf public; gutenberg build, and got essentially the same time. (Well, technically, I had hyperfine run rm -rf as a "prepare" command, and got exactly the same time. So it looks a bit like gutenberg build is triggering a full build. Is there a way to just do a rebuild? Or is it the case that, with a small site, there literally isn't a measurable difference between the two types of build?
Thanks again for your reply and your work on this project. I'm definitely planning to switch!
Sorry for the confusion, gutenberg build will rebuild the whole thing. I was only wondering if you were using gutenberg serve and editing a file - where it does partial reload like Hugo.
So Hugo & Gutenberg are at the same speed roughly despite the syntax highlighting being much more powerful in Gutenberg :o Pretty nice to know.
The search index is actually not built in parallel currently but I'm not sure it would be a significant speed increase, I'll have to add benchmarks and try it.
Thanks, that makes sense. Just curious, what "more powerful" features does the Gutenberg syntax highlighting have compared to the Chroma highlighting in Hugo?
Chroma is basically Pygments in Go so it just highlights keywords.
Syntect uses the Sublime Text highlighting syntaxes so you get context-aware highlighting and it is overall much more refined.
As an example, compare the python Pygments syntax (https://github.com/alecthomas/chroma/blob/master/lexers/p/python3.go) with the sublime one (https://github.com/sublimehq/Packages/blob/master/Python/Python.sublime-syntax). For more visual comparison, you can download sublime and look at some code VS running it in http://pygments.org
Most helpful comment
Chroma is basically Pygments in Go so it just highlights keywords.
Syntect uses the Sublime Text highlighting syntaxes so you get context-aware highlighting and it is overall much more refined.
As an example, compare the python Pygments syntax (https://github.com/alecthomas/chroma/blob/master/lexers/p/python3.go) with the sublime one (https://github.com/sublimehq/Packages/blob/master/Python/Python.sublime-syntax). For more visual comparison, you can download sublime and look at some code VS running it in http://pygments.org