Skip to content

Commit 14687fd

Browse files
committed
Use sysconf to get the number of processors online for parallel processing
1 parent 311d815 commit 14687fd

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/PackCommand.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,11 @@ static bool get_file_extents_hash(const string& file_name, FsExtentsHash* result
317317
// The keys of the returned map are the full file names of the mapped files.
318318
static map<string, FileHash> gather_file_info(const string& trace_dir) {
319319
vector<TraceReader::MappedData> files = gather_files(trace_dir);
320-
int use_cpus = min(20, get_num_cpus());
320+
int online_cpus = sysconf(_SC_NPROCESSORS_ONLN);
321+
if (online_cpus < 1) {
322+
FATAL() << "sysconf(_SC_NPROCESSORS_ONLN) failed";
323+
}
324+
int use_cpus = min(20, online_cpus);
321325
use_cpus = min((int)files.size(), use_cpus);
322326

323327
// List of files indexed by their extents hash. All files

0 commit comments

Comments
 (0)