hexojs / hexo

A fast, simple & powerful blog framework, powered by Node.js.
https://hexo.io
MIT License
39.54k stars 4.86k forks source link

hexo generate 耗时太长 #533

Closed wgzhao closed 10 years ago

wgzhao commented 10 years ago

使用当前最新版的hexo,Mac平台下,300+文章量,执行 hexo g --debug 耗时长达356.396s!! 比octopress的耗时还要长。

在1000+文章量的情况下,耗时长达不可思议的38分钟。 完全无法接受了。

附件是debug文件(修改了后缀) debug

tommy351 commented 10 years ago

I can't see the picture. Please post the debug message directly.

wgzhao commented 10 years ago

下面是当时的日志,重复的部分删除了,否则太长了

date: 2014-03-15 22:25:01.372 argv: node /usr/local/bin/hexo g --debug os: Darwin 13.1.0 darwin x64 version: hexo: 2.5.1 http_parser: 1.0 node: 0.10.26 v8: 3.14.5.9 ares: 1.9.0-DEV uv: 0.10.25 zlib: 1.2.3 modules: 11

openssl: 1.0.1e

[debug] 22:25:01.708 Config file loaded [debug] 22:25:01.714 Version info checked successfully [debug] 22:25:02.104 Processed: LICENSE [debug] 22:25:02.105 Processed: README.md [debug] 22:25:02.112 Processed: source/css/_base/layout.styl [debug] 22:25:02.112 Processed: source/css/_base/utils.styl [debug] 22:25:02.113 Processed: source/css/_base/variable.styl ... ... [debug] 22:25:03.291 Processed: layout/_partial/post/title.ejs [debug] 22:25:11.698 Processed: _posts/2004-10-19-To-expand-the-functions-of-wget.md [debug] 22:25:11.700 Processed: _posts/2004-10-19-XSLT-instructions-finishing.md [debug] 22:25:11.700 Processed: _posts/2004-10-19-paging-using-javascript-xml-xslt.md ........ ......... [debug] 22:25:11.776 Processed: _posts/2012-08-22-some-way-to-io-statistics-on-linux.md [debug] 22:25:11.776 Processed: _posts/2009-07-16-troubleshooting-kernel-panic.md [debug] 22:25:11.776 Processed: _posts/2012-12-30-some-tips-for-mac-os-x.md [debug] 22:25:11.776 Processed: _posts/2009-07-22-recover-deleted-files-on-ext3-filesystem.md [debug] 22:25:11.777 Processed: _posts/2012-08-14-upgrade-blog-environment.md [debug] 22:25:11.777 Processed: _posts/2012-01-16-5-simple-ways-to-troubleshoot-using-strace.md [debug] 22:25:11.792 Cache saved [info] 22:25:12.818 Files loaded in 11.056s [debug] 22:25:12.825 Public folder not exists. No need to clear public folder. [debug] 22:25:12.831 Render archive: archives/ [debug] 22:25:12.834 Render archive: archives/page/2/ [debug] 22:25:12.835 Render archive: archives/page/3/ [debug] 22:25:12.835 Render archive: archives/page/4/ [debug] 22:25:12.835 Render archive: archives/page/5/ [debug] 22:25:12.836 Render archive: archives/page/6/ [debug] 22:25:12.836 Render archive: archives/page/7/ [debug] 22:25:12.837 Render archive: archives/page/8/ [debug] 22:25:12.838 Render archive: archives/page/9/ [debug] 22:25:12.839 Render archive: archives/page/10/ .... .... [debug] 22:25:12.903 Render archive: archives/2012/01/ [debug] 22:25:12.903 Render archive: archives/2012/04/ [debug] 22:25:12.904 Render archive: archives/2012/08/ [debug] 22:25:12.904 Render archive: archives/2012/12/ [debug] 22:25:12.904 Render category: categories/Linux技术/ [debug] 22:25:12.905 Render category: categories/WEB开发/ ... ... [debug] 22:25:12.913 Render category: categories/strace/sys call/troubleshooting/ [debug] 22:25:12.914 Render index: [debug] 22:25:12.914 Render index: page/2/ [debug] 22:25:12.914 Render index: page/3/ [debug] 22:25:12.915 Render index: page/4/ [debug] 22:25:12.915 Render index: page/5/ [debug] 22:25:12.916 Render index: page/6/ [debug] 22:25:12.916 Render index: page/7/ ... ... [debug] 22:25:12.926 Render index: page/32/ [debug] 22:25:12.927 Render post: 2012/12/30/some-tips-for-mac-os-x/ [debug] 22:25:12.927 Render post: 2012/08/24/generate-random-strings-and-other-tips-on-postgresql/ .... .... [debug] 22:25:13.103 Render post: 2004/10/19/XSLT-instructions-finishing/ [debug] 22:25:13.104 Render post: 2004/10/19/paging-using-javascript-xml-xslt/ [debug] 22:25:13.104 Render post: 2004/10/19/To-expand-the-functions-of-wget/ [create] 22:31:08.463 Public: fancybox/blank.gif [create] 22:31:08.464 Public: fancybox/fancybox_overlay.png [create] 22:31:08.464 Public: fancybox/fancybox_loading.gif [create] 22:31:08.465 Public: fancybox/fancybox_loading@2x.gif [create] 22:31:08.467 Public: fancybox/fancybox_sprite.png [create] 22:31:08.467 Public: fancybox/fancybox_sprite@2x.png [create] 22:31:08.468 Public: fancybox/jquery.fancybox.css [create] 22:31:08.468 Public: fancybox/jquery.fancybox.pack.js [create] 22:31:08.469 Public: js/gallery.js [create] 22:31:08.470 Public: js/jquery.imagesloaded.min.js [create] 22:31:08.472 Public: css/font/fontawesome-webfont.eot [create] 22:31:08.472 Public: css/font/fontawesome-webfont.svg [create] 22:31:08.473 Public: css/font/fontawesome-webfont.woff [create] 22:31:08.476 Public: css/style.css [create] 22:31:08.477 Public: archives/index.html [create] 22:31:08.478 Public: archives/page/2/index.html [create] 22:31:08.481 Public: archives/page/3/index.html [create] 22:31:08.482 Public: archives/page/5/index.html ... ... [create] 22:31:08.711 Public: archives/2012/12/index.html [create] 22:31:08.712 Public: archives/2012/08/index.html [create] 22:31:08.713 Public: categories/WEB开发/index.html [create] 22:31:08.718 Public: categories/技术技巧/index.html ... ... [create] 22:31:08.739 Public: categories/strace/sys call/troubleshooting/index.html [create] 22:31:08.743 Public: index.html [create] 22:31:08.744 Public: page/2/index.html [create] 22:31:08.744 Public: page/3/index.html ... ... [create] 22:31:08.788 Public: page/32/index.html [create] 22:31:08.792 Public: 2012/12/30/some-tips-for-mac-os-x/index.html [create] 22:31:08.793 Public: 2012/08/21/explaining-the-postgresql-query-optimizer/index.html [create] 22:31:08.794 Public: 2012/08/24/generate-random-strings-and-other-tips-on-postgresql/index.html [create] 22:31:08.795 Public: 2012/08/22/some-way-to-io-statistics-on-linux/index.html [create] 22:31:08.797 Public: 2012/08/15/create-datediff-function-in-postgresql/index.html ... ... [create] 22:31:09.215 Public: 2004/10/19/To-expand-the-functions-of-wget/index.html

wgzhao commented 10 years ago

从日志来看,是等待了很长一段时间才开始写发布文件,怀疑是我的硬盘问题,切换到一台安装有SSD硬盘的机器上跑hexo generate,依然如此。

tommy351 commented 10 years ago

如果可以的話,可以把整個網站打包寄給我,我試著跑profiling看是那個環節花特別多時間。

wgzhao commented 10 years ago

https://github.com/wgzhao/blog-hexo.git

谢谢!

tommy351 commented 10 years ago

剛剛測試了一下,耗時的確非常異常,profiler中顯示/usr/lib/system/libsystem_kernel.dylib佔用了54.2%的CPU時間,可能是某些東西堵塞了。

wgzhao commented 10 years ago

会不会是某个帖子的某个语法或者格式触发了一个异常?

tommy351 commented 10 years ago

Profiling result: https://gist.github.com/tommy351/9595962

wgzhao commented 10 years ago

写了个脚本,逐一把帖子按照时间先后顺序加入到_posts目录,然后生成,大致时间如下:

帖子数 耗时(s)
104 60
112 70
126 90
134 100
142 120
tommy351 commented 10 years ago

此討論將移至 #550