From 6e0ec6bb965a85cb24c452dd43a34718ce2013a7 Mon Sep 17 00:00:00 2001 From: Stephen Bates Date: Tue, 10 Feb 2015 09:54:03 -0700 Subject: [PATCH] Added a latency capture tool Added a simple shell script that calls nvme read or nme write a number of times and captures latency information for post-processing. Later we will run this over random LBAs on the drive and probably move to a tools sub-folder. --- latency | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100755 latency diff --git a/latency b/latency new file mode 100755 index 00000000..17835de8 --- /dev/null +++ b/latency @@ -0,0 +1,96 @@ +#!/bin/bash +# +# Copyright 2015 PMC-Sierra, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you +# may not use this file except in compliance with the License. You may +# obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 Unless required by +# applicable law or agreed to in writing, software distributed under the +# License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the +# License. +# +# +# Author: Stephen Bates +# +# Description: +# A shell script that calls the NVMe CLI multiple times to gather +# latency data. Consider this a poor man's iometer or fio for QD=1 +# analysis. Of course this is below the file-system and block +# layer so is a best case measurement. +# + +DEVICE= +WRITE=false +COUNT=10 +DATA_SIZE=4096 +METADATA_SIZE=64 + +RAND_BASE=temp.rand +RAND_WFILE=${RAND_BASE}.write +RAND_RFILE=${RAND_BASE}.read +OUTPUT=latency.dat + +green=$(tput bold)$(tput setaf 2) +red=$(tput bold)$(tput setaf 1) +rst=$(tput sgr0) + +while getopts ":d:n:w" opt; do + case $opt in + d) + DEVICE=${OPTARG} + ;; + n) + COUNT=${OPTARG} + ;; + w) + echo "WARNING: Write mode enabled, this might trash your drive!" + WRITE=true + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + :) + echo "Option -$OPTARG requires an argument." >&2 + exit 1 + ;; + esac +done + +if [ -z "$DEVICE" ]; then + echo "regress: You must specify a NVMe device using -d" + exit 1 +fi + +function run_test { + $* | grep -i latency >> ${OUTPUT} 2>&1 + if (( $? )); then + echo ${red}"FAILED!"${rst} + echo "Failed running command: " + echo " $*" + exit 1 + fi +} + +rm ${OUTPUT} > /dev/null || exit -1 +make clean > /dev/null || exit -1 +make install > /dev/null || exit -1 + +for i in `seq 1 ${COUNT}`; +do + if $WRITE ; then + run_test dd if=/dev/urandom of=${RAND_WFILE} bs=${DATA_SIZE} count=1 + run_test nvme write ${DEVICE} --start-block=0 --block-count=0 \ + --metadata-size=${METADATA_SIZE} --data-size=${DATA_SIZE} \ + --data ${RAND_WFILE} --latency + rm ${RAND_WFILE} > /dev/null + else + run_test nvme read ${DEVICE} --start-block=0 --block-count=0 \ + --metadata-size=${METADATA_SIZE} --data-size=${DATA_SIZE} \ + --data ${RAND_RFILE} --latency + rm ${RAND_RFILE} > /dev/null + fi +done -- 2.50.1