On linux use sysfs instead of lscpu

Use sysfs (https://www.kernel.org/doc/Documentation/ABI/stable/sysfs-devices-node)
to determine processor to NUMA node mapping.

Avoids problems on some machines with high core count where lscpu was showing high cpu utilization.

closes https://github.com/official-stockfish/Stockfish/pull/5315

No functional change
This commit is contained in:
Tomasz Sobczyk
2024-05-30 17:22:53 +02:00
committed by Disservin
parent 86694b5914
commit c8375c2fbd
3 changed files with 107 additions and 84 deletions
+10 -14
View File
@@ -88,21 +88,12 @@ struct PipeDeleter {
}
};
inline std::optional<std::string> get_system_command_output(const std::string& command) {
std::unique_ptr<FILE, PipeDeleter> pipe(popen(command.c_str(), "r"));
if (!pipe)
return std::nullopt;
std::string result;
char buffer[1024];
while (fgets(buffer, sizeof(buffer), pipe.get()) != nullptr)
result += buffer;
return result;
}
#endif
// Reads the file as bytes.
// Returns std::nullopt if the file does not exist.
std::optional<std::string> read_file_to_string(const std::string& path);
void dbg_hit_on(bool cond, int slot = 0);
void dbg_mean_of(int64_t value, int slot = 0);
void dbg_stdev_of(int64_t value, int slot = 0);
@@ -118,9 +109,12 @@ inline TimePoint now() {
}
inline std::vector<std::string> split(const std::string& s, const std::string& delimiter) {
size_t begin = 0;
std::vector<std::string> res;
if (s.empty())
return res;
size_t begin = 0;
for (;;)
{
const size_t end = s.find(delimiter, begin);
@@ -136,6 +130,8 @@ inline std::vector<std::string> split(const std::string& s, const std::string& d
return res;
}
void remove_whitespace(std::string& s);
enum SyncCout {
IO_LOCK,
IO_UNLOCK