Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

performance improvements #519

Closed
wants to merge 3 commits into from

3 participants

@lucagrulla

I did some profiling and noticed how jekyll spends a lot of time in doing comparisons, namely Post comparison (via <=>).

Post comparison is actually mostly called from site_payload, that generates a on-demand hash containing (among others) the ordered list of posts. In methods where site_payload is called more than once I just introduced a local variable to reduce the multiple calls and the additional comparison.

Just this in my benchmark gives an improvement in the time needed to generate the site of a 20-25%(particularly useful for big site, with over 1000 between pages and posts).

@tmm1

:+1:

What version of ruby were you benchmarking with?

@lucagrulla

I am using 1.9.2p290(on a MacBookAir 2.13Ghz Core 2 Duo 4GB RAM).

lib/jekyll/post.rb
@@ -183,10 +183,11 @@ def related_posts(posts)
# Returns nothing
def render(layouts, site_payload)
# construct payload
+ sp = site_payload
@tmm1
tmm1 added a note

Isn't site_payload already a local variable here? It's passed into the function.

yes, you re totally right.
my bad.

I'm going to revert this one fix in my fork.
Dp you want a new pull request ?

@tmm1
tmm1 added a note

You can force push to this pull request's branch.

Thanks.
I can actually see my last commit on my fork reverting that code down here in this pull request thread.
I guess it's now part of the pull request then.

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

hey I can see that the pull request has been merged in master (right now it's the last commit). Is then the right time to close it as well ?

@parkr
Owner

Merged in 7d88f72.

@parkr parkr closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 3, 2012
  1. @lucagrulla
  2. @lucagrulla

    additional performance improvement: using a local variable for site_p…

    lucagrulla authored
    …ayload in post render to reduce the number of calls
Commits on Mar 4, 2012
  1. @lucagrulla

    actually reverted last fix.It was already local variable being passed…

    lucagrulla authored
    … into the method. late night mistake :-P
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/jekyll/site.rb
View
5 lib/jekyll/site.rb
@@ -195,12 +195,13 @@ def generate
#
# Returns nothing.
def render
+ payload = site_payload
self.posts.each do |post|
- post.render(self.layouts, site_payload)
+ post.render(self.layouts, payload)
end
self.pages.each do |page|
- page.render(self.layouts, site_payload)
+ page.render(self.layouts, payload)
end
self.categories.values.map { |ps| ps.sort! { |a, b| b <=> a } }
Something went wrong with that request. Please try again.