Conversation
20103fc to
cc94811
Compare
cc94811 to
1d92d07
Compare
- ### Problem In ruby#9381, I explained the issue about the "tail latency". TL;DR When a gem with a native extensions is downloaded, the sooner we starts compiling, the sooner it gets installed. If a gem with a native extensions ends up at the end of the queue, the longer `bundle install` becomes. ### Solution I'd like to introduce a simple queue with priority. When a gem is downloaded, we check whether that gem has a native extension and if its dependencies are installed. If both conditions are met, we add the gem in the priority queue to be picked up as quickly as possible.
1d92d07 to
c271257
Compare
eileencodes
left a comment
There was a problem hiding this comment.
One small suggestion, otherwise this look good.
| end | ||
|
|
||
| def enqueue_with_priority? | ||
| state == :installable && spec.extensions.any? |
There was a problem hiding this comment.
Since installed is defined above, I think we should use that here.
| state == :installable && spec.extensions.any? | |
| installed? && spec.extensions.any? |
There was a problem hiding this comment.
installed is a different state that installable.
installed means that the spec is fully installed and there is nothing else to do.
installable means that the spec is downloaded and can be installed immediately (either because its a pure ruby gem, or because it's a native extension gem and its dependencies are installed)
There was a problem hiding this comment.
Oh whoops I read it wrong. 🤦🏼♀️
I originally wrote that in the PR description as that's what I was consistently seeing. We now have a set of benchmark where we can run our changes on and it shows a much smaller gain. This change is hard to benchmark correctly since the optimization is purely on improving The slower compilation is on a machine, the bigger the impact this change has on |
What was the end-user or developer problem that led to this PR?
In #9381, I explained the issue about the "tail latency" problem.
TL;DR When a gem with a native extensions is downloaded, the sooner we starts compiling, the sooner it gets installed. If a gem with a native extensions ends up at the end of the queue, the longer
bundle installbecomes.Before (Profile recorded from master)
After
What is your fix for the problem, implemented in this PR?
I'd like to introduce a simple queue with priority. When a gem is downloaded, we check whether that gem has a native extension and if its dependencies are installed. If both conditions are met, we add the gem in the priority queue to be picked up as quickly as possible.
Make sure the following tasks are checked