element-x-android icon indicating copy to clipboard operation
element-x-android copied to clipboard

Why is this repository over 10gb

Open catfromplan9 opened this issue 6 months ago • 20 comments

I'm trying to git clone, what could you all have possibly done to make this repository over 10gb? Please purge whatever caused this from the git history, thanks.

catfromplan9 avatar May 29 '26 20:05 catfromplan9

what could you all have possibly done to make this repository over 10gb

You could try searching existing issues? https://github.com/element-hq/element-x-android/issues/184 There's also a project in that issue that you might try to reduce the size.

bxdxnn avatar May 30 '26 08:05 bxdxnn

Why has the git history not been rewritten yet? This is unacceptable, just cut the losses to anyone's current clones and rewrite commit history to drop the several gb of files, this needs to be fixed.

catfromplan9 avatar May 30 '26 09:05 catfromplan9

Okay great so they said they're gonna fix it if thats okay, called it a day when they removed the file in a git commit, and 3 years later have not fixed the underlying issue of the full repostory including the history being 10gb. This is critical. I cannot, in any way, work on this codebase when I have to do a 10gb clone that took around an hour.

catfromplan9 avatar May 30 '26 09:05 catfromplan9

This kind of aggressive behavior isn't acceptable either, have you actually read the issue I've linked? That was already done, and there've been plenty of other work done to reduce it even more, but naturally the project has grown over 3 years. Contributions are welcome to reduce it even more. If you're suggesting to actually reset the entire history, that won't happen. If you don't need the entire history, use shallow clone. You can still create PRs with shallow clones e.g. if you commit in a new branch or upload the commit patch to GitHub.

bxdxnn avatar May 30 '26 09:05 bxdxnn

It clearly is not already done if the repository is cloned to 10gb. So, if that issue is not related, then whatever else in the history is making it 10gb should be purged. No amount of natural growth is gonna make an android app repository become 10gb

catfromplan9 avatar May 30 '26 16:05 catfromplan9

I am aware my tone is harsh, but you need a reality check, this is not acceptable quality standards for anything published onto the internet publicly without a large disclaimer in the readme that nobody should use it.

To add more context, I have spent many many hours of my time working on a fork of Element Classic, fixing all the problems which you all refused to fix, there are dozens and dozens of them. The client was left in atrocious state. Then I try to git clone this repository to reference for my blurhash implementation, and I see it pulling in 10gb, it pissed me off, like after all the awful code I've had to clean up, all the bugs present for years and years never fixed even when element classic was maintained and before Element X's inception, we had these bugs that element HQ team refused to fix. Now I see 10gb big chungus repository being pulled in, for matrix client app, not triple A video game but matrix client has 20gb git repo.

According to some reddit posts, linux kernel git repo is 6gb, I have no desire to clone myself to verify rn. So there is no reason your project git size should be so big, when the scope is infinitely smaller than the largest kernel project in existence. When there is problem, you fix it. That's how things are supposed to work. Unacceptably large git size? Purge large stuff from history, people can reclone, because this makes project unusable (and no i dont want to set a low depth, i wanted full history to track changes)

catfromplan9 avatar May 30 '26 16:05 catfromplan9

Anyway, sorry for harsh tone, I am very pissed off after having to deal with lots of bug fixing from new vector spaghetti code in element classic

catfromplan9 avatar May 30 '26 16:05 catfromplan9

A quick look:

The repo itself (+ LFS assets I assume) is actually ~2 GB, the source code itself is ~1.5 GB and the .git dir is ~500 MB though I have a lot of origins/stashes/branches. The 10 GB you're talking about is actually taken by build artifacts (on my machine, all build dirs take 7.6 GB) and other untracked things.

I'm not sure that we can easily get rid of the large build artifacts (a bit related #848), mobile development is infamously very heavy on disk/RAM space.

A quick way to get rid of it is running ./gradlew clean, then always building only the arch/flavor that you actually need everytime, e.g. ./gradlew -Parm64 assembleGplayNightly. This way, you can save build time and space everytime you build the app.

bxdxnn avatar May 30 '26 18:05 bxdxnn

@bxdxnn I did a fresh clone of EXA with gh repo clone element-hq/element-x-android so it's mostly same as using git directly to clone. Logs:

@ gh repo clone element-hq/element-x-android
Cloning into 'element-x-android'...
remote: Enumerating objects: 745792, done.
remote: Counting objects: 100% (450/450), done.
remote: Compressing objects: 100% (207/207), done.
remote: Total 745792 (delta 282), reused 259 (delta 231), pack-reused 745342 (from 3)
Receiving objects: 100% (745792/745792), 11.68 GiB | 5.18 MiB/s, done.
Resolving deltas: 100% (164136/164136), done.

So with full history it downloaded 11.68 GiB of repository datas.

I'm currently running git filter-repo --analyze for further invesgation.

ShadowRZ avatar Jun 03 '26 05:06 ShadowRZ

We are suspecting the branch gh-pages to consume lots of space. They host all the images for the gallery (https://element-hq.github.io/element-x-android/) and we cannot use git LFS for this. If this is confirmed, we should probably host this project outside of the repo, because I agree that cloning EXA is not as fast as it could be.

bmarty avatar Jun 03 '26 08:06 bmarty

I'm currently running git filter-repo --analyze for further invesgation.

git filter-repo --analyze output packaged: filter-repo.tar.gz

@bmarty was right that gh-pages consumed lots of space. Deleting the gh-pages branch alone (I did git branch --remote --delete origin/gh-pages, possibily git branch -D gh-pages, along with git reflog expire --expire=all --all in case it was referenced in reflog), and running git gc --prune=now shrinked this repo's size (without LFS checkouts) to ~195.1MB 🤯

ShadowRZ avatar Jun 03 '26 10:06 ShadowRZ

If this is confirmed, we should probably host this project outside of the repo, because I agree that cloning EXA is not as fast as it could be.

You might want to also consider using GitHub Actions to publish GitHub Pages as an option so you don't need to maintain the gh-pages branch while preserving the EXA Gallery's links, see GitHub Docs

ShadowRZ avatar Jun 03 '26 10:06 ShadowRZ

@ gh repo clone element-hq/element-x-android

FYI I have only the develop branch downloaded using git clone, not gh repo clone, alongside my (mostly 1 commit diverge) branches.

bxdxnn avatar Jun 03 '26 11:06 bxdxnn

I'm currently running git filter-repo --analyze for further invesgation.

git filter-repo --analyze output packaged: filter-repo.tar.gz

@bmarty was right that gh-pages consumed lots of space. Deleting the gh-pages branch alone (I did git branch --remote --delete origin/gh-pages, possibily git branch -D gh-pages, along with git reflog expire --expire=all --all in case it was referenced in reflog), and running git gc --prune=now shrinked this repo's size (without LFS checkouts) to ~195.1MB 🤯

~200mb is what I was expecting as well. Thats pretty much identical to element classic's size. Well then, please do trash the pages branch and handle that another way, thanks

catfromplan9 avatar Jun 03 '26 12:06 catfromplan9

One recipe to clone the project by excluding the branch gh-pages

git init element-x-android
cd element-x-android
git remote add origin https://github.com/element-hq/element-x-android
git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'
git config --add remote.origin.fetch '^refs/heads/gh-pages'           
git fetch origin
git checkout develop

We doing this, I have a folder of 196M as well.

bmarty avatar Jun 03 '26 12:06 bmarty

git clone --single-branch should helps here too.

ShadowRZ avatar Jun 03 '26 12:06 ShadowRZ

Deleting the gh-pages branch alone (I did git branch --remote --delete origin/gh-pages, possibily git branch -D gh-pages, along with git reflog expire --expire=all --all in case it was referenced in reflog), and running git gc --prune=now shrinked this repo's size (without LFS checkouts) to ~195.1MB 🤯

This recipe does not work for me, the .git folder still contains 15GB of data :/

bmarty avatar Jun 10 '26 14:06 bmarty

I just removed the gh-pages branch, it seems like the repo is back to something manageable:

Cloning into 'element-x-android'...
remote: Enumerating objects: 487351, done.
remote: Counting objects: 100% (329/329), done.
remote: Compressing objects: 100% (179/179), done.
remote: Total 487351 (delta 221), reused 164 (delta 136), pack-reused 487022 (from 3)
Receiving objects: 100% (487351/487351), 108.85 MiB | 12.61 MiB/s, done.
Resolving deltas: 100% (154250/154250), done.
Updating files: 100% (11208/11208), done.
Filtering content: 100% (4177/4177), 206.79 MiB | 1.72 MiB/s, done.

jmartinesp avatar Jun 26 '26 10:06 jmartinesp

I did tried to experiment with GHA based deployment of EXA gallery: https://github.com/ShadowRZ/element-x-android/commit/bc230c516fdfb0e31e8ecefa021574ccb95a4119 , But failed to test since the screenshot generation task also failed in upstream repo.

ShadowRZ avatar Jun 26 '26 11:06 ShadowRZ

I just removed the gh-pages branch, it seems like the repo is back to something manageable:

Cloning into 'element-x-android'...
remote: Enumerating objects: 487351, done.
remote: Counting objects: 100% (329/329), done.
remote: Compressing objects: 100% (179/179), done.
remote: Total 487351 (delta 221), reused 164 (delta 136), pack-reused 487022 (from 3)
Receiving objects: 100% (487351/487351), 108.85 MiB | 12.61 MiB/s, done.
Resolving deltas: 100% (154250/154250), done.
Updating files: 100% (11208/11208), done.
Filtering content: 100% (4177/4177), 206.79 MiB | 1.72 MiB/s, done.

Thanks!

catfromplan9 avatar Jun 26 '26 13:06 catfromplan9