Skip to content
This repository has been archived by the owner on Mar 6, 2019. It is now read-only.

Reduce development build time to < 2 seconds. #484

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

qvm1Wak
Copy link

@qvm1Wak qvm1Wak commented Feb 2, 2018

I noticed the compile time for the website was pretty slow, so I spent some time making it faster! Developers need to see changes as soon as possible between edits, and on my machine the build time was around two minutes, and sometimes over five minutes.

To get the build time down, I made the build do less. Specifically, disabling responsive image generation, building only one i18n locale (en), and excluding large irrelevant folders that weren't already excluded.
In bullets:

  • disables images by overriding the ruby image.rb plugin
  • disables i18n with Jekyll config override
  • excludes more directories with Jekyll config override
  • new npm run targets (build:dev, build:jekyll:dev, build:novalidate)
  • commit hook to prevent committing overrides
  • a full build is still required for pre-commit
  • removed duplicate run target for "validate"
  • none of this uses Jekyll's incremental builds, but it probably should.
  • since image assets are no longer being copied as part of the image gen process, a new copy step just moves those assets directly.

The only way I could figure out how to disable images was by making a stub Liquid interface in Ruby (in the _plugins folder). Overriding the existing plugin with the stub one saves 30-60 seconds of build time, but at the cost that you might accidentally check that override in. So there's another pre-commit check to verify you didn't do that. In the long run we might try to extract the responsive image logic so it's not so tied to Jekyll.

Jekyll is also working on logic such that includes override excludes so you can work on just a page or two at a time, but that's not ready yet. This PR continues to build all pages, but you're free to change that as you work.

Pre-commit still requires a full build of everything, just to be safe. I'm not sure if this is necessary as CI could catch those issues without slowing devs too much.

Steven

Edits: Grammar, image asset copy note

…ly several minutes)

- disables images by overriding the ruby plugin
- disables i18n with jekyll config override
- excludes more directories with jekyll config override
- new npm run targets
- commit hook to prevent committing overrides
- a full build is still required for pre-commit
- removed duplicate run target for "validate"
@chuckwilliams37
Copy link
Contributor

Thanks for your contribution, @qvm1Wak ! This has been a thorn in our side for a while, and while I personally modified my own workspace last year to do what you're describing, I did not implement it in such a way that was reusable for others.

If you're interested - it might be nice to put a switch in that additionally disables the multi-language outputs - that speeds it up (if I recall correctly) as well.

Also - did you try using the incremental build at all? Is that working for you while developing? It seemed to be very quick for me in that it executes an initial build (takes a while) then detects changes and builds only what is affected by your changes (my understanding). I used it with much success.

@tungfa can we get a web-team member to review this PR?

@qvm1Wak
Copy link
Author

qvm1Wak commented Feb 2, 2018

Thanks for the tips @chuckwilliams37 ! I'll see what I can do with incremental, I've never really used it. I had some luck with disabling languages.. was able to exclude the language folder and set yml overrides to just compile English pages. There's now a separate _config-dev.yml where you can select subsets of things to build.

@mrleewong mrleewong requested review from 0xfffxfff and removed request for 0xfffxfff February 4, 2018 06:08
@@ -65,6 +69,7 @@
},
"jshintConfig": {},
"pre-commit": [
"check:dev-override",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please delete this line from pre commit? And the rest is fine.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants