New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hexo 3.0 file loading speed #1124

Closed
YumeMichi opened this Issue Mar 20, 2015 · 14 comments

Comments

9 participants
@YumeMichi

YumeMichi commented Mar 20, 2015

Hi, my hexo was migrated from 2.8 to 3.0 recently, but the speed of file loading was extremely slow.

hexo: 2.8.3
[info] Files loaded in 0.914s
[info] 102 files generated in 1.527s

hexo: 3.0.0
INFO Files loaded in 2.45 min
INFO 101 files generatd in 2.97 s

Can someone help me?

@Xuanwo

This comment has been minimized.

Show comment
Hide comment
@Xuanwo

Xuanwo Mar 20, 2015

Contributor

Wow, It's different for me that Hexo generent faster than 2.8.3

Contributor

Xuanwo commented Mar 20, 2015

Wow, It's different for me that Hexo generent faster than 2.8.3

@wzpan

This comment has been minimized.

Show comment
Hide comment
@wzpan

wzpan Mar 24, 2015

Member

It took me more than one hour to launch the server and render the whole site with 168 files after I upgrade to Hexo 3.0.
In contrast, the server get to work within seconds in Hexo 2.x.

Member

wzpan commented Mar 24, 2015

It took me more than one hour to launch the server and render the whole site with 168 files after I upgrade to Hexo 3.0.
In contrast, the server get to work within seconds in Hexo 2.x.

@jr0cket

This comment has been minimized.

Show comment
Hide comment
@jr0cket

jr0cket Mar 24, 2015

It could be your theme, assuming you are not using the default landscape theme. If you are using the landscape theme,I'd suggest it's either a plugin or something in your content that is tripping up the parsers.

Or it could be an old version of node.js

jr0cket commented Mar 24, 2015

It could be your theme, assuming you are not using the default landscape theme. If you are using the landscape theme,I'd suggest it's either a plugin or something in your content that is tripping up the parsers.

Or it could be an old version of node.js

@celsomiranda

This comment has been minimized.

Show comment
Hide comment
@celsomiranda

celsomiranda Mar 24, 2015

Contributor

Are you using hexo-browsersync @wzpan?

It really seems to slowdown the server startup, even with only a couple of source files.

Contributor

celsomiranda commented Mar 24, 2015

Are you using hexo-browsersync @wzpan?

It really seems to slowdown the server startup, even with only a couple of source files.

@wzpan

This comment has been minimized.

Show comment
Hide comment
@wzpan

wzpan Mar 25, 2015

Member

Hi @jr0cket , @celsomiranda

After profiling I found it's such kind of code that become the bottleneck of loading speed:

   oglsuperbible5-read-only/    # OpenGL SuperBible 5th Edition 代码包
   |                                            
   +--  freeglut-2.6.0/         # freeglut 安装包                   
   |                                                               
   +--  Linux/                  # Linux Makefile 工程文件
   |     |                                               
   |     +----  Chap01/                                  
   |     |        |                                      
   |     |        +---- Block/                           
   |     |                |                              
   |     |                +---- Makefile # Block 程序的Makefile
   |     |                                                     
   |     +----  ...                                            
   |     |                                                     
   |                                                           
   +--  Src/                   # 源代码         
   |     |                                                     
   |     +----  Chap01/                                        
   |     |        |                                            
   |     |        +---- Block/                                 
   |     |                |                                    
   |     |                +---- Block.cpp # Block 程序源文件
   |     |                                                  
   |     +----  ...                                         
   |     |                                                  
   |     |                                                  
   |     +----  GLTools/      # GLTools工具包               
   |     |        |                                         
   |     |        +---- include/  # 头文件                  
   |     |        |      |                                  
   |     |        |      +----  GL/                         
   |     |        |      |                                  
   |     |        |      +----  GLTools.h # GLTools头文件   
   |     |        |      |                                  
   |     |        |      +----  math3d.h  # 矩阵类头文件    
   |     |        |      |                                  
   |     |        |      +----  ...                         
   |     |        |                                         
   |     |        +---- src/     # 源文件                   
   |     |               |                                  
   |     |               +---- GLTools.cpp # GLTools头文件  
   |     |               |                                
   |     |               +---- math3d.cpp  # 矩阵类源文件
   |     |               |                               
   |     |               +---- ...                       
   |     |                                               
   |     +----  Models/                                  
   |     |                                               
   |     +----  OpenEXR/                                 
   |                                                     
   +--  VisualStudio2008/    # VisualStudio 2008 工程文件
   |                                                     
   +--  VisualStudio2010/    # VisualStudio 2010 工程文件
   |                                                     
   +--  XCode/               # XCode 工程文件

