Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions benchpress/config/jobs_ai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down
41 changes: 41 additions & 0 deletions packages/chm/ChmBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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
Expand All @@ -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=<path>"
Expand Down
9 changes: 6 additions & 3 deletions packages/chm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading