Skip to content
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

Speed up the Jekyll build times for large sites #1163

Merged
merged 1 commit into from
Aug 7, 2023

Conversation

cotes2020
Copy link
Owner

@cotes2020 cotes2020 commented Aug 7, 2023

Description

If the site has a large number of posts, and a lot of metadata (categories and tags from posts), then rendering the _includes/related-posts.html will be a bottleneck in build time.

Practical example:

With 1082 posts, 94 categories, and 26 tags, on a machine configured with Intel Core i7 CPU and 16GB RAM, the site's build time details are as follows:

Build Process Summary:

| PHASE    |     TIME |
+----------+----------+
| RESET    |   0.0003 |
| READ     |  34.1979 |
| GENERATE |   0.1318 |
| RENDER   | 123.6652 |
| CLEANUP  |   0.1728 |
| WRITE    |   0.7328 |


Site Render Stats:

| Filename                                                                                  | Count |     Bytes |    Time |
+-------------------------------------------------------------------------------------------+-------+-----------+---------+
| _layouts/page.html                                                                        |  1319 | 53683.56K | 107.046 |
| _includes/related-posts.html                                                              |  1085 | 31899.44K | 104.668 |
| _layouts/default.html                                                                     |  1319 | 87090.83K |   8.098 |
| _includes/head.html                                                                       |  1319 | 15723.82K |   4.609 |
| _layouts/home.html                                                                        |   109 |  2953.91K |   4.168 |
| _layouts/post.html                                                                        |  1085 |  7249.28K |   2.390 |
| _includes/js-selector.html                                                                |  1319 |  1149.73K |   1.207 |
| _includes/sidebar.html                                                                    |  1319 |  4068.55K |   1.203 |
| _includes/post-paginator.html                                                             |   109 |  1086.50K |   1.085 |
| _includes/datetime.html                                                                   |  7383 |  1248.77K |   0.881 |
| _includes/read-time.html                                                                  |  1085 |   293.66K |   0.836 |
| _includes/post-sharing.html                                                               |  1085 |  2381.29K |   0.747 |
| _includes/jsdelivr-combine.html                                                           |  1319 |   873.32K |   0.595 |
| _includes/post-nav.html                                                                   |  1085 |   663.21K |   0.560 |
| _includes/refactor-content.html                                                           |  1196 | 11139.09K |   0.491 |
| _includes/topbar.html                                                                     |  1319 |  1357.49K |   0.356 |
...
| _tabs/about.md                                                                            |     1 |     0.30K |   0.000 |
                    done in 158.944 seconds.

Type of change

  • Improvement (refactoring and improving code)

Additional context

How has this been tested

For the same hardware with the same site files, executing the bundle exec jekyll b --profile command results in a significant reduction in build time.

Build Process Summary:

| PHASE    |    TIME |
+----------+---------+
| RESET    |  0.0002 |
| READ     | 32.4250 |
| GENERATE |  0.0847 |
| RENDER   | 32.1113 |
| CLEANUP  |  0.2832 |
| WRITE    |  0.8849 |


Site Render Stats:

| Filename                                                                                  | Count |     Bytes |   Time |
+-------------------------------------------------------------------------------------------+-------+-----------+--------+
| _layouts/page.html                                                                        |  1319 | 22114.94K | 17.042 |
| _includes/related-posts.html                                                              |  1085 |   330.82K | 14.423 |
| _layouts/default.html                                                                     |  1319 | 55522.21K |  6.963 |
| _layouts/home.html                                                                        |   109 |  2953.91K |  3.573 |
| _includes/head.html                                                                       |  1319 | 15723.82K |  3.251 |
| _layouts/post.html                                                                        |  1085 |  7249.28K |  2.677 |
| _includes/js-selector.html                                                                |  1319 |  1149.73K |  1.321 |
| _includes/sidebar.html                                                                    |  1319 |  4068.55K |  1.285 |
| _includes/post-paginator.html                                                             |   109 |  1086.50K |  1.097 |
| _includes/read-time.html                                                                  |  1085 |   293.66K |  0.922 |
| _includes/post-sharing.html                                                               |  1085 |  2381.29K |  0.917 |
| _includes/post-nav.html                                                                   |  1085 |   663.21K |  0.784 |
| _includes/jsdelivr-combine.html                                                           |  1319 |   873.32K |  0.663 |
| _includes/refactor-content.html                                                           |  1196 | 11139.09K |  0.530 |
| _includes/datetime.html                                                                   |  4128 |   733.82K |  0.497 |
| _includes/topbar.html                                                                     |  1319 |  1357.49K |  0.380 |
...
| _tabs/about.md                                                                            |     1 |     0.30K |  0.000 |

                    done in 65.825 seconds.

Refactor `_includes/related-posts.html`
@cotes2020 cotes2020 marked this pull request as ready for review August 7, 2023 22:18
@cotes2020 cotes2020 changed the title Speed up the Jekyll build times Speed up the Jekyll build times for large sites Aug 7, 2023
@cotes2020 cotes2020 merged this pull request into master Aug 7, 2023
@cotes2020 cotes2020 deleted the feature/speed-up-build-times branch August 7, 2023 22:47
cotes2020 added a commit that referenced this pull request Aug 8, 2023
Refactor `_includes/related-posts.html`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant