diff --git a/benchpress/config/jobs_ai.yml b/benchpress/config/jobs_ai.yml index c38bc778..d832df15 100644 --- a/benchpress/config/jobs_ai.yml +++ b/benchpress/config/jobs_ai.yml @@ -172,7 +172,7 @@ vars: - 'distribution_file=benchmarks/chm/model_a.dist' - - 'num_threads=80' + - 'num_threads=64' - 'duration_seconds=360' - 'batch_size=10000000' - 'num_batch_threads=4' @@ -190,11 +190,46 @@ vars: - 'distribution_file=benchmarks/chm/model_b.dist' - - 'num_threads=80' + - 'num_threads=64' - 'duration_seconds=360' - 'batch_size=10000000' - 'num_batch_threads=4' +- benchmark: chm + name: chm_autoscale_a + description: Concurrent hash map benchmark for Model A. + args: + - '--distribution_file={distribution_file}' + - '--num_threads_for_one_socket={num_threads_for_one_socket}' + - '--duration_seconds={duration_seconds}' + - '--batch_size={batch_size}' + - '--num_batch_threads={num_batch_threads}' + + vars: + - 'distribution_file=benchmarks/chm/model_a.dist' + - 'duration_seconds=360' + - 'batch_size=10000000' + - 'num_batch_threads=4' + - 'num_threads_for_one_socket=true' + + +- benchmark: chm + name: chm_autoscale_b + description: Concurrent hash map benchmark for Model B. + args: + - '--distribution_file={distribution_file}' + - '--num_threads_for_one_socket={num_threads_for_one_socket}' + - '--duration_seconds={duration_seconds}' + - '--batch_size={batch_size}' + - '--num_batch_threads={num_batch_threads}' + + vars: + - 'distribution_file=benchmarks/chm/model_b.dist' + - 'duration_seconds=360' + - 'batch_size=10000000' + - 'num_batch_threads=4' + - 'num_threads_for_one_socket=true' + - benchmark: deser name: deser_a diff --git a/packages/chm/ChmBenchmark.cpp b/packages/chm/ChmBenchmark.cpp index db2ed5db..457541cd 100644 --- a/packages/chm/ChmBenchmark.cpp +++ b/packages/chm/ChmBenchmark.cpp @@ -36,6 +36,8 @@ // Command line flags DEFINE_string(distribution_file, "", "Path to the distribution CSV file"); DEFINE_int32(num_threads, 4, "Number of worker threads per batch"); +// If num_threads_for_one_socket is true then it will override num_threads +DEFINE_bool(num_threads_for_one_socket, false, "Use number of threads available in socket 0"); DEFINE_int32(num_batch_threads, 2, "Number of parallel batch threads"); DEFINE_int32(duration_seconds, 10, "Benchmark duration in seconds"); DEFINE_int32(initial_capacity, 0, "Initial hash map capacity hint"); @@ -622,6 +624,34 @@ class ChmBenchmark { } // namespace chm_benchmark +/** + * Get the cpu core count on single socket + */ +int get_cpu_core_count_for_one_socket() { + FILE* pipe = popen("lscpu -p=CPU,SOCKET", "r"); + if (!pipe) { + std::cerr << "Failed to run lscpu\n"; + return -1; + } + + char line[128]; + int cpu, socket; + int target_socket = 0; // Assume socket 0 + int count = 0; + while (fgets(line, sizeof(line), pipe)) { + if (line[0] == '#') continue; + if (sscanf(line, "%d,%d", &cpu, &socket) == 2) { + if (socket == target_socket) { + count++; + } + } + } + + pclose(pipe); + return count; +} + + /** * Main entry point for the ConcurrentHashMap benchmark * Parses command line arguments, loads distribution data, and executes @@ -631,6 +661,17 @@ int main(int argc, char* argv[]) { // Parse command line flags gflags::ParseCommandLineFlags(&argc, &argv, true); + // Check autoscale + if(FLAGS_num_threads_for_one_socket){ + int num_threads = get_cpu_core_count_for_one_socket(); + if (0 >= num_threads) { + std::cerr << "Failed to get cpu core count!\n"; + return 1; + } + FLAGS_num_threads = num_threads; + std::cout << "Autoscaled: " << FLAGS_num_threads << std::endl; + } + if (FLAGS_distribution_file.empty()) { std::cerr << "Error: Distribution file path is required. Use --distribution_file=" diff --git a/packages/chm/README.md b/packages/chm/README.md index 37f0d59a..ae4126f8 100644 --- a/packages/chm/README.md +++ b/packages/chm/README.md @@ -2,20 +2,23 @@ `chm` is a benchmark that simulates a concurrent hashmap workload representative of a widely used model. The benchmark closely mimics the implementation of a production-grade concurrent hashmap and utilizes workload distributions collected from real-world production environments. ## Installation -To install Adsim, execute the following command: +To install Chm, execute the following command: ```bash ./benchpress -b ai install chm_a ./benchpress -b ai install chm_b ``` -## Run Adsim +## Run Chm ### Job - `chm_a` and `chm_b` `chm_a` and `chm_b` correspondingly simuate the workload for Model A and Model B. +`chm_autoscale_a` and `chm_autoscale_b` sets num_threads to the threads of single socket. To run `chm` benchmark, please use following command ```bash ./benchpress -b ai run chm_a -./benchpress -b ai run chm_a +./benchpress -b ai run chm_b +./benchpress -b ai run chm_autoscale_a +./benchpress -b ai run chm_autoscale_b ``` ## Reporting and Measurement