Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Shallow Submodule Init to Reduce Clone Times #1605

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

Conversation

TShapinsky
Copy link

Reopening with new PR due to being unable to reopen #1603 (force push/rebase caused history mismatch).

Added --depth 1 to the git submodule update command in Makefile.in.

To test I setup a docker image which built the repository with ./configure --prefix=/opt/riscv --with-arch=rv32gc --with-abi=ilp32d. The image with this change was 14.77 GB where as the version without this change was 16.93 GB. That is a savings of 2.16 GB. This won't be a big deal for people developing in a stable environment where they only init the submodules once, but for cases where the build is happening in a container this is a big gain.

A different approach would be to populate the shallow property in .gitmodules. However, this approach only saves about 100MB, perhaps because the shallow property is not applied recursively.

@@ -12,6 +12,7 @@ jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Copy link
Author

Choose a reason for hiding this comment

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

This can be removed. But right now it is hard to debug actions as all jobs exit when one fails.

@@ -347,7 +347,7 @@ endif
$(srcdir)/%/.git:
cd $(srcdir) && \
flock `git rev-parse --git-dir`/config git submodule init $(dir $@) && \
flock `git rev-parse --git-dir`/config git submodule update --progress $(dir $@)
flock `git rev-parse --git-dir`/config git -c "http.version=HTTP/1.1" submodule update --progress --depth 1 $(dir $@)
Copy link
Author

Choose a reason for hiding this comment

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

`-c "http.version=HTTP/1.1" forces http 1.1 to avoid error which was seen in previous PR.

@cmuellner
Copy link
Collaborator

Looks like the git server of uclibc-ng does not like shallow clones.

I've seen that shallow clones can be configured in .gitmodules.
Maybe something like this works (untested):

diff --git a/.gitmodules b/.gitmodules
index 68c2932..058d88a 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -2,44 +2,56 @@
        path = binutils
        url = https://sourceware.org/git/binutils-gdb.git
        branch = binutils-2_43-branch
+       shallow = true
 [submodule "gcc"]
        path = gcc
        url = https://gcc.gnu.org/git/gcc.git
        branch = releases/gcc-14
+       shallow = true
 [submodule "glibc"]
        path = glibc
        url = https://sourceware.org/git/glibc.git
+       shallow = true
 [submodule "dejagnu"]
        path = dejagnu
        url = https://git.savannah.gnu.org/git/dejagnu.git
        branch = master
+       shallow = true
 [submodule "newlib"]
        path = newlib
        url = https://sourceware.org/git/newlib-cygwin.git
        branch = master
+       shallow = true
 [submodule "gdb"]
        path = gdb
        url = https://sourceware.org/git/binutils-gdb.git
        branch = gdb-15-branch
+       shallow = true
 [submodule "qemu"]
        path = qemu
        url = https://gitlab.com/qemu-project/qemu.git
+       shallow = true
 [submodule "musl"]
        path = musl
        url = https://git.musl-libc.org/git/musl
        branch = master
+       shallow = true
 [submodule "spike"]
        path = spike
        url = https://github.com/riscv-software-src/riscv-isa-sim.git
        branch = master
+       shallow = true
 [submodule "pk"]
        path = pk
        url = https://github.com/riscv-software-src/riscv-pk.git
        branch = master
+       shallow = true
 [submodule "llvm"]
        path = llvm
        url = https://github.com/llvm/llvm-project.git
        branch = release/17.x
+       shallow = true
 [submodule "uclibc-ng"]
        path = uclibc-ng
        url = https://git.uclibc-ng.org/git/uclibc-ng.git
+       shallow = false

@TShapinsky
Copy link
Author

TShapinsky commented Nov 2, 2024

Looks like the git server of uclibc-ng does not like shallow clones.

I've seen that shallow clones can be configured in .gitmodules. Maybe something like this works (untested):

diff --git a/.gitmodules b/.gitmodules
index 68c2932..058d88a 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -2,44 +2,56 @@
        path = binutils
        url = https://sourceware.org/git/binutils-gdb.git
        branch = binutils-2_43-branch
+       shallow = true
 [submodule "gcc"]
        path = gcc
        url = https://gcc.gnu.org/git/gcc.git
        branch = releases/gcc-14
+       shallow = true
 [submodule "glibc"]
        path = glibc
        url = https://sourceware.org/git/glibc.git
+       shallow = true
 [submodule "dejagnu"]
        path = dejagnu
        url = https://git.savannah.gnu.org/git/dejagnu.git
        branch = master
+       shallow = true
 [submodule "newlib"]
        path = newlib
        url = https://sourceware.org/git/newlib-cygwin.git
        branch = master
+       shallow = true
 [submodule "gdb"]
        path = gdb
        url = https://sourceware.org/git/binutils-gdb.git
        branch = gdb-15-branch
+       shallow = true
 [submodule "qemu"]
        path = qemu
        url = https://gitlab.com/qemu-project/qemu.git
+       shallow = true
 [submodule "musl"]
        path = musl
        url = https://git.musl-libc.org/git/musl
        branch = master
+       shallow = true
 [submodule "spike"]
        path = spike
        url = https://github.com/riscv-software-src/riscv-isa-sim.git
        branch = master
+       shallow = true
 [submodule "pk"]
        path = pk
        url = https://github.com/riscv-software-src/riscv-pk.git
        branch = master
+       shallow = true
 [submodule "llvm"]
        path = llvm
        url = https://github.com/llvm/llvm-project.git
        branch = release/17.x
+       shallow = true
 [submodule "uclibc-ng"]
        path = uclibc-ng
        url = https://git.uclibc-ng.org/git/uclibc-ng.git
+       shallow = false

Yeah, I'm testing this out locally. I can't get it to take... but hopefully I'll figure it out soon.

It would definitely be preferable to do it this way instead of forcing it.

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.

2 participants