It works fine under Hexo 2.x but not under 3.0. So maybe the Highlight.js is to be blamed? You can test the above code under your environment and see whether you come across the same problem.

Member

wzpan commented Mar 25, 2015

Hi @jr0cket , @celsomiranda

After profiling I found it's such kind of code that become the bottleneck of loading speed:

   oglsuperbible5-read-only/    # OpenGL SuperBible 5th Edition 代码包
   |                                            
   +--  freeglut-2.6.0/         # freeglut 安装包                   
   |                                                               
   +--  Linux/                  # Linux Makefile 工程文件
   |     |                                               
   |     +----  Chap01/                                  
   |     |        |                                      
   |     |        +---- Block/                           
   |     |                |                              
   |     |                +---- Makefile # Block 程序的Makefile
   |     |                                                     
   |     +----  ...                                            
   |     |                                                     
   |                                                           
   +--  Src/                   # 源代码         
   |     |                                                     
   |     +----  Chap01/                                        
   |     |        |                                            
   |     |        +---- Block/                                 
   |     |                |                                    
   |     |                +---- Block.cpp # Block 程序源文件
   |     |                                                  
   |     +----  ...                                         
   |     |                                                  
   |     |                                                  
   |     +----  GLTools/      # GLTools工具包               
   |     |        |                                         
   |     |        +---- include/  # 头文件                  
   |     |        |      |                                  
   |     |        |      +----  GL/                         
   |     |        |      |                                  
   |     |        |      +----  GLTools.h # GLTools头文件   
   |     |        |      |                                  
   |     |        |      +----  math3d.h  # 矩阵类头文件    
   |     |        |      |                                  
   |     |        |      +----  ...                         
   |     |        |                                         
   |     |        +---- src/     # 源文件                   
   |     |               |                                  
   |     |               +---- GLTools.cpp # GLTools头文件  
   |     |               |                                
   |     |               +---- math3d.cpp  # 矩阵类源文件
   |     |               |                               
   |     |               +---- ...                       
   |     |                                               
   |     +----  Models/                                  
   |     |                                               
   |     +----  OpenEXR/                                 
   |                                                     
   +--  VisualStudio2008/    # VisualStudio 2008 工程文件
   |                                                     
   +--  VisualStudio2010/    # VisualStudio 2010 工程文件
   |                                                     
   +--  XCode/               # XCode 工程文件

It works fine under Hexo 2.x but not under 3.0. So maybe the Highlight.js is to be blamed? You can test the above code under your environment and see whether you come across the same problem.

@tommy351

This comment has been minimized.

Show comment
Hide comment
@tommy351

tommy351 Mar 25, 2015

Member

@wzpan Maybe you're right. Highlight.js is super slow when it's trying to detect languages automatically. You can try to specify the language of code block to plain to avoid auto detect.

``` plain
something
```
Member

tommy351 commented Mar 25, 2015

@wzpan Maybe you're right. Highlight.js is super slow when it's trying to detect languages automatically. You can try to specify the language of code block to plain to avoid auto detect.

``` plain
something
```
@wzpan

This comment has been minimized.

Show comment
Hide comment
@wzpan

wzpan Mar 25, 2015

Member

Yup that's a good scenario. Solved it. Thanks @tommy351 .

Member

wzpan commented Mar 25, 2015

Yup that's a good scenario. Solved it. Thanks @tommy351 .

@tommy351

This comment has been minimized.

Show comment
Hide comment
@tommy351
Member

tommy351 commented Mar 25, 2015

Ref #1036

@YumeMichi

This comment has been minimized.

Show comment
Hide comment
@YumeMichi

YumeMichi Mar 26, 2015

Thank you for everyone.

YumeMichi commented Mar 26, 2015

Thank you for everyone.

@YumeMichi YumeMichi closed this Mar 26, 2015

@kiwenlau

This comment has been minimized.

Show comment
Hide comment
@kiwenlau

kiwenlau Jun 26, 2015

Using 'plain' can help improve file load performance. I've verified this. My blog has 5 posts. The original load time is 5.39s and it becomes 4.5s after add "plain" for code blocks.

However, It seems that it still need to be optimized

kiwenlau commented Jun 26, 2015

