cherrypick: Reduce memory when calculating commit graph
Created by: efritz
This tracks a cherry-pick of e88ead6c5eb63446762baabe67a6fe7171199f93 into the 3.22 branch.
Created by: efritz
This tracks a cherry-pick of e88ead6c5eb63446762baabe67a6fe7171199f93 into the 3.22 branch.