levelupcc / level-up

LevelUp project website
https://level-up.cc
32 stars 9 forks source link

Improve build times #166

Closed joncamfield closed 2 years ago

joncamfield commented 4 years ago

Currently building the LU site takes quite a few minutes. profiling this reveals a few includes and layouts which are rebuilt for each page and take a ton of time. It is worth considering using a caching plugin to reduce the build time (at the cost of, for example, not highlighting the nav per section:

Here is the --profile report:

| Filename | Count | Bytes | Time | -------------------------------------------------------------------------+-------+----------+--------- _includes/navigation.html | 165 | 5995.59K | 1935.426 _layouts/default.html | 165 | 5934.89K | 544.668 _includes/site-index.html | 1 | 31.18K | 12.578 _includes/breadcrumb.html | 164 | 1436.71K | 11.199 _layouts/content-page.html | 145 | 2556.46K | 10.330 _layouts/site-map.html | 1 | 10.99K | 3.577 _layouts/module.html | 15 | 165.10K | 0.906 _includes/head.html | 165 | 155.58K | 0.168 _layouts/page-index.html | 13 | 35.94K | 0.160 _layouts/resource.html | 2 | 17.91K | 0.135 _includes/header.html | 165 | 792.61K | 0.078 _includes/footer.html | 165 | 49.63K | 0.060 _layouts/news.html | 1 | 10.96K | 0.036 _layouts/page.html | 1 | 3.29K | 0.021 _includes/logo.html | 165 | 757.00K | 0.016 _layouts/curriculum.html | 1 | 5.95K | 0.012 feed.xml | 1 | 7.78K | 0.005 _includes/post.html | 3 | 7.67K | 0.002 _layouts/news-updates.html | 1 | 0.76K | 0.001 index.html | 1 | 1.30K | 0.001 _includes/post-index.html | 1 | 0.75K | 0.000 _pages/before-an-event/psychosocial-underpinnings-of-security-training/1-getting-grips-with-fear/1-getting-grips-with-fear.md | 1 | 21.54K | 0.000 _pages/curriculum/safer-communication/pgp-gpg-email-encryption/deepening/thunderbird-and-gpg/thunderbird-and-gpg.md | 1 | 20.79K | 0.000 _pages/before-an-event/creating-safe-spaces/creating-safe-spaces.md | 1 | 22.63K | 0.000 _pages/curriculum/malware-protection/using-antivirus-tools/activity-discussion/analyzing-potentially-harmful-email/analyzing-potentially-harmful-email.md | 1 | 12.99K | 0.000 _pages/curriculum/social-media-safety/social-media-safety-awareness/input/social-media-essentials/social-media-essentials.md | 1 | 17.57K | 0.000 _pages/before-an-event/psychosocial-underpinnings-of-security-training/3-raise-lower-pressure/3-raise-lower-pressure.md | 1 | 18.45K | 0.000 _pages/curriculum/safer-browsing/anonymity-and-circumvention/input/how-censorship-and-circumvention-work/how-censorship-and-circumvention-work.md | 1 | 19.10K | 0.000 _pages/curriculum/safer-communication/pgp-gpg-email-encryption/input/why-email-encryption-matters/why-email-encryption-matters.md | 1 | 15.40K | 0.000 _pages/before-an-event/preparing-sessions-using-adids/preparing-sessions-using-adids.md | 1 | 14.59K | 0.000 _pages/curriculum/safer-browsing/identity-protection-privacy/input/maintaining-privacy-while-browsing-web/maintaining-privacy-while-browsing-web.md | 1 | 11.43K | 0.000 _pages/curriculum/protecting-data/data-backup-basics/deepening/learning-how-to-backup-your-data/learning-how-to-backup-your-data.md | 1 | 13.29K | 0.000 _pages/curriculum/mobile-safety/how-mobile-networks-work/input/how-do-mobile-devices-work/how-do-mobile-devices-work.md | 1 | 16.34K | 0.000 _pages/community/community-resources-and-tools/community-resources-and-tools.md | 1 | 17.08K | 0.000 _pages/before-an-event/psychosocial-underpinnings-of-security-training/4-traumatic-stress-reactions/4-traumatic-stress-reactions.md | 1 | 11.79K | 0.000 _pages/curriculum/protecting-data/creating-and-managing-strong-passwords/input/safer-password-practices/safer-password-practices.md | 1 | 14.96K | 0.000 _pages/curriculum/malware-protection/safer-software-updating/input/safer-software-practice-full/safer-software-practice-full.md | 1 | 10.49K | 0.000 _pages/curriculum/safer-workspaces/tails/deepening/installing-launching-replicating-tails/installing-launching-replicating-tails.md | 1 | 14.72K | 0.000 _pages/curriculum/malware-protection/using-antivirus-tools/input/malware-101/malware-101.md | 1 | 14.81K | 0.000 _pages/curriculum/safer-communication/safer-online-advocacy/input/safe-online-campaigning/safe-online-campaigning.md | 1 | 10.55K | 0.000 _pages/before-an-event/psychosocial-underpinnings-of-security-training/5-emotional-resilience/5-emotional-resilience.md | 1 | 11.41K | 0.000 _pages/you-the-trainer/be-a-better-trainer/be-a-better-trainer.md | 1 | 14.90K | 0.000 _pages/curriculum/rethinking-security/digital-security-motivations-resistances-and-barriers/activity-discussion/personal-perceptions-of-security/personal-perceptions-of-security.md | 1 | 13.75K | 0.000 _pages/curriculum/safer-communication/pgp-gpg-email-encryption/activity-discussion/how-email-works/how-email-works.md | 1 | 9.49K | 0.000 _pages/curriculum/malware-protection/safer-software-updating/input/safer-software-practice-short/safer-software-practice-short.md | 1 | 10.64K | 0.000 _pages/you-the-trainer/setting-expectations-for-participants-organizers-and-yourself/setting-expectations-for-participants-organizers-and-yourself.md | 1 | 12.61K | 0.000 _pages/before-an-event/planning-your-event-agenda/the-participant-driven-agenda/the-participant-driven-agenda.md | 1 | 8.54K | 0.000 _pages/before-an-event/using-levelup-trainers-curriculum/using-levelup-trainers-curriculum.md | 1 | 12.19K | 0.000 _pages/before-an-event/psychosocial-underpinnings-of-security-training/2-anxiety-pressure-gauge/2-anxiety-pressure-gauge.md | 1 | 10.96K | 0.000 _pages/curriculum/safer-browsing/https-ssl/input/internet-authenticity-confidentiality/internet-authenticity-confidentiality.md | 1 | 5.05K

joncamfield commented 4 years ago

Here is performance when caching navigation, head, header, and footer includes in the default template. Note that this removes the highlighting of the nav section you're in, but wow it's fast!

   Jekyll Feed: Generating feed for posts

Filename | Count | Bytes | Time ---------------------------+-------+----------+------ _includes/site-index.html | 1 | 31.18K | 5.962 _includes/navigation.html | 1 | 36.32K | 5.679 _includes/breadcrumb.html | 164 | 1444.81K | 5.475 _layouts/content-page.html | 145 | 2466.76K | 5.066 _layouts/site-map.html | 1 | 10.99K | 1.692 _layouts/default.html | 165 | 6032.92K | 1.631 _layouts/module.html | 15 | 165.85K | 0.432 sitemap.xml | 1 | 19.42K | 0.141 _layouts/page-index.html | 13 | 36.05K | 0.077 _layouts/resource.html | 2 | 18.01K | 0.069 _layouts/news.html | 1 | 10.99K | 0.019 _layouts/page.html | 1 | 3.30K | 0.009 _layouts/curriculum.html | 1 | 5.96K | 0.006 _includes/post.html | 3 | 7.67K | 0.002 _includes/head.html | 1 | 1.55K | 0.001 index.html | 1 | 1.31K | 0.001 _layouts/news-updates.html | 1 | 0.76K | 0.001 robots.txt | 1 | 0.04K | 0.000 _includes/post-index.html | 1 | 0.75K | 0.000 _includes/footer.html | 1 | 0.83K | 0.000 _includes/header.html | 1 | 4.80K | 0.000 _includes/logo.html | 1 | 4.59K | 0.000

joncamfield commented 4 years ago

and here it is not caching nav, but still caching everything else:

Filename | Count | Bytes | Time ---------------------------+-------+----------+-------- _includes/navigation.html | 165 | 5995.59K | 999.162 _layouts/default.html | 165 | 6033.56K | 281.185 _includes/site-index.html | 1 | 31.18K | 6.071 _includes/breadcrumb.html | 164 | 1444.81K | 5.846 _layouts/content-page.html | 145 | 2466.76K | 5.426 _layouts/site-map.html | 1 | 10.99K | 1.725 _layouts/module.html | 15 | 165.85K | 0.436 sitemap.xml | 1 | 19.42K | 0.148 _layouts/page-index.html | 13 | 36.05K | 0.084 _layouts/resource.html | 2 | 18.01K | 0.077 _layouts/news.html | 1 | 10.99K | 0.022 _layouts/page.html | 1 | 3.30K | 0.010 _layouts/curriculum.html | 1 | 5.96K | 0.007 _includes/post.html | 3 | 7.67K | 0.001 _includes/head.html | 1 | 1.55K | 0.001 robots.txt | 1 | 0.04K | 0.001 _layouts/news-updates.html | 1 | 0.76K | 0.001 index.html | 1 | 1.31K | 0.000 _includes/post-index.html | 1 | 0.75K | 0.000 _includes/footer.html | 1 | 0.83K | 0.000 _includes/header.html | 1 | 4.80K | 0.000 _includes/logo.html | 1 | 4.59K | 0.000

(just the nav include is responsible for almost 4:30 of build time on my machine, it's 11 seconds to build the whole site with it cached, 4.85 without.

If anyone wants to try to either:

Anyone who is anxiously waiting for 5 minutes to tic by to see if their change worked would be infinitely grateful.

joncamfield commented 4 years ago

Overall Jekyll perfomance guidance: https://cloudcannon.com/tips/2017/12/08/speed-up-your-jekyll-builds/

joncamfield commented 2 years ago

This commit applies this to the dev branch: https://github.com/levelupcc/level-up/commit/c99299fcf7b18673206e2649feaa5b36546f8da0