mbligh | a440f4a | 2008-09-09 21:30:04 +0000 | [diff] [blame] | 1 | import os, re |
mbligh | 53da18e | 2009-01-05 21:13:26 +0000 | [diff] [blame] | 2 | from autotest_lib.client.bin import test, utils |
lmr | 9aacf2b | 2010-05-04 13:56:05 +0000 | [diff] [blame] | 3 | import postprocessing |
mbligh | 548ace8 | 2006-10-19 14:36:45 +0000 | [diff] [blame] | 4 | |
mbligh | 548ace8 | 2006-10-19 14:36:45 +0000 | [diff] [blame] | 5 | |
| 6 | class iozone(test.test): |
lmr | 7f52bc9 | 2010-04-15 01:27:41 +0000 | [diff] [blame] | 7 | """ |
| 8 | This autotest module runs the IOzone filesystem benchmark. The benchmark |
| 9 | generates and measures a variety of file operations. Iozone has been ported |
| 10 | to many machines and runs under many operating systems. |
| 11 | |
| 12 | Iozone is useful for performing a broad filesystem analysis of a vendor's |
| 13 | computer platform. The benchmark tests file I/O performance for the |
| 14 | following operations: |
| 15 | |
| 16 | Read, write, re-read, re-write, read backwards, read strided, fread, fwrite, |
| 17 | random read, pread ,mmap, aio_read, aio_write |
| 18 | |
| 19 | @author: Ying Tao (yingtao@cn.ibm.com) |
| 20 | @see: http://www.iozone.org |
| 21 | """ |
| 22 | version = 3 |
mbligh | 548ace8 | 2006-10-19 14:36:45 +0000 | [diff] [blame] | 23 | |
mbligh | c5ddfd1 | 2008-08-04 17:15:00 +0000 | [diff] [blame] | 24 | def initialize(self): |
| 25 | self.job.require_gcc() |
| 26 | |
| 27 | |
lmr | 7f52bc9 | 2010-04-15 01:27:41 +0000 | [diff] [blame] | 28 | def setup(self, tarball='iozone3_347.tar'): |
| 29 | """ |
| 30 | Builds the given version of IOzone from a tarball. |
| 31 | @param tarball: Tarball with IOzone |
| 32 | @see: http://www.iozone.org/src/current/iozone3_347.tar |
| 33 | """ |
mbligh | 8b35285 | 2008-06-07 01:07:08 +0000 | [diff] [blame] | 34 | tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) |
mbligh | 53da18e | 2009-01-05 21:13:26 +0000 | [diff] [blame] | 35 | utils.extract_tarball_to_dir(tarball, self.srcdir) |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 36 | os.chdir(os.path.join(self.srcdir, 'src/current')) |
mbligh | 548ace8 | 2006-10-19 14:36:45 +0000 | [diff] [blame] | 37 | |
mbligh | 53da18e | 2009-01-05 21:13:26 +0000 | [diff] [blame] | 38 | arch = utils.get_current_kernel_arch() |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 39 | if (arch == 'ppc'): |
Eric Li | 6f27d4f | 2010-09-29 10:55:17 -0700 | [diff] [blame] | 40 | utils.make('linux-powerpc') |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 41 | elif (arch == 'ppc64'): |
Eric Li | 6f27d4f | 2010-09-29 10:55:17 -0700 | [diff] [blame] | 42 | utils.make('linux-powerpc64') |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 43 | elif (arch == 'x86_64'): |
Eric Li | 6f27d4f | 2010-09-29 10:55:17 -0700 | [diff] [blame] | 44 | utils.make('linux-AMD64') |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 45 | else: |
Eric Li | 6f27d4f | 2010-09-29 10:55:17 -0700 | [diff] [blame] | 46 | utils.make('linux') |
mbligh | 548ace8 | 2006-10-19 14:36:45 +0000 | [diff] [blame] | 47 | |
mbligh | 1f33761 | 2007-09-30 01:19:47 +0000 | [diff] [blame] | 48 | |
mbligh | a440f4a | 2008-09-09 21:30:04 +0000 | [diff] [blame] | 49 | def run_once(self, dir=None, args=None): |
lmr | 7f52bc9 | 2010-04-15 01:27:41 +0000 | [diff] [blame] | 50 | """ |
| 51 | Runs IOzone with appropriate parameters, record raw results in a per |
| 52 | iteration raw output file as well as in the results attribute |
| 53 | |
| 54 | @param dir: IOzone file generation dir. |
| 55 | @param args: Arguments to the iozone program. |
| 56 | """ |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 57 | if not dir: |
| 58 | dir = self.tmpdir |
| 59 | os.chdir(dir) |
| 60 | if not args: |
| 61 | args = '-a' |
mbligh | a440f4a | 2008-09-09 21:30:04 +0000 | [diff] [blame] | 62 | |
mbligh | 9b21efc | 2008-10-22 21:47:14 +0000 | [diff] [blame] | 63 | cmd = os.path.join(self.srcdir, 'src', 'current', 'iozone') |
mbligh | 34b297b | 2009-02-03 17:49:48 +0000 | [diff] [blame] | 64 | self.results = utils.system_output('%s %s' % (cmd, args)) |
| 65 | self.auto_mode = ("-a" in args) |
mbligh | 6303ed6 | 2007-07-19 16:19:16 +0000 | [diff] [blame] | 66 | |
lmr | 9aacf2b | 2010-05-04 13:56:05 +0000 | [diff] [blame] | 67 | self.results_path = os.path.join(self.resultsdir, |
| 68 | 'raw_output_%s' % self.iteration) |
| 69 | self.analysisdir = os.path.join(self.resultsdir, |
| 70 | 'analysis_%s' % self.iteration) |
| 71 | |
| 72 | utils.open_write_close(self.results_path, self.results) |
lmr | 7f52bc9 | 2010-04-15 01:27:41 +0000 | [diff] [blame] | 73 | |
mbligh | 6303ed6 | 2007-07-19 16:19:16 +0000 | [diff] [blame] | 74 | |
mbligh | 8110e11 | 2009-01-13 21:42:09 +0000 | [diff] [blame] | 75 | def __get_section_name(self, desc): |
mbligh | a440f4a | 2008-09-09 21:30:04 +0000 | [diff] [blame] | 76 | return desc.strip().replace(' ', '_') |
| 77 | |
| 78 | |
lmr | 9aacf2b | 2010-05-04 13:56:05 +0000 | [diff] [blame] | 79 | def generate_keyval(self): |
mbligh | a440f4a | 2008-09-09 21:30:04 +0000 | [diff] [blame] | 80 | keylist = {} |
| 81 | |
mbligh | 34b297b | 2009-02-03 17:49:48 +0000 | [diff] [blame] | 82 | if self.auto_mode: |
mbligh | a440f4a | 2008-09-09 21:30:04 +0000 | [diff] [blame] | 83 | labels = ('write', 'rewrite', 'read', 'reread', 'randread', |
| 84 | 'randwrite', 'bkwdread', 'recordrewrite', |
| 85 | 'strideread', 'fwrite', 'frewrite', 'fread', 'freread') |
mbligh | 34b297b | 2009-02-03 17:49:48 +0000 | [diff] [blame] | 86 | for line in self.results.splitlines(): |
mbligh | a440f4a | 2008-09-09 21:30:04 +0000 | [diff] [blame] | 87 | fields = line.split() |
| 88 | if len(fields) != 15: |
| 89 | continue |
| 90 | try: |
| 91 | fields = tuple([int(i) for i in fields]) |
| 92 | except ValueError: |
| 93 | continue |
| 94 | for l, v in zip(labels, fields[2:]): |
| 95 | key_name = "%d-%d-%s" % (fields[0], fields[1], l) |
| 96 | keylist[key_name] = v |
| 97 | else: |
| 98 | child_regexp = re.compile('Children see throughput for[\s]+' |
mbligh | c9bde78 | 2009-02-06 22:44:31 +0000 | [diff] [blame] | 99 | '([\d]+)\s+([-\w]+[-\w\s]*)\=[\s]+([\d\.]*) KB/sec') |
mbligh | a440f4a | 2008-09-09 21:30:04 +0000 | [diff] [blame] | 100 | parent_regexp = re.compile('Parent sees throughput for[\s]+' |
mbligh | c9bde78 | 2009-02-06 22:44:31 +0000 | [diff] [blame] | 101 | '([\d]+)\s+([-\w]+[-\w\s]*)\=[\s]+([\d\.]*) KB/sec') |
mbligh | a440f4a | 2008-09-09 21:30:04 +0000 | [diff] [blame] | 102 | |
| 103 | KBsec_regexp = re.compile('\=[\s]+([\d\.]*) KB/sec') |
| 104 | KBval_regexp = re.compile('\=[\s]+([\d\.]*) KB') |
| 105 | |
| 106 | section = None |
| 107 | w_count = 0 |
| 108 | |
mbligh | 34b297b | 2009-02-03 17:49:48 +0000 | [diff] [blame] | 109 | for line in self.results.splitlines(): |
mbligh | a440f4a | 2008-09-09 21:30:04 +0000 | [diff] [blame] | 110 | line = line.strip() |
| 111 | |
| 112 | # Check for the beginning of a new result section |
| 113 | match = child_regexp.search(line) |
| 114 | if match: |
| 115 | # Extract the section name and the worker count |
| 116 | w_count = int(match.group(1)) |
| 117 | section = self.__get_section_name(match.group(2)) |
| 118 | |
| 119 | # Output the appropriate keyval pair |
| 120 | key_name = '%s-%d-kids' % (section, w_count) |
| 121 | keylist[key_name] = match.group(3) |
| 122 | continue |
| 123 | |
| 124 | # Check for any other interesting lines |
| 125 | if '=' in line: |
| 126 | # Is it something we recognize? First check for parent. |
| 127 | match = parent_regexp.search(line) |
| 128 | if match: |
| 129 | # The section name and the worker count better match |
| 130 | p_count = int(match.group(1)) |
| 131 | p_secnt = self.__get_section_name(match.group(2)) |
| 132 | if p_secnt != section or p_count != w_count: |
| 133 | continue |
| 134 | |
| 135 | # Set the base name for the keyval |
| 136 | basekey = 'parent' |
| 137 | else: |
| 138 | # Check for the various 'throughput' values |
| 139 | if line[3:26] == ' throughput per thread ': |
| 140 | basekey = line[0:3] |
| 141 | match_x = KBsec_regexp |
| 142 | else: |
| 143 | # The only other thing we expect is 'Min xfer' |
| 144 | if not line.startswith('Min xfer '): |
| 145 | continue |
| 146 | basekey = 'MinXfer' |
| 147 | match_x = KBval_regexp |
| 148 | |
| 149 | match = match_x.search(line) |
| 150 | if match: |
| 151 | result = match.group(1) |
| 152 | key_name = "%s-%d-%s" % (section, w_count, basekey) |
| 153 | keylist[key_name] = result |
| 154 | |
| 155 | self.write_perf_keyval(keylist) |
lmr | 9aacf2b | 2010-05-04 13:56:05 +0000 | [diff] [blame] | 156 | |
| 157 | |
| 158 | def postprocess_iteration(self): |
| 159 | self.generate_keyval() |
| 160 | if self.auto_mode: |
| 161 | a = postprocessing.IOzoneAnalyzer(list_files=[self.results_path], |
| 162 | output_dir=self.analysisdir) |
| 163 | a.analyze() |
| 164 | p = postprocessing.IOzonePlotter(results_file=self.results_path, |
| 165 | output_dir=self.analysisdir) |
| 166 | p.plot_all() |