-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Performance Data of Hexo #3663
Comments
I had not heard of that setting so I wanted to help provide some context: |
@SukkaW Please comment out this line, rerun your tests and see how results are https://github.com/hexojs/hexo/blob/master/lib/plugins/filter/index.js#L14 spoiler alert |
@ppoffice Yeah, I do have received a notice that |
@ppoffice The result is out: This is baseline Set Comment out the |
After having a look at git blame, I found out that the
And those are plugins and filters that used |
@SukkaW Edit |
@ppoffice |
https://gitlab.com/JiangTJ/performance-test-hexo/-/jobs/272854627 When there are too many tags, some of the theme code can lead to very long generation times, which I think should be avoided in hexo. See: |
I have created a PR about this. Anyway, I totally disagree to use cheerio traversing all the HTML generated, just for add an |
open_graph approach? This also means (with that approach) Ultimately, it depends how much we care about Wappalyzer statistics. Judging by the performance benchmark, maybe it's not worth it. I'm very interested if commenting out the I'm preparing a PR to move meta_generator from filter to helper. Edit: #3669 Another (less breaking) approach by using string.replace() instead |
@curbengh Currently the theme I used in performance test, hexo-theme-suka, generates Open Graph manually without using Hexo helper: https://github.com/SukkaW/hexo-theme-suka/blob/master/layout/_partial/head/open-graph.ejs Maybe I would bring up a test with hexo-theme-landscape to test the performance of open-graph helper. Also, cheerio is very slow... Especially when it is needed to let cheerio ran through all the hundreds of, maybe thousands of HTML files generated. |
I just bring up the benchmark for Raw test log can be found here: https://travis-ci.com/theme-suka/performance-test/builds/123338750 Teat A with Teat B with sed -i "s|<%- open_graph({twitter_id: theme.twitter, fb_admins: theme.fb_admins, fb_app_id: theme.fb_app_id}) %>||g" themes/landscape/layout/_partial/head.ejs It is 28% faster without Update
|
I wonder if cheerio@1.0.0rc.3 is faster. It's currently unusable for non-ASCII chars though, but it shouldn't affect the benchmarking if we disregard how the rendered file looks like. If you need the rendered file to be valid, you can use |
@curbengh Edit During the test case, although there are 300 posts used in the benchmark, but none of them includes images, which means even without images in the content, cheerio might still slow down the speed. |
I like the idea, though ES6
your proposed fix is supposed to fix it, yes? |
A benchmark of Teat A with hexo-theme-landscape and meta_generator set to false, and cheer io is always required. Teat B with hexo-theme-landscape and meta_generator set to false, and only require cheerio when if (!images.length && content) {
images = images.slice();
if (content.includes('<img')) {
if (!cheerio) cheerio = require('cheerio');
const $ = cheerio.load(content);
$('img').each(function() {
const src = $(this).attr('src');
if (src) images.push(src);
});
}
} As those 300 posts includes no images, generate speed is now 17% faster. I will open a PR then. UpdatesI have updated Then Test A Test B Now it is only 4% faster. |
@ppoffice Is it possible you can show me an example of this? Also we hardly need cheerio for simple dom operations. Possibly we can just use string templates for the simple cases. |
@tcrowe I have listed the helpers & filters that use cheerio. Maybe we can replace them with regex. |
I'm also interested in the performance impact of Test A Baseline, Test B
I can see only a little improvements on generating speed, less than It might because |
I just found |
I have noticed that during those benchmarks, my Test A Baseline, with Test B Disable the toc. Bingo! Then I looked at the hexo/lib/plugins/helper/toc.js Lines 9 to 14 in 49c7d4a
Most of the theme use toc(page.content) which means when a theme is using |
I created a separate issue (#3677) to track cheerio-related plugins. Maybe we could also create a separate issue to find out improper uses of Promise. Replacement for highlight.js is already discussed in #1036 and it's part of the roadmap. |
This issue has been automatically marked as stale because lack of recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Latest Benchmark
It is the current baseline of Hexo
(Travis CI, Ubuntu 16, Node.js 10)
Past Benchmark
I have ran a performance test for Hexo using Travis CI with 300 posts(All posts have 1 category and 5 tags, and all markdown styles and large amounts of code blocks are included in each .md file)
All the css, js & images are deleted before
hexo clean && hexo g
to make sure every file generated is rendered HTML.Raw log can be seen here.
It seems that
Disable Fragment Cache
will make hexo35%
slower,Enable highlight.js
will make hexo45%
slower.And even with Fragment enabled and Highlight.js disabled, hexo can only render 33 HTML per second.
The text was updated successfully, but these errors were encountered: