Skip to content

Speeding up build process#385

Merged
shiffman merged 5 commits into
mainfrom
faster-builds
Jul 18, 2022
Merged

Speeding up build process#385
shiffman merged 5 commits into
mainfrom
faster-builds

Conversation

@runemadsen
Copy link
Copy Markdown
Contributor

@runemadsen runemadsen commented Jul 18, 2022

I took a good look at the build process and managed to get the build time to be significantly less. On my local machine, it went from 13 minutes to 3.5 minutes, and Netlify builds are now 10-20 minutes depending on the cache. There are some significant changes that I'll list below:

  • New URL structure. The most apparent change is that I had to change the URL structure for filtering topics and languages. The URL's went from .../topic:bla+lang:bla to .../topic/bla/lang/bla. The reason for this is that Gatsby will created static JSON files based on the path on the computer, and win/mac computers would have problems with the +, : and lower-upper caps in the filenames. Therefore I changed the way page generation works so I could slugify the paths, which means that .../topic:JavaScript is now .../.topic/javascript. All in all, it shouldn't be a major change except for the fact that it is not allowed to have two separate tags with the same characters in diffferent upper and lower case combinations. I went through the code and changed all the apparent examples of this (processing vs. Processing and javascript vs. Javascript vs. JavaScript).
  • Optimize GraphQL queries. I changed some GraphQL queries and removed some unused GraphQL queries to significantly cut down the build time.
  • Remove duplicated pages. The path naming problems also resulted in duplicated pages, which means that the build process will now produce 1500 pages less.

There's a few more things that I'll tackle in upcoming PR's:

  • Turn homepage.svg file into a PNG since it's 1.6MB raw SVG with base64 in it
  • Check resizing of images to make sure everything happens correctly
  • Redesign the topic and language selector

Also @shiffman: Can you check whether this PR solves #367? I have the feeling that some of the page duplication logic could have resulted in this problem, so let me know if it looks better with this PR.

This fixes #264

@netlify
Copy link
Copy Markdown

netlify Bot commented Jul 18, 2022

Deploy Preview for codingtrain ready!

Name Link
🔨 Latest commit 831bbd5
🔍 Latest deploy log https://app.netlify.com/sites/codingtrain/deploys/62d54d37d66d5d0008d27ebd
😎 Deploy Preview https://deploy-preview-385--codingtrain.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@runemadsen
Copy link
Copy Markdown
Contributor Author

@shiffman After a few hours debugging the GraphQL queries, I've managed to bring the Netlify build time down to 20 minutes without cache and 12 minutes with cache! I'm still working through a few other things that might bring this down even more, so I'll report here when I have an update.

@runemadsen
Copy link
Copy Markdown
Contributor Author

Also, the build time without cache on my local machine went from 766 seconds to 200 seconds

@runemadsen runemadsen changed the title [WIP] Speeding up build Speeding up build Jul 18, 2022
@runemadsen
Copy link
Copy Markdown
Contributor Author

@shiffman Updated the PR message above and removed the WIP tag. Please give it a good test to make sure everything works and merge if it looks alright. The build on Netlify is now 13 minutes without cache 🥳

@runemadsen runemadsen changed the title Speeding up build Speeding up build process Jul 18, 2022
@shiffman
Copy link
Copy Markdown
Member

Wow! This is amazing @runemadsen! I've tested the build locally and checked the preview and all looks good. I'm seeing all the passenger showcase projects but I don't think we'll know if #367 is fully resolved until we have some activity over the course of the week of new submissions and multiple builds. @klinegareth let's keep a close eye and see! I'm going to go ahead and merge this so we can see how it performs. Thank you @runemadsen!!!!

@shiffman shiffman merged commit 5ee6b08 into main Jul 18, 2022
@runemadsen
Copy link
Copy Markdown
Contributor Author

Excellent!

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.

Netlify Build issue?

2 participants