Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Tweak squashfs for low-memory systems #2383
Conversation
tych0
merged commit bf69978
into
lxc:master
Sep 15, 2016
| @@ -99,6 +99,13 @@ func unpack(file string, path string) error { | ||
| } else if strings.HasPrefix(extension, ".squashfs") { | ||
| command = "unsquashfs" | ||
| args = append(args, "-f", "-d", path, "-n") | ||
| + | ||
| + mem, err := deviceTotalMemory() | ||
| + mem = mem / 1024 / 1024 / 10 |
sean-jc
Sep 15, 2016
Contributor
This is non-intuitive for me; even with the commit message it took me a bit to work through the logic. I think it's especially confusing for people used to power-of-two math, the 10 seems so out of place. Any objection to changing the code to something like this? This assumes the comparison against 2.5gb instead of 2gb was unintentional.
if err == nil && mem <= (1<<31) {
mem = mem / 1024 / 1024 / 10
...
}
stgraber
Sep 15, 2016
Owner
The reason is simply that unsquashfs defaults to 256MB chunks, so we only want to set the argument if the resulting computed chunk size is smaller than that and we don't want that chunk to be bigger than 10% of the system's memory.
stgraber
Sep 15, 2016
Owner
The "mem" variable is intended as the chunk of memory in MB that we're willing to let unsquashfs use.
sean-jc
Sep 15, 2016
Contributor
I understand the intent and logic, but for someone coming along later I think the code will be quite confusing, especially since the commit message doesn't match the code. 2gb vs 2.5gb is nitpicking, but my initial reaction when looking at the code was "that's not 2gb". I can see someone (like me) changing the code to actually compare against 2gb, thinking they're doing the right thing.
sergiusens
commented
Sep 15, 2016
|
Just want to confirm this works on my low mem env:
|
stgraber commentedSep 15, 2016
On low-memory systems (below 2GB of RAM), limit unsquashfs to a single
CPU and to 10% of the RAM for its fragment size.
Closes #2382
Signed-off-by: Stéphane Graber stgraber@ubuntu.com