-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
feat/lower squashfs size #211
base: main
Are you sure you want to change the base?
Conversation
e7b659f
to
9bd468e
Compare
Green depends on: NixOS/nixpkgs#311675 |
cb56c9d
to
ef9a889
Compare
@@ -74,6 +74,9 @@ if ! "$SCRIPT_DIR/kexec" --load "$SCRIPT_DIR/bzImage" \ | |||
exit 1 | |||
fi | |||
|
|||
sync; echo 3 > /proc/sys/vm/drop_caches | |||
echo "current available memory: $(free -h | awk '/^Mem/ {print $7}')" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't the linux kernel do this automatically anyway if it needs memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could very well imagine that yes, although I didn't verify and don't intent to stake that claim either.
The main reason I put this here is for reporting so that (especially during tests) we can see how much effective free memory was available prior to switching the kernel.
Not sure if it is utterly useful otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. But you are already printing the available memory, which will automatically substract any memory claimed by page cache or dirty pages.
So no need to flush the caches, which might even contain the initrd that we are about to kexec into.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we could even print a warning if we are below X MB available memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we could even print a warning if we are below X MB available memory.
Yeah, I had that idea, too, today: outright refuse to proceed because it's potentially not recoverable, if you have no IPMI access.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. But you are already printing the available memory, which will automatically substract any memory claimed by page cache or dirty pages.
So no need to flush the caches, which might even contain the initrd that we are about to kexec into.
Iirc, I did some A/B testing and saw a small ~30MB difference, but yeah, I agree that it shouldn't be necessary.
I did notice, however, on a slightly tangential note, that at the RAM-limit, kexec --load
kept working while then kexec -e
failed. But I guess that's just due to what the stage 1 or squashfs ultimately command into RAM.
restore-network = pkgs.writers.writePython3 "restore-network" { flakeIgnore = [ "E501" ]; } | ||
./restore_routes.py; | ||
|
||
restore-network = pkgs.writers.writeBash "restore-network" ./restore_routes.sh; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the saving removing python out of interest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember exactly. It was relatively significant though. I may even think in the ballpark of 150MB or so. It was, indeed, the lowest hanging fruit. I could have gone with python minimal, but since I was trying to really size this down as much as possible, I thought I'd save those additional dozens of MB that python minimal would have left us with, as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, the effect on the RAM was rather small (maybe 30-60MB or so?), ostensible due to a somewhat efficient caching and on-demand decompression of the squashfs, while having a (much!) smaller impact while compressed.
ClosuresBaseline: util-linux = prev.util-linux.override {
nlsSupport = false;
ncursesSupport = false;
systemdSupport = false;
translateManpages = false;
};
w translateManpages util-linux = prev.util-linux.override {
nlsSupport = false;
ncursesSupport = false;
systemdSupport = false;
# translateManpages = false;
};
w systemdSupport util-linux = prev.util-linux.override {
nlsSupport = false;
ncursesSupport = false;
# systemdSupport = false;
# translateManpages = false;
};
Interestingly, bringing back systemd support, despite using systemd seems to have negative effect for other reasons than the pure dependency. w ncursesSupport util-linux = prev.util-linux.override {
nlsSupport = false;
# ncursesSupport = false;
# systemdSupport = false;
# translateManpages = false;
};
original # util-linux = prev.util-linux.override {
# nlsSupport = false;
# ncursesSupport = false;
# systemdSupport = false;
# translateManpages = false;
# };
|
NixOS/nixpkgs@e5b250b is still on |
0541cd6
to
df11b55
Compare
We are now down to 1GB: https://github.com/nix-community/nixos-images/pull/218/files |
c54ae6f
to
eeb2377
Compare
# save ~12MB by not bundling manpages | ||
coreutils-full = prev.coreutils; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also question here: Do we actually care about this? We are not shipping manpages afaik and they are hopefully in a separate output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they are hopefully in a separate output?
Unfortunately not, at least in nixos-23.11:
postInstall = optionalString (isCross && !minimal) ''
rm $out/share/man/man1/*
cp ${buildPackages.coreutils-full}/share/man/man1/* $out/share/man/man1
''
# du: 8.7 M locale + 0.4 M man pages
+ optionalString minimal ''
rm -r "$out/share"
'';
minimal
is false
on -full
@@ -0,0 +1,121 @@ | |||
#!/usr/bin/env bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @Lassulus for review of this.
Context
Results
Unstable Patch Required