From c53bc99b4aae5dee521e1217fc1c5034261ef195 Mon Sep 17 00:00:00 2001 From: Benjamin Owad Date: Tue, 31 Oct 2023 01:00:23 -0400 Subject: [PATCH] Dynamically set make's -j flag to use all available CPUs --- compatibility_analysis.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/compatibility_analysis.py b/compatibility_analysis.py index 3db5ce1d8..15910a61d 100644 --- a/compatibility_analysis.py +++ b/compatibility_analysis.py @@ -4,6 +4,7 @@ import json import os import subprocess +import multiprocessing import sys # File paths (globals) @@ -21,6 +22,8 @@ port_num = 5432 exit_flag = False +nproc = multiprocessing.cpu_count(); + # Load extension database extn_files = os.listdir(current_working_dir + "/" + extn_info_dir) extn_db = {} @@ -79,8 +82,8 @@ def install_extn(extn_name, extn_entry, terminal_file): return elif install_type == "pgxs": install_extn_dir = current_working_dir + "/" + ext_work_dir + "/" + extn_entry["folder_name"] - subprocess.run("make USE_PGXS=1 PG_CONFIG=" + pg_config_path + " -j8", shell=True, cwd=install_extn_dir, stdout=terminal_file, stderr=terminal_file) - subprocess.run("make USE_PGXS=1 PG_CONFIG=" + pg_config_path + " install -j8", shell=True, cwd=install_extn_dir, stdout=terminal_file, stderr=terminal_file) + subprocess.run("make USE_PGXS=1 PG_CONFIG=" + pg_config_path + f" -j{nproc}", shell=True, cwd=install_extn_dir, stdout=terminal_file, stderr=terminal_file) + subprocess.run("make USE_PGXS=1 PG_CONFIG=" + pg_config_path + f" install -j{nproc}", shell=True, cwd=install_extn_dir, stdout=terminal_file, stderr=terminal_file) elif install_type == "shell_script": # Copy shell script over to the installation directory and run it. install_extn_dir = current_working_dir + "/" + ext_work_dir + "/" + extn_entry["folder_name"] @@ -165,8 +168,8 @@ def install_postgres(postgres_config_options = []): subprocess.run("./configure --prefix=" + prefix + " " + config_options_str, capture_output=True, shell=True, cwd=postgres_dir) subprocess.run("make clean", capture_output=True, shell=True, cwd=postgres_dir) - subprocess.run("make world-bin -j8", capture_output=True, shell=True, cwd=postgres_dir) - subprocess.run("make install-world-bin -j8", capture_output=True, shell=True, cwd=postgres_dir) + subprocess.run(f"make world-bin -j{nproc}", capture_output=True, shell=True, cwd=postgres_dir) + subprocess.run(f"make install-world-bin -j{nproc}", capture_output=True, shell=True, cwd=postgres_dir) print("Done installing Postgres " + postgres_version + "...") def get_configure_options(extns_to_install): @@ -763,4 +766,5 @@ def single_mode(file_extns_filename): pairwise_parallel_mode(extn_list_filename) elif mode == 'combinatorial': ### TODO: Support combinatorial mode - print("Combinatorial mode not supported yet!") \ No newline at end of file + print("Combinatorial mode not supported yet!") +