Skip to content

Commit 024e7ad

Browse files
committed
Baremetal script for running batch expriments with background eviction promotion and DML. Includes json parsing and metric aggregation for analysis and plotting
1 parent ff44c3c commit 024e7ad

9 files changed

+55166
-0
lines changed

baremetal/README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Bare-metal Testing Scripts
2+
3+
4+
> ### accelConfig.sh
5+
>
6+
>> Set up DSA devices using accel-config.
7+
>> - OPTIONAL Arg-1: DSA device id. Default: 0
8+
>> - OPTIONAL Arg-2: Enable/Disable DSA device. Default: yes
9+
>> - OPTIONAL Arg-3: SHARED WQ id. Default: 1
10+
>> - OPTIONAL Arg-4: ENGINE count. Default: 4
11+
>> - OUTPUT Verify DSA devices set up is correct using accel-config
12+
13+
14+
> ### runTestAndConvertToJson.py
15+
>
16+
>> Run a single test and convert the output TXT to CSV.
17+
>> This script uses numactl to bind all threads to node 0.
18+
>> Run with **sudo**
19+
>> - REQUIRED Arg-1: Cachebench config file path from root directory
20+
>> - REQUIRED Arg-2: DSA device count
21+
>> - REQUIRED Arg-3: Number of background evictors
22+
>> - REQUIRED Arg-4: Eviction batch size
23+
>> - REQUIRED Arg-5: Number of background promoters
24+
>> - REQUIRED Arg-6: Promotion batch size
25+
>> - REQUIRED Arg-7: Output path
26+
>> - OUTPUT txt and json saved in same path
27+
28+
29+
> ### aggregateAndFilterTestResults.py
30+
>
31+
>> Gather all output JSON using the file name filter
32+
>> Run with **sudo**
33+
>> - REQUIRED Arg-1: Output json directory path
34+
>> - REQUIRED Arg-2: Filter filenames using this string. Pass null str to gather all files.
35+
>> - OUTPUT Saved in a csv on the output JSON directory path
36+
37+
38+
> ### parseTestResultIntoCsv.py
39+
>
40+
>> Parse TXT output and save in JSON format
41+
>> - REQUIRED Arg-1: output txt file name
42+
>> - REQUIRED Arg-2: Tag a string for the text
43+
>> - OUTPUT Save CSV to the same path
44+
45+
46+
> ### sample.sh
47+
>
48+
>> This shows how to create a test sequence, then parses results and aggregates it.
49+
>> Run with **sudo**
50+
51+

