-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Reimplement 'pause' in C - smaller footprint all around #23009
Conversation
set -e | ||
set -x | ||
REPO = docker.io/uluyol/cross | ||
TAG = musl-1.1.14 |
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.
REPO needs to be changed before submission along with docker push command.
I wasn't sure how (if at all) to integrate building these with any other part of the build system. |
Reassigning to @thockin for triage. I'll ask, though: why? |
Should have linked this earlier: #15140 |
@k8s-merge-robot you're a little too eager |
@uluyol Thanks, I'll check this out. |
First off, why do this in musl? It should be statically linked anyway. How much cpu/ram does this consume? 1 RSS? The thing with C should be to reduce the usage to a minimum.
Maybe dietlibc would be something to look into? |
glibc doesn't support static linking and isn't exactly lightweight. Does kube-cross have a C cross-compiler? I was under the impression that it's just for Go.
The binary is already smaller than 4KB, I haven't measured the memory usage but the entire binary could fit in a single page.
I don't see any advantage to using dietlibc over musl. musl works with kubernetes dns for things that care now and is MIT licensed (dietlibc is GPL). Even if we use dietlibc, we still need a dedicated cross-compiler setup for it so it wouldn't simplify the build process at all. |
Thanks. |
GCC_CONFFLAGS="--with-arch=armv5 --with-float=softfp" | ||
|
||
# Enable this to build the bootstrap gcc (thrown away) without optimization, to reduce build time | ||
GCC_STAGE1_NOOPT=1 |
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 think we always want to optimize the binary, although it takes a little more time.
The compilation will only be done one or twice, but the image will be used many thousands of times
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.
Building gcc requires building it twice (first build the compiler, then use it to build itself). This disables optimizations when building the throwaway compiler.
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.
Thanks. Noticed that when I tried out the code later on.
@uluyol FYI, there should be an image for |
|
||
TAG = 2.0 | ||
#TRIPLE = arm-linux-musleabi |
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.
Please do:
ARCH?=amd64
ifeq($(ARCH),amd64)
TRIPLE?=x86_64-linux-musl
endif
ifeq($(ARCH),arm)
TRIPLE?=arm-linux-musleabi
endif
ifeq($(ARCH),arm64)
TRIPLE?=aarch64-linux-musl
endif
ifeq($(ARCH),ppc64le)
TRIPLE?=powerpc-linux-musl # Not sure about the naming here
endif
One shouldn't have to edit the file to cross-build, just specify args
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.
Done.
musl (and dietlibc) don't have support for ppc64 or arm64 so those continue to use Go. |
Container sizes:
|
#include <unistd.h> | ||
|
||
static void sigdown(int signo) { | ||
exit(0); |
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.
log the signal received
I don't understand the comment about glibc not supporting static compilation, which leads to a right MESS of things. On what planet does compiling a trivial C program with
The binary is larger than I am happy about but it's pretty inconsequential, and still smaller than the Go binary. |
if (signal(SIGINT, sigdown) == SIG_ERR) | ||
return 1; | ||
if (signal(SIGTERM, sigdown) == SIG_ERR) | ||
return 1; |
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.
return 2 here
Looks great! Just a nit and I think you don't mean to edit CHANGELOG |
@@ -0,0 +1 @@ | |||
.build-* |
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.
This should be /.build-* - the leading slash means "only in this dir"
Actually, I have a Makefile patch for you - something smelled wrong. soon |
It got sort of big, sorry. Pasting it here. It should apply cleanly to this tree as of right now. Once it's merged into your PR, I can actually build and push the images and we can get this PR in. |
Applied the changes, this is definitely cleaner. PTAL |
@@ -0,0 +1,3 @@ | |||
/.container-* | |||
/.push.* |
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.
should be push-* ?
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.
Done.
nit on gitignore. please squash |
I'm going to build and push these to see if e2e needs that to run properly |
One more bugfix:
This stops 'push' from doing extra work |
I have built and pushed these. When you repush with last fixes, we'll see about e2e |
6d67d46
to
e186ab1
Compare
Builds statically against glibc. References to the old pause image have been updated.
|
||
push-legacy-too: push | ||
push-legacy: .push-legacy-$(ARCH) |
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.
@thockin I'm not sure if we should push legacy of this image anymore, as we've updated all refs to -amd64:3.0
and the 2:0
still exists.
My point is, since the "old" naming is deprecated, it might be best to not push/refer to the old naming at all, to reduce confusion. However, if you've already pushed it, it's okay
WDYT?
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'd prefer to just leave it for a while.
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.
okay, fine
@thockin e2e has passed. PTAL |
LGTM thanks! |
GCE e2e build/test passed for commit f3690e2. |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
k8s-merge-robot has asked k8s-bot to test this three times now. Something wrong with the merge process? |
GCE e2e build/test passed for commit f3690e2. |
Automatic merge from submit-queue |
Statically links against musl. Size of amd64 binary is 3560 bytes.
I couldn't test the arm binary since I have no hardware to test it on, though I assume we want it to work on a raspberry pi.
This PR also adds the gcc5/musl cross compiling image used to build the binaries.
@thockin