Skip to content

Commit

Permalink
Dump bench weights
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteNacked committed May 16, 2024
1 parent 6f38466 commit 6d8c498
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
13 changes: 2 additions & 11 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,6 @@ jobs:
- name: Run all benchmarks
run: |
./scripts/benchmarking/run_all_benchmarks.sh -c vara-dev -m
cp ./scripts/benchmarking/weights-output/* runtime/vara/src/weights
# apply some patches for `pallets/gear/src/weights.rs`
cp runtime/vara/src/weights/pallet_gear.rs pallets/gear/src/weights.rs
sed -i -E 's/\w+::WeightInfo for SubstrateWeight/WeightInfo for SubstrateWeight/' pallets/gear/src/weights.rs
# apply some patches for `pallets/gear-builtin/src/weights.rs`
cp runtime/vara/src/weights/pallet_gear_builtin.rs pallets/gear-builtin/src/weights.rs
sed -i -E 's/\w+::WeightInfo for SubstrateWeight/WeightInfo for SubstrateWeight/' pallets/gear-builtin/src/weights.rs
# generate code for lightweight scheduler that is used in gtest and other crates
./scripts/weight-dump.sh
- name: "ACTIONS: Upload artifact with benchmarking errors (if exist)"
if: ${{ always() }}
Expand All @@ -132,8 +123,8 @@ jobs:
with:
name: weights-vara
path: |
runtime/vara/src/weights/
utils/wasm-instrument/src/gas_metering/
scripts/benchmarking/weights-output
- name: "TIP: download the artifacts and use `./scripts/unpack-weights.sh`"
run: |
Expand Down
12 changes: 12 additions & 0 deletions .maintain/dump_weights.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
{{#each benchmarks as |benchmark|}}
"{{benchmark.name}}": {
"base": {{benchmark.base_weight}},
{{#each benchmark.component_weight as |cw|}}
"cw_slope": {{cw.slope}}
{{~#unless @last}},{{/unless}}
{{/each}}
}
{{~#unless @last}},{{/unless}}
{{/each}}
}
10 changes: 5 additions & 5 deletions scripts/benchmarking/run_all_benchmarks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ for PALLET in "${PALLETS[@]}"; do
EXTRINSICS=("*")
fi

WEIGHT_FILE="./${WEIGHTS_OUTPUT}/${PALLET}.rs"
WEIGHT_FILE="./${WEIGHTS_OUTPUT}/${PALLET}.json"
echo "[+] Benchmarking $PALLET with weight file $WEIGHT_FILE";

OUTPUT=$(
Expand All @@ -163,7 +163,7 @@ for PALLET in "${PALLETS[@]}"; do
--extrinsic="$(IFS=, ; echo "${EXTRINSICS[*]}")" \
--heap-pages=4096 \
--output="$WEIGHT_FILE" \
--template=.maintain/frame-weight-template.hbs 2>&1
--template=.maintain/dump_weights.hbs 2>&1
)

if [ $? -ne 0 ]; then
Expand All @@ -183,8 +183,8 @@ for PALLET in "${PALLETS[@]}"; do
--pallet="$PALLET" \
--extrinsic="$(IFS=', '; echo "${ONE_TIME_EXTRINSICS[*]}")" \
--heap-pages=4096 \
--output="./${WEIGHTS_OUTPUT}/${PALLET}_onetime.rs" \
--template=.maintain/frame-weight-template.hbs 2>&1
--output="./${WEIGHTS_OUTPUT}/${PALLET}_onetime.json" \
--template=.maintain/dump_weights.hbs 2>&1
)

if [ $? -ne 0 ]; then
Expand Down Expand Up @@ -224,7 +224,7 @@ else
fi

# Merge pallet_gear weights.
./scripts/benchmarking/merge_outputs.sh
#./scripts/benchmarking/merge_outputs.sh

# Check if the error file exists.
if [ -f "$ERR_FILE" ]; then
Expand Down

0 comments on commit 6d8c498

Please sign in to comment.