Skip to content
Snippets Groups Projects
Unverified Commit 18e8b147 authored by J. Martin's avatar J. Martin
Browse files

Limit the gem native build resources

When building the native extension make -j can absorb all available
resources on a system.  Implement "reasonable" limits on the number
of compiling jobs when the number of processors can be detected and
use a conservative count when ruby version does not provide detection.
parent ed7d06af
No related branches found
No related tags found
No related merge requests found
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
require 'etc'
require 'mkmf' require 'mkmf'
LIBDIR = RbConfig::CONFIG['libdir'] LIBDIR = RbConfig::CONFIG['libdir']
...@@ -80,7 +81,9 @@ ENV['BUILDDIR'] = output_dir ...@@ -80,7 +81,9 @@ ENV['BUILDDIR'] = output_dir
unless windows unless windows
puts 'Building internal gRPC into ' + grpc_lib_dir puts 'Building internal gRPC into ' + grpc_lib_dir
system("make -j -C #{grpc_root} #{grpc_lib_dir}/libgrpc.a CONFIG=#{grpc_config}") nproc = 4
nproc = Etc.nprocessors * 2 if Etc.respond_to? :nprocessors
system("make -j#{nproc} -C #{grpc_root} #{grpc_lib_dir}/libgrpc.a CONFIG=#{grpc_config}")
exit 1 unless $? == 0 exit 1 unless $? == 0
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment