Speed up build in large project with right work flow

If many people develop a large project (e.g. Chromium), many changes can be created all the time. If we update the code, we need to rebuild all the changed files which may take a lot of time.

Let us assume the name of the major develop branch is master. To speed up our build, we can checkout and update master branch everyday and then start a build before we get off work (or before the meal time). The build will be finished when we get back to work next morning. We can call it daily build.

Our goal is to avoid too many file changes in our local workspace between two daily build. So rebuild our local changes will be fast because it is incremental build.

If we need to checkout among different feature branches, and some of the branch may be created several days ago, and it has many diff from the current master branch, what should we do? The answer is to use git rebase in the right way.

For example, we are currently on latest master branch, and we have a feature branch named my-feature which is checked out from earlier version of master branch.

1
2
3
A---B---C---F---...---G (HEAD master)
\
D---E (my-feature)

If we need to rebase my-feature on to latest master branch, we have different ways:

  • One way is: 1) git checkout my-feature, 2) git rebase master. But when we checkout to my-feature branch in step 1, many files in our workspace will be modified, so the build may becomes very slow.
  • Another way is to run git rebase master my-feature. When running this command, git will apply each commit from my-feature on to the current master branch. Finally we will rebase and check out to the my-feature branch. Changes in the workspace only contains the commits from my-feature branch, so the incremental build will be fast.
1
2
3
4
Before
A---B---C---F---...---G (HEAD master)
\
D---E (my-feature)
1
2
3
4
After
A---B---C---F---...---G (master)
\
D'---E' (HEAD my-feature)

Reference:

https://git-scm.com/docs/git-rebase

https://womanonrails.com/git-rebase-onto