Skip to content

storage benchmarking: read results not consistent when writes are benchmarked #10405

@michalkucharczyk

Description

@michalkucharczyk

While working on #10215 I was benchmarking Polkadot Asset Hub database storage read/write to understand the impact of the work I've done in #10215 to the performance.

It seems that benchmarking of writes does not leave the database in consistent state. I noticed that benchmarks using both read and write operations lead to different read timings results than in case of only running read benchmark (--skip-write options).

Here are the results that I got.

This are the results of 10 consecutive executions of read only test for different batches size, results are pretty stable:

batch-size: 100k
weigths_pah_reads_only/00/weigths_pah___100k_read_01.rs:                read: 119_991 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___100k_read_02.rs:                read: 119_923 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___100k_read_03.rs:                read: 120_301 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___100k_read_04.rs:                read: 119_977 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___100k_read_05.rs:                read: 120_256 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___100k_read_06.rs:                read: 119_823 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___100k_read_07.rs:                read: 119_630 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___100k_read_08.rs:                read: 120_147 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___100k_read_09.rs:                read: 119_909 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___100k_read_10.rs:                read: 120_060 * constants::WEIGHT_REF_TIME_PER_NANOS,

batch-size: 10k
weigths_pah_reads_only/00/weigths_pah___10k_read_01.rs:                 read: 118_578 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___10k_read_02.rs:                 read: 118_319 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___10k_read_03.rs:                 read: 118_847 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___10k_read_04.rs:                 read: 119_084 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___10k_read_05.rs:                 read: 118_966 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___10k_read_06.rs:                 read: 118_750 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___10k_read_07.rs:                 read: 118_884 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___10k_read_08.rs:                 read: 118_812 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___10k_read_09.rs:                 read: 118_392 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___10k_read_10.rs:                 read: 119_567 * constants::WEIGHT_REF_TIME_PER_NANOS,

batch-size: 1M
weigths_pah_reads_only/00/weigths_pah___1M_read_01.rs:                  read: 120_442 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___1M_read_02.rs:                  read: 120_587 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___1M_read_03.rs:                  read: 120_616 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___1M_read_04.rs:                  read: 120_668 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___1M_read_05.rs:                  read: 120_417 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___1M_read_06.rs:                  read: 120_444 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___1M_read_07.rs:                  read: 120_503 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___1M_read_08.rs:                  read: 120_412 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___1M_read_09.rs:                  read: 120_471 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_reads_only/00/weigths_pah___1M_read_10.rs:                  read: 121_295 * constants::WEIGHT_REF_TIME_PER_NANOS,

For read then write benchmark executed in loop over the same db (writes skipped for clarity), read timings are not stable any more:

weigths_pah_rw/00/weigths_pah___100k_rw_01.rs:			read: 130_946 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___100k_rw_02.rs:			read: 119_475 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___100k_rw_03.rs:			read: 134_775 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___100k_rw_04.rs:			read: 136_035 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___100k_rw_05.rs:			read: 130_444 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___100k_rw_06.rs:			read: 170_214 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___100k_rw_07.rs:			read: 130_497 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___100k_rw_08.rs:			read: 181_800 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___100k_rw_09.rs:			read: 182_406 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___100k_rw_10.rs:			read: 137_068 * constants::WEIGHT_REF_TIME_PER_NANOS,

weigths_pah_rw/00/weigths_pah___10k_rw_01.rs:			read: 77_933 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___10k_rw_02.rs:			read: 87_517 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___10k_rw_03.rs:			read: 115_153 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___10k_rw_04.rs:			read: 104_654 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___10k_rw_05.rs:			read: 105_840 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___10k_rw_06.rs:			read: 119_721 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___10k_rw_07.rs:			read: 99_925 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___10k_rw_08.rs:			read: 102_330 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___10k_rw_09.rs:			read: 114_771 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___10k_rw_10.rs:			read: 146_837 * constants::WEIGHT_REF_TIME_PER_NANOS,

weigths_pah_rw/00/weigths_pah___1M_rw_01.rs:			read: 135_741 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___1M_rw_02.rs:			read: 145_561 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___1M_rw_03.rs:			read: 110_653 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___1M_rw_04.rs:			read: 139_268 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___1M_rw_05.rs:			read: 109_138 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___1M_rw_06.rs:			read: 155_584 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___1M_rw_07.rs:			read: 120_767 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___1M_rw_08.rs:			read: 123_224 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___1M_rw_09.rs:			read: 176_991 * constants::WEIGHT_REF_TIME_PER_NANOS,
weigths_pah_rw/00/weigths_pah___1M_rw_10.rs:			read: 136_337 * constants::WEIGHT_REF_TIME_PER_NANOS,

paritytech/parity-common#949 and #10242 don't help, read numbers are still not stable for read/write benchmarking.

Script for reference
#!/bin/bash -x

export BIN=./polkadot-parachain
export CHAIN="--base-path ./grab-db/pah/"
export COMMON="--state-version 1 --skip-write"
export DIR=weigths_pah_reads_only/00

for i in `seq 1 10`; do
  WEIGTH_FILE=$DIR/`printf "weigths_pah___10k_read_%02d.rs" $i`
  RUST_LOG=info $BIN benchmark storage $CHAIN $COMMON --weight-path $WEIGTH_FILE --batch-size 10000
done

for i in `seq 1 10`; do
  WEIGTH_FILE=$DIR/`printf "weigths_pah___1M_read_%02d.rs" $i`
  RUST_LOG=info $BIN benchmark storage $CHAIN $COMMON --weight-path $WEIGTH_FILE --batch-size 1000000
done

for i in `seq 1 10`; do
  WEIGTH_FILE=$DIR/`printf "weigths_pah___100k_read_%02d.rs" $i`
  RUST_LOG=info $BIN benchmark storage $CHAIN $COMMON --weight-path $WEIGTH_FILE --batch-size 100000
done

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions