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

Add libgmp for faster Integer calculations. #266

Merged
merged 2 commits into from
Mar 1, 2019

Conversation

lsb
Copy link
Contributor

@lsb lsb commented Feb 27, 2019

I was wondering why some large integer multiplications were taking a while, so I ran

$ docker run ruby:2.6 ruby -e 'puts Integer::GMP_VERSION'
-e:1:in `<main>': uninitialized constant Integer::GMP_VERSION (NameError)

and found that GMP wasn't included in the default images. Building these images gives me

$ docker run ruby:gmp-2.6 ruby -e 'puts Integer::GMP_VERSION'
GMP 6.1.2

For significantly large integers (on my machine) GMP is over 50x faster than Ruby's fallback Integer methods: https://github.com/ruby/ruby/blob/a2eb04f52dccb9b42404f8b133acb36b577e3b54/bignum.c#L2527

@lsb

This comment has been minimized.

@tianon
Copy link
Member

tianon commented Mar 1, 2019

Nice catch; I dug in and found ruby/ruby@83a0709, which led me to wonder if this was actually applicable enough to add to buildpack-deps which led me to find:

... and thus file docker-library/buildpack-deps#92. 👍

@tianon
Copy link
Member

tianon commented Mar 1, 2019

(but this is still applicable for -slim and -alpine variants, so I'll be pushing an update shortly after I finish a little testing to make sure it works on each)

@tianon tianon merged commit f2bdb4a into docker-library:master Mar 1, 2019
tianon added a commit to infosiftr/stackbrew that referenced this pull request Mar 1, 2019
- `buildpack-deps`: `libgmp-dev` (docker-library/buildpack-deps#92)
- `docker`: 18.09.3
- `ghost`: 2.16.2
- `mariadb`: 10.4.3
- `mongo`: 3.6.11
- `openjdk`: 13-ea+10
- `rabbitmq`: 3.7.13-rc.2, `RABBITMQ_VM_MEMORY_HIGH_WATERMARK=0` valid (docker-library/rabbitmq#322)
- `ruby`: `libgmp` (docker-library/ruby#266)
@maxbrunet
Copy link

@juusujanar I got the issue with nokogiri on alpine and fixed it by installing gmp-dev.

maxbrunet added a commit to maxbrunet/lofocats_api that referenced this pull request Mar 3, 2019
maxbrunet added a commit to maxbrunet/lofocats_ui that referenced this pull request Mar 3, 2019
maxbrunet added a commit to maxbrunet/lofocats_api that referenced this pull request Mar 3, 2019
maxbrunet added a commit to maxbrunet/lofocats_ui that referenced this pull request Mar 3, 2019
@ghost
Copy link

ghost commented Mar 4, 2019

jaro_winkler can't build on ruby:2.4.5-slim-stretch. Add libgmp-dev fixed it.

@springerigor
Copy link

Since this PR was merged libgmp-dev is removed by apt-get purge command. As a result it is not available during runtime and some Ruby gems depends on it (like well-known nokogiri).

To solve the issue you should install it by yourself (apt get libgmp-dev).

I tested it with Ruby 2.5.3 & Nokogiri 1.8.4 and the described approach solved the issue.

@tianon
Copy link
Member

tianon commented Mar 4, 2019

See #267 for where this issue is being discussed further.

@docker-library docker-library locked and limited conversation to collaborators Mar 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants