mbedtls icon indicating copy to clipboard operation
mbedtls copied to clipboard

Improve checkout speed with submodules

Open awesomekosm opened this issue 7 months ago • 2 comments

Git Checkout with submodules

Add, this is --depth 1 for submodules

git config -f .gitmodules submodule.framework.shallow true
git config -f .gitmodules submodule.tf-psa-crypto.shallow true

Justification

Mbed TLS needs this because it's slow to checkout, it's over 90mbs per submodule, and psa-crypto seems to have it's own dependency on framework, which will need to be also downloaded again.

$ git clone --recurse-submodules https://github.com/awesomekosm/mbedtls.git
Cloning into 'mbedtls'...
remote: Enumerating objects: 271486, done.
remote: Counting objects: 100% (1639/1639), done.
remote: Compressing objects: 100% (465/465), done.
remote: Total 271486 (delta 1394), reused 1174 (delta 1174), pack-reused 269847 (from 3)
Receiving objects: 100% (271486/271486), 131.63 MiB | 15.17 MiB/s, done.
Resolving deltas: 100% (211583/211583), done.
Submodule 'framework' (https://github.com/Mbed-TLS/mbedtls-framework) registered for path 'framework'
Submodule 'tf-psa-crypto' (https://github.com/Mbed-TLS/TF-PSA-Crypto.git) registered for path 'tf-psa-crypto'
Cloning into 'D:/projects/c/projects/mbedtls/framework'...
remote: Enumerating objects: 206976, done.
remote: Counting objects: 100% (1671/1671), done.
remote: Compressing objects: 100% (728/728), done.
remote: Total 206976 (delta 1107), reused 966 (delta 943), pack-reused 205305 (from 4)
Receiving objects: 100% (206976/206976), 97.08 MiB | 14.22 MiB/s, done.
Resolving deltas: 100% (159656/159656), done.
Cloning into 'D:/projects/c/projects/mbedtls/tf-psa-crypto'...
remote: Enumerating objects: 205700, done.
remote: Counting objects: 100% (108/108), done.
remote: Compressing objects: 100% (66/66), done.
remote: Total 205700 (delta 72), reused 46 (delta 42), pack-reused 205592 (from 3)
Receiving objects: 100% (205700/205700), 98.26 MiB | 14.79 MiB/s, done.
Resolving deltas: 100% (159932/159932), done.
Submodule path 'framework': checked out '1a83e0c84d4b7aa11c7cfd3771322486fc87d281'
Submodule path 'tf-psa-crypto': checked out '35ae18cf891d3675584da41f7e830f1de5f87f07'
Submodule 'framework' (https://github.com/Mbed-TLS/mbedtls-framework) registered for path 'tf-psa-crypto/framework'
Cloning into 'D:/projects/c/projects/mbedtls/tf-psa-crypto/framework'...
remote: Enumerating objects: 206976, done.
remote: Counting objects: 100% (1671/1671), done.
remote: Compressing objects: 100% (728/728), done.
remote: Total 206976 (delta 1107), reused 966 (delta 943), pack-reused 205305 (from 4)
Receiving objects: 100% (206976/206976), 97.08 MiB | 13.96 MiB/s, done.
Resolving deltas: 100% (159656/159656), done.
Submodule path 'tf-psa-crypto/framework': checked out '1a83e0c84d4b7aa11c7cfd3771322486fc87d281'

awesomekosm avatar Jun 12 '25 22:06 awesomekosm

Thanks for your interest in Mbed-TLS. Without any change in the library:

git clone --recurse-submodules --shallow-submodules https://github.com/awesomekosm/mbedtls.git

achieve the same I think. Would it be a possible solution for you? Otherwise, the question is, what is the best default behavior?

ronald-cron-arm avatar Jun 13 '25 07:06 ronald-cron-arm

That works as well.

I can update my CI to git clone --depth 1 --branch $_MBEDTLS_VERSION --recurse-submodules --shallow-submodules ... By default I doubt CI/devs need submodules entire history tree, especially since the same submodule is cloned multiple times. Maybe it's okay to make it 'shallow' .gitmodules.

Thank you, close this if you think it's unnecessary as a default.

awesomekosm avatar Jun 13 '25 15:06 awesomekosm

I am closing it for now. We may consider this later.

ronald-cron-arm avatar Jun 19 '25 06:06 ronald-cron-arm