capistrano / bundler

Bundler support for Capistrano 3.x
MIT License
219 stars 83 forks source link

Set Bundler Jobs Default to 4 #110

Closed Tensho closed 6 years ago

Tensho commented 6 years ago

Bundler --jobs option is loyal to overhead and if you don't have 4 cores it just fallbacks to 1. Even majority of the smartphones has 2+ cores, so it's reasonable to set 4 as default. In this case, the majority of people will leverage on parallelization out of the box without any extra configuration.

Improvements

capistrano-bot commented 6 years ago

Thanks for the PR! This project lacks automated tests, which makes reviewing and approving PRs somewhat difficult. Please make sure that your contribution has not broken backwards compatibility or introduced any risky changes.

Generated by :no_entry_sign: Danger

Tensho commented 6 years ago

I'm also thinking about adding cores number auto-detection. For example:

> require 'concurrent'
=> true
> Concurrent.processor_count
=> 8

Is it reasonable?

will-in-wi commented 6 years ago

I'd be fine with this change.

I don't think the Concurrent.processor_count would work because it would run locally, not on the relevant server.

Tensho commented 6 years ago

Thank you for the quick response 🙇 I guess capistrano (sshkit) provides capture method to run any command at remote host and get STDOUT as a result back to local host. Something like this should work:

cores = capture(:ruby, '-e "require 'concurrent'; puts Concurrent.processor_count"')

But it requires an upfront concurrent-ruby gem installation which is not cool.

will-in-wi commented 6 years ago

Yeah, and getting the CPU count in a cross-platform manner is quite tricky as shown by the source behind the Concurrent.processor_count method: https://github.com/ruby-concurrency/concurrent-ruby/blob/0ee31d0d2a7f144471578fb0e95a25e436ec48f5/lib/concurrent/utility/processor_counter.rb#L76

Tensho commented 6 years ago

TBH, I'm not sure does Capistrano support non-Unix platforms in a full range. For *nix servers we don't need any additional dependency:

> require 'etc'; 
=> true
> Etc.nprocessors`
=> 4

https://ruby-doc.org/stdlib-2.2.0/libdoc/etc/rdoc/Etc.html#method-c-nprocessors