Skip to contentSkip to conversation

block/023: performance test on queue creation & cleanup

PATCH In review Ming Lei 2 participants 3 messages Jul 4, 2018 – Jul 29, 2018 Block layer

lore
Share & tools
lore

Ming Lei

author
#0 lore raw

PATCH 1/1 block/023: performance test on queue creation & cleanup

SCSI may have lots of channels, targets or LUNs, so it may take long time for creating and cleaning up queues.

So introduce block/023 and uses null_blk to run this test on both blk-mq and legacy mode, then compare both and check the difference.

---
 tests/block/023     | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/block/023.out |   2 ++
 2 files changed, 103 insertions(+)
 create mode 100755 tests/block/023
 create mode 100755 tests/block/023.out
tests/block/023 new file +101 -0
new file mode 100755
index 000000000000..5a8f323bd42a
@@ -0,0 +1,101 @@
+#!/bin/bash
+#
+# Performance regression test on blk-mq queue creation & cleanup. Measure
+# the time for creating & cleaning up null_blk queues in both legacy and
+# blk-mq mode, then compare both & check if there is performance regression.
+#
+# Copyright (C) 2018 Ming Lei
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+. tests/block/rc
+
+DESCRIPTION="performance regression test on null_blk queue creation & cleanup"
+QUICK=1
+
+requires() {
+	_have_module null_blk
+}
+
+remove_null_blk_mod() {
+	delay=$1
+	while true; do
+		modprobe -r null_blk > /dev/null 2>&1
+		[ $? -eq 0 ] && break
+		sleep $delay
+	done
+}
+
+test_null_blk_queue_perf() {
+	QUEUE_MODE=$1
+
+	remove_null_blk_mod 1
+
+	start_time=`date +'%s'`
+	modprobe null_blk nr_devices=4096 queue_mode=$QUEUE_MODE
+	end_time=`date +'%s'`
+	create_time=`expr $end_time - $start_time + 1`
+
+	start_time=`date +'%s'`
+	remove_null_blk_mod 0.1
+	end_time=`date +'%s'`
+	cleanup_time=`expr $end_time - $start_time + 1`
+
+	echo $create_time $cleanup_time
+}
+
+check_diff() {
+	src=$1
+	dst=$2
+	msg=$3
+
+	diff=`expr $dst - $src`
+	[ $diff -le 10 ] && return
+
+	result=`echo "scale=0;($diff - $src * 0.4) / 1" | bc`
+	[ $result -ge 0 ] && echo $msg
+}
+
+check_limit() {
+	src=$1
+	dst=$2
+	msg=$3
+
+	result=`echo "scale=0;$dst - $src * 20" | bc`
+	[ $result -ge 0 ] && echo $msg
+}
+
+test() {
+	echo "Running ${TEST_NAME}"
+
+	rq_time=($(test_null_blk_queue_perf 1))
+	mq_time=($(test_null_blk_queue_perf 2))
+
+	echo ${rq_time[0]} ${mq_time[0]} >> "$FULL"
+	echo ${rq_time[1]} ${mq_time[1]} >> "$FULL"
+
+	msg="blk_mq takes too long(${mq_time[0]}s) to create queues compared with block rq(${rq_time[0]}s)"
+	check_diff ${rq_time[0]} ${mq_time[0]} "$msg"
+
+	msg="blk_mq takes too long(${mq_time[1]}s) to cleanup queues compared with block rq(${rq_time[1]}s)"
+	check_diff ${rq_time[1]} ${mq_time[1]} "$msg"
+
+	msg="block rq takes too long(${rq_time[1]}s) to cleanup queues compared with creating queues(${rq_time[0]}s)"
+	check_limit ${rq_time[0]} ${rq_time[1]} "$msg"
+
+	msg="blk_mq takes too long(${mq_time[1]}s) to cleanup queues compared with creating queues(${mq_time[0]}s)"
+	check_limit ${mq_time[0]} ${mq_time[1]} "$msg"
+
+	echo "Test complete"
+}
tests/block/023.out new file +2 -0
new file mode 100755
index 000000000000..4a11db1f10fe
@@ -0,0 +1,2 @@
+Running block/023
+Test complete
Signature · 1 line
2.9.5
#1 lore raw
Quoted 7 lines · Ming Lei

SCSI may have lots of channels, targets or LUNs, so it may take long time for creating and cleaning up queues.

So introduce block/023 and uses null_blk to run this test on both blk-mq and legacy mode, then compare both and check the difference.

Quoted 7 lines
---
 tests/block/023     | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/block/023.out |   2 ++
 2 files changed, 103 insertions(+)
 create mode 100755 tests/block/023
 create mode 100755 tests/block/023.out

Hi, Ming, is this a regression test for "blk-mq: remove synchronize_rcu() from blk_mq_del_queue_tag_set()" and "blk-mq: avoid to synchronize rcu inside blk_cleanup_queue()"?

author
#2 lore raw
Quoted 16 lines · Omar Sandoval
Quoted 7 lines · Ming Lei

SCSI may have lots of channels, targets or LUNs, so it may take long time for creating and cleaning up queues.

So introduce block/023 and uses null_blk to run this test on both blk-mq and legacy mode, then compare both and check the difference.

Quoted 7 lines
---
 tests/block/023     | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/block/023.out |   2 ++
 2 files changed, 103 insertions(+)
 create mode 100755 tests/block/023
 create mode 100755 tests/block/023.out
Quoted 3 lines

Hi, Ming, is this a regression test for "blk-mq: remove synchronize_rcu() from blk_mq_del_queue_tag_set()" and "blk-mq: avoid to synchronize rcu inside blk_cleanup_queue()"?

Yeah, it is.

It also shows that destroying queue may take much more time than creating queue, and seems no solution for this one now.

Thanks,
Ming