Skip to content

Commit a43c311

Browse files
Kaiwei Tufacebook-github-bot
authored andcommitted
Add a new concurrent hashmap benchmark to AI benchmark suite in DCPerf. (#147)
Summary: Pull Request resolved: #147 This update introduces a new benchmark type, CHM, to the AI benchmark suite. The CHM benchmark simulates the usage pattern of a concurrent hash map in machine learning workloads, where certain key-value pairs are hashed in an in-memory key-value store for retrieval. #### HOW TO RUN THE NEW BENCHMARK To install and run the rebatch benchmark, use the following commands: ``` ./benchpress_cli.py -b ai install chm_a // Install the chm workload representing workload A ./benchpress_cli.py -b ai install chm_b // Install the chm workload representing workload B ./benchpress_cli.py -b ai run chm_a // Run the chm workload representing workload A ./benchpress_cli.py -b ai run chm_b // Run the chm workload representing workload B ``` #### FILES ADDED AND MODIFIED ``` - benchpress - configs - benchmarks_ai.yml // Added the new chm benchmark. - jobs_ai.yml // Added two new chm benchmark jobs. - plugins - parsers.py - chm.py // Added a new parser for the chm benchmark. - __init__.py // Registered the new parser. - packages - chm - install_chm.sh // Added a new installation script for chm benchmark. - cleanup_chm.sh // Added a new cleanup script for chm benchmark. - ChmBenchmark.cpp // Added a benchmark simuates the concurrent hash map workload. - CMakeLists.txt // CMake file to compile the benchmark. - ConcurrentHashMap.h // A sharded concurrent hash map implementation - model_a.dist // Key distribution file for workload A. - model_b.dist // Key distribution file for workload B. - BUCK // Updated to include the new benchmark components. ... ``` Differential Revision: D77214563
1 parent 41826be commit a43c311

File tree

11 files changed

+1254
-2
lines changed

11 files changed

+1254
-2
lines changed

benchpress/config/benchmarks_ai.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,11 @@ rebatch:
1414
metrics:
1515
- bandwidth
1616
- time_per_batch_us
17+
18+
chm:
19+
parser: chm
20+
install_script: ./packages/chm/install_chm.sh
21+
cleanup_script: ./packages/chm/cleanup_chm.sh
22+
path: ./benchmarks/chm/chm_bench
23+
metrics:
24+
- mops

benchpress/config/jobs_ai.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104

105105
- benchmark: rebatch
106106
name: rebatch_a
107-
description: rebatch benchmark for Model A.
107+
description: Rebatch benchmark for Model A.
108108
args:
109109
- '--threads={threads}'
110110
- '--duration={duration}'
@@ -125,7 +125,7 @@
125125

126126
- benchmark: rebatch
127127
name: rebatch_b
128-
description: rebatch benchmark for Model B.
128+
description: Rebatch benchmark for Model B.
129129
args:
130130
- '--threads={threads}'
131131
- '--duration={duration}'
@@ -143,3 +143,30 @@
143143
- 'prefetch=0'
144144
- 'output_tensor_size=2421002'
145145
- 'memory_pool_size=4'
146+
147+
- benchmark: chm
148+
name: chm_a
149+
description: Concurrent hash map benchmark for Model A.
150+
args:
151+
- '--distribution_file={distribution_file}'
152+
- '--num_threads={num_threads}'
153+
- '--duration_seconds={duration_seconds}'
154+
155+
vars:
156+
- 'distribution_file=benchmarks/chm/model_a.dist'
157+
- 'num_threads=16'
158+
- 'duration_seconds=360'
159+
160+
161+
- benchmark: chm
162+
name: chm_b
163+
description: Concurrent hash map benchmark for Model B.
164+
args:
165+
- '--distribution_file={distribution_file}'
166+
- '--num_threads={num_threads}'
167+
- '--duration_seconds={duration_seconds}'
168+
169+
vars:
170+
- 'distribution_file=benchmarks/chm/model_b.dist'
171+
- 'num_threads=16'
172+
- 'duration_seconds=360'

benchpress/plugins/parsers/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from .benchdnn import BenchdnnParser
1212
from .cachebench import CacheBenchParser
1313
from .checkmark import CheckmarkParser
14+
from .chm import ChmParser
1415
from .clang import ClangParser
1516
from .cloudsuite_graph import CloudSuiteGraphParser
1617
from .compression_parser import CompressionParser
@@ -104,6 +105,7 @@ def register_parsers(factory):
104105
factory.register("syscall", SyscallParser)
105106
factory.register("embedding", EmbeddingParser)
106107
factory.register("rebatch", RebatchParser)
108+
factory.register("chm", ChmParser)
107109

108110
if not open_source:
109111
factory.register("adsim", AdSimParser)

benchpress/plugins/parsers/chm.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
#
4+
# This source code is licensed under the MIT license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# pyre-unsafe
8+
import re
9+
10+
from benchpress.lib.parser import Parser
11+
12+
13+
class ChmParser(Parser):
14+
def parse(self, stdout, stderr, returncode):
15+
metrics = {}
16+
17+
# Parse stdout for operations per second
18+
for line in stdout:
19+
# Match "Millions of Operations per Second: X Mops/sec"
20+
match = re.search(
21+
r"Millions of Operations per Second:\s*(\d+\.\d+)\s*Mops/sec", line
22+
)
23+
if match:
24+
metrics["mops"] = float(match.group(1))
25+
break
26+
27+
return metrics

packages/chm/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
project(ChmBench LANGUAGES CXX)
3+
4+
set(CMAKE_PREFIX_PATH
5+
"${CMAKE_SOURCE_DIR}/installed"
6+
${CMAKE_PREFIX_PATH})
7+
set(CMAKE_CXX_STANDARD 17)
8+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
9+
10+
11+
find_package(folly CONFIG REQUIRED)
12+
find_package(gflags CONFIG REQUIRED)
13+
14+
add_executable(chm_bench ChmBenchmark.cpp)
15+
16+
17+
target_link_libraries(chm_bench PRIVATE Folly::folly)

0 commit comments

Comments
 (0)