baremetal/accelConfig.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
3+
echo "OPTIONAL Arg-1: DSA device id. Default: 0"
4+
echo "OPTIONAL Arg-2: Enable/Disable DSA device. Default: yes"
5+
echo "OPTIONAL Arg-3: SHARED WQ id. Default: 1"
6+
echo "OPTIONAL Arg-4: ENGINE count. Default: 4"
7+
8+
if [ "$#" -ge 5 ]; then
9+
echo "ERROR: Incorrect argument count. Expected arg count <= 4"
10+
exit 1
11+
fi
12+
13+
DEVID=${1:-0}
14+
ENABLE=${2:-yes}
15+
SWQID=${3:-1}
16+
NENGS=${4:-4}
17+
18+
DEV=dsa${DEVID}
19+
SWQ=${DEV}/wq${DEVID}.${SWQID}
20+
21+
echo "=> ${SWQ}:"
22+
accel-config disable-wq ${SWQ}
23+
24+
echo "=> ${DEV}:"
25+
accel-config disable-device ${DEV}
26+
27+
if [ "${ENABLE}" != "yes" ]; then
28+
echo "Exit after disabling ${DEV}."
29+
exit 1
30+
fi
31+
32+
for ((i=0; i < ${NENGS}; i++))
33+
do
34+
echo "=> ${DEV}/engine${DEVID}.${i}"
35+
echo "configured"
36+
accel-config config-engine ${DEV}/engine${DEVID}.${i} --group-id=0
37+
done
38+
39+
accel-config config-wq ${SWQ} --group-id=0
40+
accel-config config-wq ${SWQ} --priority=1
41+
accel-config config-wq ${SWQ} --wq-size=128
42+
accel-config config-wq ${SWQ} --max-batch-size=1024
43+
accel-config config-wq ${SWQ} --max-transfer-size=2147483648
44+
accel-config config-wq ${SWQ} --block-on-fault=0
45+
accel-config config-wq ${SWQ} --type=user
46+
accel-config config-wq ${SWQ} --name="dsa-test"
47+
accel-config config-wq ${SWQ} --mode=shared
48+
accel-config config-wq ${SWQ} --threshold=127
49+
accel-config config-wq ${SWQ} --driver-name="user"
50+
51+
echo "=> ${DEV}:"
52+
accel-config enable-device ${DEV}
53+
54+
echo "=> ${SWQ}:"
55+
accel-config enable-wq ${SWQ}
56+
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/usr/bin/python3
2+
3+
import sys
4+
import json
5+
import re
6+
import os
7+
import pandas as pd
8+
import csv
9+
10+
11+
def listJson(path, filterStr):
12+
jsonFiles = [jsonFile for jsonFile in os.listdir(path) if jsonFile.endswith('.json') and filterStr in jsonFile]
13+
return [path + f for f in jsonFiles]
14+
15+
16+
def getMetrics(files, cbCols, sysCols):
17+
values = {}
18+
for entry in files:
19+
with open(entry, 'r') as jsonFile :
20+
data = json.load(jsonFile)
21+
key = os.path.basename(entry).rsplit(".", 1)[0]
22+
values[key] = {}
23+
for col in cbCols:
24+
values[key][col] = data['cachebench_metrics'][col]
25+
for col in sysCols:
26+
values[key][col] = data['system_metrics'][col]
27+
return values
28+
29+
30+
def main():
31+
args = sys.argv[1:]
32+
if len(args) < 1 or len(args) > 2:
33+
print("Invalid Args. Required : path, filter-string")
34+
exit()
35+
36+
path = args[0]
37+
filterStr = args[1] if len(args) == 2 else ''
38+
files = listJson(path, filterStr)
39+
40+
cbCols = [
41+
'cache_allocate_api_latency_p90_in_ns',
42+
'cache_allocate_api_latency_p99_in_ns',
43+
'cache_find_api_latency_p90_in_ns',
44+
'cache_find_api_latency_p99_in_ns',
45+
'cache_background_eviction_latency_p90_in_ns',
46+
'cache_background_eviction_latency_p99_in_ns',
47+
'cache_evict_dml_large_item_wait_latency_p90_in_ns',
48+
'cache_evict_dml_large_item_wait_latency_p99_in_ns',
49+
'cache_evict_dml_small_item_wait_latency_p90_in_ns',
50+
'cache_evict_dml_small_item_wait_latency_p99_in_ns',
51+
'cache_background_promotion_latency_p90_in_ns',
52+
'cache_background_promotion_latency_p99_in_ns',
53+
'cache_promote_dml_large_item_wait_latency_p90_in_ns',
54+
'cache_promote_dml_large_item_wait_latency_p99_in_ns',
55+
'cache_promote_dml_small_item_wait_latency_p90_in_ns',
56+
'cache_promote_dml_small_item_wait_latency_p99_in_ns'
57+
]
58+
59+
sysCols = [
60+
'dsa0/event=0x1,event_category=0x0/',
61+
'dsa0/event=0x10,event_category=0x1/',
62+
'dsa0/event=0x2,event_category=0x3/',
63+
'time_elapsed_in_secs',
64+
'user_time_seconds',
65+
'percent_of_cpu_this_job_got'
66+
]
67+
metrics = getMetrics(files, cbCols, sysCols)
68+
69+
''' Save metrics to csv '''
70+
fields = ['test'] + cbCols + sysCols
71+
csvFile = os.path.join(path , 'metrics.' + filterStr + '.csv')
72+
with open(csvFile, 'w') as f:
73+
w = csv.DictWriter(f, fields)
74+
w.writeheader()
75+
for key, val in sorted(metrics.items()):
76+
row = {'test': key}
77+
row.update(val)
78+
w.writerow(row)
79+
print("Filter: {0} ; Results gathered in {1}".format(filterStr, csvFile))
80+
81+
82+
if __name__ == '__main__':
83+
main()

baremetal/cdn/config.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"cache_config": {
3+
"cacheSizeMB": 32768,
4+
"dsaEnabled": "true",
5+
"minBatchSizeForDsaUsage": 10,
6+
"largeItemMinSize": 4096,
7+
"largeItemBatchEvictDsaUsageFraction": 0.75,
8+
"smallItemBatchEvictDsaUsageFraction": 0.7,
9+
"htBucketPower": 27,
10+
"htBucketLock": 27,
11+
"evictorThreads": 4,
12+
"maxEvictionBatch": 100,
13+
"backgroundEvictorIntervalMilSec": 1,
14+
"promotorThreads": 4,
15+
"maxPromotionBatch": 100,
16+
"backgroundPromoterIntervalMilSec": 1,
17+
"memoryTiers": [
18+
{
19+
"ratio": 1,
20+
"memBindNodes": 0
21+
},
22+
{
23+
"ratio": 1,
24+
"memBindNodes": 1
25+
}
26+
],
27+
"poolRebalanceIntervalSec": 0,
28+
"moveOnSlabRelease": false
29+
},
30+
"test_config": {
31+
"addChainedRatio": 0.0,
32+
"delRatio": 0.0,
33+
"enableLookaside": true,
34+
"getRatio": 0.9911552928593673,
35+
"keySizeRange": [
36+
1,
37+
8,
38+
64
39+
],
40+
"keySizeRangeProbability": [
41+
0.3,
42+
0.7
43+
],
44+
"loneGetRatio": 0.008844707140632665,
45+
"numKeys": 8935378,
46+
"numOps": 5000000,
47+
"opRatePerSec": 1000000,
48+
"numThreads": 24,
49+
"popDistFile": "pop.json",
50+
"setRatio": 0.0,
51+
"valSizeDistFile": "sizes.json"
52+
}
53+
}

0 commit comments

Comments
 (0)