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

Implement a cache within the `where` filter #6868

Merged
merged 1 commit into from Apr 12, 2018

Conversation

Projects
None yet
5 participants
@ashmaroli
Member

ashmaroli commented Mar 22, 2018

This is improve build times in sites that use multiple calls to the where filter with the same input and property parameter.
The official docs site for Jekyll contains multiple uses of where filter with input: site.docs, property: url

The cache implementation resulted in reduced calls to Jekyll::Filters#item_property.
( via method_profiler gem on Windows 7 with Ruby 2.3 ):

Before:

MethodProfiler results for: Jekyll::Filters
+---------------------------+----------+----------+--------------+------------+-------------+
| Method                    | Min Time | Max Time | Average Time | Total Time | Total Calls |
+---------------------------+----------+----------+--------------+------------+-------------+
| #xml_escape               | 0.000s   | 0.012s   | 0.000s       | 0.030s     | 216         |
| #where_exp                | 0.000s   | 0.003s   | 0.001s       | 0.010s     | 9           |
| #where                    | 0.001s   | 0.021s   | 0.005s       | 19.845s    | 3698        |
| #uri_escape               | 0.000s   | 0.001s   | 0.000s       | 0.064s     | 202         |
| #smartify                 | 0.012s   | 0.013s   | 0.013s       | 0.139s     | 11          |
| #parse_condition          | 0.000s   | 0.000s   | 0.000s       | 0.001s     | 9           |
| #normalize_whitespace     | 0.000s   | 0.000s   | 0.000s       | 0.015s     | 427         |
| #markdownify              | 0.001s   | 0.004s   | 0.001s       | 0.575s     | 407         |
| #jsonify                  | 0.003s   | 0.005s   | 0.003s       | 0.438s     | 133         |
| #item_property            | 0.000s   | 0.013s   | 0.000s       | 3.792s     | 180714      |
| #as_liquid                | 0.000s   | 0.000s   | 0.000s       | 0.002s     | 133         |
| #array_to_sentence_string | 0.000s   | 0.000s   | 0.000s       | 0.003s     | 198         |
+---------------------------+----------+----------+--------------+------------+-------------+

After:


MethodProfiler results for: Jekyll::Filters
+---------------------------+----------+----------+--------------+------------+-------------+
| Method                    | Min Time | Max Time | Average Time | Total Time | Total Calls |
+---------------------------+----------+----------+--------------+------------+-------------+
| #xml_escape               | 0.000s   | 0.012s   | 0.000s       | 0.030s     | 216         |
| #where_exp                | 0.000s   | 0.005s   | 0.001s       | 0.012s     | 9           |
| #where                    | 0.000s   | 0.028s   | 0.003s       | 10.260s    | 3698        |
| #uri_escape               | 0.000s   | 0.002s   | 0.000s       | 0.069s     | 202         |
| #smartify                 | 0.012s   | 0.014s   | 0.012s       | 0.134s     | 11          |
| #parse_condition          | 0.000s   | 0.000s   | 0.000s       | 0.001s     | 9           |
| #normalize_whitespace     | 0.000s   | 0.000s   | 0.000s       | 0.015s     | 427         |
| #markdownify              | 0.001s   | 0.018s   | 0.002s       | 0.640s     | 407         |
| #jsonify                  | 0.003s   | 0.008s   | 0.003s       | 0.460s     | 133         |
| #item_property            | 0.000s   | 0.007s   | 0.000s       | 1.926s     | 90371       |
| #as_liquid                | 0.000s   | 0.000s   | 0.000s       | 0.002s     | 133         |
| #array_to_sentence_string | 0.000s   | 0.000s   | 0.000s       | 0.003s     | 198         |
+---------------------------+----------+----------+--------------+------------+-------------+
@DirtyF

⚡️ Build time measure: ~1s faster on Jekyll's website

@Crunch09

LGTM! 👍

@ashmaroli ashmaroli added this to the v3.8.0 milestone Apr 9, 2018

@pathawks

This comment has been minimized.

Member

pathawks commented Apr 12, 2018

@jekyllbot: :shipit: +minor

@jekyllbot jekyllbot merged commit 053b522 into jekyll:master Apr 12, 2018

3 checks passed

WIP ready for review
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@ashmaroli ashmaroli deleted the ashmaroli:cache-in-where-filters branch Apr 12, 2018

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