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

Remove pycache to save space (20:4 MiB pre:post squashfs-ing) #399

Merged
merged 1 commit into from Jul 29, 2020

Conversation

mvidner
Copy link
Member

@mvidner mvidner commented Jul 27, 2020

Related to:

Files in the __pycache__ directories are compiled versions of the sources, used for faster loading. In the inst-sys, saving space is more important than the small speedup, so we delete them.

Size Before (Tumbleweed of 2020-07-04)

$  wget https://download.opensuse.org/tumbleweed/repo/oss/boot/x86_64/{common,root}
(...)
$ du -hc common root
61M     common
73M     root
133M    total
$ pysize() { unsquashfs -ll $1 | grep __pycache__ | awk '{s += $3} END {print s/1024/1024}'; }
$ pysize common
18.8646
$ pysize root
0.151923

Size After

$ du -hc common root
57M     common
72M     root
129M    total
$ pysize root
0
$ pysize common
0

Copy link
Member

@lslezak lslezak left a comment

Choose a reason for hiding this comment

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

Start dir?

@@ -378,6 +378,7 @@ R s/ Server//g etc/issue
# remove files we don't want to show up at all
r /usr/share/{doc,info,locale,man} /usr/src/packages /usr/share/fillup-templates /var/adm/fillup-templates
r dev/mapper dev/stderr dev/initctl
e find . -name __pycache__ -print0 | xargs -0 rm -rf
Copy link
Member

Choose a reason for hiding this comment

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

I do not know where the cached files can be located, but do we need to scan the whole tree? How long does it take in OBS? I mean scanning e.g. just usr could be a bit faster... But maybe it's irrelevant considering how long the i-i build actually takes....

Copy link
Member

@wfeldt wfeldt Jul 27, 2020

Choose a reason for hiding this comment

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

I don't think it would make much of a difference. /usr is the largest blob anyway and the file tree has just been created and is likely still cached.

Copy link
Member Author

Choose a reason for hiding this comment

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

Luckily the measurement is easily obtained, and the answer is: it takes 1 second or less:

$ grep -A1 pycache /var/tmp/build-root-openSUSE_Factory/.build.log
[  333s] running "find . -name __pycache__ -print0| xargs -0 rm -rf"
[  334s] running "touch etc/sysconfig/kernel"
--
[  475s] running "find . -name __pycache__ -print0| xargs -0 rm -rf"
[  475s] running "find var -type f"
--
[ 1348s] running "find . -name __pycache__ -print0| xargs -0 rm -rf"
[ 1348s] running "touch etc/sysconfig/kernel"

@mvidner mvidner changed the title Remove pycache to save space (20 MB uncompressed) Remove pycache to save space (20:4 MiB pre:post squashfs-ing) Jul 28, 2020
@mvidner
Copy link
Member Author

mvidner commented Jul 29, 2020

@wfeldt Anything else? Can we merge?

Copy link
Member

@wfeldt wfeldt left a comment

Choose a reason for hiding this comment

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

lgtm

@mvidner mvidner merged commit 428ffe4 into master Jul 29, 2020
@mvidner mvidner deleted the reduce-disk-space branch July 29, 2020 09:28
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.

None yet

3 participants