This repository has been archived by the owner on Oct 30, 2018. It is now read-only.
Reduce maximum memory usage via tempfiles #191
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Replacing a few uses of
bytes.Buffer
with temporary files or passing aroundio.Reader
instead of a full buffer reduces the Maximum RSS (measured bytime(1)
) from 6.7G to 110M when building thekube-master.iso
from https://github.com/linuxkit/kubernetes.Motivation for looking into this was that in the https://github.com/linuxkit/kubernetes CI the image build process is occasionally being SIGKILL'd, since the CI containers are limited to 4G I hypothesised that the process was being OOM killed (I have not yet tested with these changes in place).
Since i have plenty of RAM no my test system the data, presumably, remains hot in the page cache so elapsed wallclock time is unaffected (it's a few seconds faster on a minute long build, so in the noise). On a memory (but not disk) constrained system it ought to complete slowly instead of getting killed.
Also adds
-memprofile
and-cpuprofile
options to enable measurement, although I mostly ended up using `time(1) since the profiles show cumulative or overall allocations rather than max rss.I'm not sure but with these changes it might be possible to mark some additional image formats as streaming.