Closed Tensho closed 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
I'm also thinking about adding cores number auto-detection. For example:
> require 'concurrent'
=> true
> Concurrent.processor_count
=> 8
Is it reasonable?
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.
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.
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
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
Bundler
--jobs
option is loyal to overhead and if you don't have4
cores it just fallbacks to1
. 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
sshkit
from gemspec, because it's alreadycapistrano
dependency