totocaster / metalsmith-tags

A metalsmith plugin to create dedicated pages for tags in posts or pages.
49 stars 43 forks source link

metalsmith-tags is very slow when using metalsmith-watch #17

Closed deltamualpha closed 9 years ago

deltamualpha commented 9 years ago

I ran into major performance problems with metalsmith while using it for live development, and so I started using a little home-cooked timer to see which plugin was making a change to a single file take almost a minute and a half to rebuild. Lo and behold:

$ DEBUG=metalsmith-debug node watch
[metalsmith-watch] ✓ Live reload server started on port: 35729
  metalsmith-debug start timing +0ms
  metalsmith-debug post-metadata +1ms
  metalsmith-debug post-fileMetadata +3ms
  metalsmith-debug post-copy +16ms
  metalsmith-debug post-tags +10ms
  metalsmith-debug post-collections +23ms
  metalsmith-debug post-paginate +8s
  metalsmith-debug post-lunr +1s
  metalsmith-debug post-markdown +81ms
  metalsmith-debug post-excerpts +129ms
  metalsmith-debug post-permalinks +155ms
  metalsmith-debug post-templates +428ms
  metalsmith-debug post-assets +2ms
  metalsmith-debug post-sass +595ms
  metalsmith-debug post-prefixer +59ms
[metalsmith-serve] serving build at http://localhost:8080
[metalsmith-watch] ✔︎ Watching src/**/*
[metalsmith-watch] ✔︎ Watching assets/styles/*
[metalsmith-watch] ✔︎ Watching templates/**/*
[metalsmith-watch] ✔︎ src/blog/posts/this-is-a-post.md changed
[metalsmith-watch] - Updating 1 file...
  metalsmith-debug start timing +26s
  metalsmith-debug post-metadata +0ms
  metalsmith-debug post-fileMetadata +0ms
  metalsmith-debug post-copy +1ms
  metalsmith-debug post-tags +59s
  metalsmith-debug post-collections +0ms
  metalsmith-debug post-paginate +0ms
  metalsmith-debug post-lunr +3ms
  metalsmith-debug post-markdown +36ms
  metalsmith-debug post-excerpts +2ms
  metalsmith-debug post-permalinks +1ms
  metalsmith-debug post-templates +186ms
  metalsmith-debug post-assets +1ms
  metalsmith-debug post-sass +1ms
  metalsmith-debug post-prefixer +1ms
[metalsmith-watch] ✔︎ 12 files reloaded
[metalsmith-watch] ✔︎ src/blog/posts/this-is-a-post.md changed
[metalsmith-watch] - Updating 1 file...
  metalsmith-debug start timing +6m
  metalsmith-debug post-metadata +0ms
  metalsmith-debug post-fileMetadata +0ms
  metalsmith-debug post-copy +0ms
  metalsmith-debug post-tags +14s
  metalsmith-debug post-collections +1ms
  metalsmith-debug post-paginate +0ms
  metalsmith-debug post-lunr +2ms
  metalsmith-debug post-markdown +11ms
  metalsmith-debug post-excerpts +33ms
  metalsmith-debug post-permalinks +1ms
  metalsmith-debug post-templates +109ms
  metalsmith-debug post-assets +1ms
  metalsmith-debug post-sass +1ms
  metalsmith-debug post-prefixer +0ms
[metalsmith-watch] ✔︎ 12 files reloaded

metalsmith-tags is nice and fast on first run, and then falls off a cliff on subsequent rebuilds using metalsmith-watch. (Subsequent runs leveled off at 14s, but that's still orders of magnitude slower than any other plugin in the list.) Any guesses what's going on here?

hswolff commented 9 years ago

Haven't used metalsmith-watch so sadly can't help much there.

If you can narrow down exactly what function(s?) seem to take the bulk of the time we can work on optimizing, but at this macro view it's a little hard to know where to start.

Let me know what investigations you uncover though, happy to help.

hswolff commented 9 years ago

Just published 0.10.0 from #18. Try that out for a spin and let me know?

deltamualpha commented 9 years ago

Nice and fast! I'm getting some duplicate articles in my results pages, but that's probably me misusing the plugin somehow.

hswolff commented 9 years ago

Woohoo, progress!

Let me know if you uncover anything with the duplicate post situation. Just checked my blog locally with the new version and it looks ok, but still something I'd like to be sure about.

Going to close this issue. Please open one if you uncover if there's a duplicates issue.