Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docpad - how can I find out why it is slow?

Tags:

node.js

docpad

I'm migrating my tumblr blog to docpad and have started with this boilerplate: https://github.com/ervwalter/ewalnet-docpad

Now my problem is that "docpad run" takes 58s to run, and a livereload run takes 23s. I wrote the author of this boilerplate and he says he is having the same, but it doesn't bother him too much.

But I don't want to wait half a minute for every change in a blog post to see how it looks like, so I'm trying to make it faster. I tried profiling with nodetime but I don't see a drilldown per method or so. My assumption is that the time is lost in the partials, at it sends the whole posts to the partials

How can I profile Docpad so I see where the time is lost? I know the question is very broad, but all I found on performance optimizing on DocPad is that you should make Docpad not to parse static files.

Update the missing link was that I needed to start the CPU profiler on nodetime:

  1. configure nodetime, described here
  2. start CPU profiler on nodetime
  3. start docpad: docpad --profile run

Unfortunately in my case the output is not much helping. The results of my run reveal that 81% of the time is spent in ambi.js, which seems is just a intermediate layer which calls functions. I could not find out which functions are called, adding console.log(fireMethod.toString()) I only see

function () { [native code] }

so I'm not really further. How can I find out where the time is actually spent? For reference: here is my v8.log

Also, I'm a bit worried, that docpad almost only relies on modules written by Benjamin Lupton. Why is that so?

like image 392
hansaplast Avatar asked May 26 '14 09:05

hansaplast


1 Answers

After an odyssey of about 1 week I came to the conclusion that Docpad is not made for speed, it is made to handle complex sites. Some facts:

  • even a fresh docpad installation with only twitter bootstrap takes 12s to build
  • there are no means to only regenerate the files which source files have changed (dependency tree), it always regenerates everything
  • reading threads like this show that speed is not in focus

My use case is writing articles for a blog and I have a lot of "change text and see how it looks" loops. I have switched to Hexo which is a lot faster:

  • hexo server starts in 2.5 seconds. With livereload on, when I change a blog post, the broswer tab reloads the page and shows the new content in about 1s
  • generating all files afresh with hexo clean and hexo generate takes only 5s.

This is the same setup (with less, coffeescript, etc.) I had for DocPad where DocPad needed 38s to run.

Additionally to speed hexo gave me

  • themes: hexo nicely separates between the theme and the content (DocPad mingles the two). Currently there are about 30 hexo themes to choose from
  • implementation of read more: in hexo <! --more --> is supported out of the box
  • deployment to github pages is out of the box
  • architecture was a lot easier for me to understand, writing widgets is a bliss, the documentation also looks nicer

Overall, it looks like hexo is suited better for blogs, whereas docpad is better suited for more complex sites. Hexo looks like it's really taking off, getting about 30 stars on github per week, whereas docpad is only getting about 10 stars per week.

like image 73
hansaplast Avatar answered Nov 15 '22 01:11

hansaplast