Using 'plain' can help improve file load performance. I've verified this. My blog has 5 posts. The original load time is 5.39s and it becomes 4.5s after add "plain" for code blocks.

However, It seems that it still need to be optimized

@tommy351

This comment has been minimized.

Show comment
Hide comment
@tommy351

tommy351 Jun 26, 2015

Member

@kiwenlau In Hexo 3.1, you can disable auto detect for highlight.

highlight:
  auto_detect: false
Member

tommy351 commented Jun 26, 2015

@kiwenlau In Hexo 3.1, you can disable auto detect for highlight.

highlight:
  auto_detect: false
@wzpan

This comment has been minimized.

Show comment
Hide comment
@wzpan

wzpan Jun 26, 2015

Member

FYI, I wrote a script to help me detect all the plain codes without plain flag and append the flag to them.
It only works for codes that surrounded with three back quotes rather than {% codeblock %}...{% endcodeblock %} (You can easily extend it to support that though).

Remember to backup your posts before executing this script, since it will do the job in-place.

Script address: https://gist.github.com/wzpan/7db9b0888f06a8d6ff8c

Member

wzpan commented Jun 26, 2015

FYI, I wrote a script to help me detect all the plain codes without plain flag and append the flag to them.
It only works for codes that surrounded with three back quotes rather than {% codeblock %}...{% endcodeblock %} (You can easily extend it to support that though).

Remember to backup your posts before executing this script, since it will do the job in-place.

Script address: https://gist.github.com/wzpan/7db9b0888f06a8d6ff8c

@kiwenlau

This comment has been minimized.

Show comment
Hide comment
@kiwenlau

kiwenlau Jun 26, 2015

@tommy351 I've disabled auto detect for highlight, but it can not improve file load time, which is 4.57s(the load time is 4.5s with auto detect).

I think there will be some other reasons for this.

FYI. Following is the output of "hexo version"

hexo: 3.1.1
os: Linux 3.13.0-32-generic linux x64
http_parser: 1.0
node: 0.10.25
v8: 3.14.5.9
ares: 1.10.0
uv: 0.10.23
zlib: 1.2.8
modules: 11
openssl: 1.0.1f

kiwenlau commented Jun 26, 2015

@tommy351 I've disabled auto detect for highlight, but it can not improve file load time, which is 4.57s(the load time is 4.5s with auto detect).

I think there will be some other reasons for this.

FYI. Following is the output of "hexo version"

hexo: 3.1.1
os: Linux 3.13.0-32-generic linux x64
http_parser: 1.0
node: 0.10.25
v8: 3.14.5.9
ares: 1.10.0
uv: 0.10.23
zlib: 1.2.8
modules: 11
openssl: 1.0.1f
@jingb

This comment has been minimized.

Show comment
Hide comment
@jingb

jingb Aug 22, 2017

@tommy351
highlight:
enable: false

The _config.yml file in the theme's(mine is Next) directory or the main site directory ?
It will throw some errors below and faild to start the hexo server when I add the config to the _config.yml in the main site directory. And if I add the config to the _config.yml in the theme's directory, it has no errors but seems useless because it is still very slow when launching the hexo server. Did I do any wrong? Thanks for your answer.

FATAL duplicated mapping key at line 111, column 1:
^
Error
at generateError (/Users/jingb/jingbBlog/node_modules/js-yaml/lib/js-yaml/loader.js:162:10)
at throwError (/Users/jingb/jingbBlog/node_modules/js-yaml/lib/js-yaml/loader.js:168:9)
at storeMappingPair (/Users/jingb/jingbBlog/node_modules/js-yaml/lib/js-yaml/loader.js:305:7)

jingb commented Aug 22, 2017

@tommy351
highlight:
enable: false

The _config.yml file in the theme's(mine is Next) directory or the main site directory ?
It will throw some errors below and faild to start the hexo server when I add the config to the _config.yml in the main site directory. And if I add the config to the _config.yml in the theme's directory, it has no errors but seems useless because it is still very slow when launching the hexo server. Did I do any wrong? Thanks for your answer.

FATAL duplicated mapping key at line 111, column 1:
^
Error
at generateError (/Users/jingb/jingbBlog/node_modules/js-yaml/lib/js-yaml/loader.js:162:10)
at throwError (/Users/jingb/jingbBlog/node_modules/js-yaml/lib/js-yaml/loader.js:168:9)
at storeMappingPair (/Users/jingb/jingbBlog/node_modules/js-yaml/lib/js-yaml/loader.js:305:7)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment