Skip to content
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

#43: Add a rake task to compress binaries with UPX #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

k3rni
Copy link

@k3rni k3rni commented Oct 28, 2018

It's been added to the gem package task's prerequisites, so the binaries will be changed locally and then packed into the gem. This PR doesn't contain the packed binaries themselves. My idea is that we should grab and store the upstream binaries untouched, but ship the compact versions with this gem.

Gemfile size before packing: 171MB
After packing: 45MB

Also, the task is safe to run multiple times - already-compressed files will be detected and skipped (using upx -t).

…of the gem packing task.

It's safe to run multiple times - already-compressed files will be detected and skipped.
@ericboehs
Copy link

ericboehs commented Jan 30, 2019

This would be great to see merged. @zakird any suggestions to getting this moved along?

@k3rni k3rni mentioned this pull request Aug 16, 2019
@webaholik
Copy link

I believe this solves a blocker related to update_to_0.12.5 - let's get it merged.

@unixmonkey
Copy link
Collaborator

@k3rni I've merged PR #49, and the built gem for that is around 250mb (instead of 171 as claimed here, but probably because it's changed since you looked).

I'd love to add this, but after making some adjustments to this (unpacking the .gz files, running upx over them all), and re-creating the gem, it only comes out 9Mb smaller (241mb), and gzipping the ups-compressed binaries comes out pretty much the same (as I'm sure is expected).

Am I doing something wrong? I'd love to get this working, as a 250mb gem is huge.

@k3rni
Copy link
Author

k3rni commented Nov 4, 2019

You are correct in that both versions result in a gem file of roughly the same size. UPX uses basically the same compression method as gzip, it just keeps the files executable directly, with no additional unpacking step required.

The changes to bin/wkhtmltopdf(0c076ab and later f2d79ae) were made much later than my PR (about 7 months later), and result in mostly the same thing - binaries are shipped compressed, with the one you actually need extracted on first use. The only difference now is if you were to use the gem on a restricted, read-only filesystem (like Heroku's slugs) or install gems system-wide, then try to use them as a regular user and fail on a permission error. Whereas with upx, the files can be run with no additional steps.

Those error conditions listed are strictly conjecture - haven't tested that. So feel free to keep the current solution and discard this, as the goals were achieved anyway :)

@k3rni
Copy link
Author

k3rni commented Jan 27, 2020

Closing due to inactivity and the issue being solved elsewhere.

@k3rni k3rni closed this Jan 27, 2020
@unixmonkey
Copy link
Collaborator

Reopening because I think we want to do this. I've had a number of reports from people having trouble uncompressing the gzipped files, especially on systems with restricted filesystems.

@unixmonkey unixmonkey reopened this Jan 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants