-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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
pecl install is slow and produces massive (55Mb) binary #23626
Comments
@acoulton Thanks for the report. Just to clarify - this is not a recent regression right? As in, the PECL extension has always been shipped this way. There's no one particular release where the binary size or build time significantly increased right? |
@stanley-cheung thanks - I can't say for sure as we've only started using it quite recently (and only really now are we starting to use it properly). But certainly it's been very consistent across all the (infrequent) builds in that time, both into Docker containers on GCB and now natively onto VMs. Just looked and the first experimental build we did was on 19th May, we got 1.28.0 and it compiled to about 62M (so I guess it's improved 😮 😀 ):
And that build (on a GCB standard builder) took about 9 minutes to run the following initial section of the Dockerfile on php:7.2-cli-alpine:
Unfortunately there's nothing in the logs with a timestamp between the end of APK and the start of pecl but we have similar package installs on other containers and they're always pretty fast so I'm pretty sure the grpc was the bulk of that 9 minutes... |
This is still an issue with gRPC 1.35; the FYI, I have also been suffering from slow compilation. I am now using the following command to tremendously speed up the compilation process, which instructs
I am also looking into stripping the binary during compilation now. |
Update: I have not found a way to pass |
Chiming in to say I'm getting an extremely slow run time for this process, eventually failing with this message:
|
I've also this behavior on my side, compiling from source or using by using |
@stanley-cheung I'm not sure where this was fixed and therefore if I should be waiting for a release? But FYI I am still seeing this when installing grpc-1.51.1 from pecl on a standard php:8.1-cli-alpine container. This test case on github actions took 15m 51s just for the pecl install and creates a 173.6M binary: This is the Dockerfile I'm using to test that, I don't think it's doing anything unusual:
|
Hi everyone! We also see gRPC's overhead in our builds. In the build's output we can see:
somehow gRPC's module is not stripped (it's installed in the same batch as extensions seen above). Why? 🤔 Anyway, thanks to comments above I was able to optimise our build both in terms of size and speed 🙂 Thank you very much! |
Hi Mind sharing the dockerfile for this? And how long did it took you to build it? |
@cmius I can't share the Dockerfile since it's proprietary. What I can tell we install gRPC along with several other extensions and when gRPC was added to the Dockerfile, it significantly increased build time. We're migrating from 7.4 to 8.2 and both builds were affected (starting from official PHP images based on Debian). |
You don't really need @Wirone's Dockerfile if you just use the below suggestions, I don't believe @Wirone is doing anything else to decrease build times or container sizes. Decreasing build timesYou can often speed up extension build times by increasing the number of jobs In both of the above cases we use Reducing container sizeTo strip all your php extensions you can just add this layer # strip php extensions to decrease container size
RUN \
set -eux \
\
&& find "$(php-config --extension-dir)" -name '*.so' -type f -exec strip --strip-all {} \; The relevant command being: find "$(php-config --extension-dir)" -name '*.so' -type f -exec strip --strip-all {} \; This uses Other improvements
N.B. If you are building multi architecture images using emulation for the different architectures this will significantly impact build times, negatively. |
FYI: we couldn't use |
@Wirone 20 minutes is still a long time. Why is the build so large? Most php extensions build in a minute or less |
@jontro we have many OS-level packages to install, 11 extensions to install (9 for prod target, additional 2 for dev), we also copy some files from other internal, pre-built images, we clear few dirs after installation. When it sums up, it takes time 🤷♂️. And of course I don't say everything is optimal right now, I just wanted to share the info that we had the same problem with gRPC and were able to reduce this overhead with advices above 🙂 |
@tomekit how do you build an image from an already pre-built grpc installed image? |
@akeebismail After trying many alternate ways to try and build the This way means that when we build and deploy our application, it doesn't take 30+ minutes; just the time it takes to pull the e.g.
The app image then contains it as a base:
|
What version of gRPC and what language are you using?
What operating system (Linux, Windows,...) and version?
Ubuntu 18.08
What runtime / compiler are you using (e.g. python version or version of gcc)
pecl
What did you do?
time sudo pecl install grpc
What did you expect to see?
The extension install in a reasonable timeframe and at a reasonable size
What did you see instead?
The pecl install takes 6m 21s (on a machine that is not usually slow):
I have seen similar execution times running the pecl install as part of Docker build on Google Cloud Build. This is far and away the longest part of our entire build process.
I realise in a Docker environment it's possible to use layer caching to reduce the impact of this, we are currently working in a hybrid environment and have some projects where we need to install onto VMs semi-regularly where a 6.5 minute build for one extension is somewhat problematic.
The generated binary is 55Mb in size:
On our VMs that's not such an issue, but on our Docker environments again that means grpc is actually one of the single biggest contributors to our overall image size.
Anything else we should know
I found #22040 (comment) which suggested the binary size is largely due to debug symbols. This appears to be the case, running
strip --strip-debug /usr/lib/php/20170718/grpc.so
reduces the size of the binary to 5.0Mb which is much more acceptable.However I can't see any documentation / information on whether this is recommended and/or whether it's possible to get pecl to build the package with the debug symbols already stripped.
The text was updated successfully, but these errors were encountered: