Changeset 25118 for gs2-extensions
- Timestamp:
- 2012-02-21T13:35:11+13:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs2-extensions/parallel-building/trunk/src/bin/script/batch-testing.pl
r24695 r25118 15 15 16 16 # 0. Configuration 17 #my $infodb_type = 'GDBM';17 my $infodb_type = 'GDBM'; 18 18 #my $infodb_type = 'GDBMServer'; 19 19 #my $infodb_type = 'SQLite'; 20 my $infodb_type = 'TDB'; 21 my @sizes = (100); 20 #my $infodb_type = 'TDB'; 21 #my @sizes = (100); 22 #my @sizes = (500); 23 #my @sizes = (1000); 24 #my @sizes = (5000); 25 #my @sizes = (10000); 26 #my @sizes = (50000); 27 #my @sizes = (100, 500, 1000, 5000, 10000, 50000, 100000); 28 my @sizes = (500000); 29 #my @sizes = (1000000); 30 #my @sizes = (500000, 1000000); 22 31 #my @sizes = (100, 500, 1000, 5000, 10000, 50000, 100000, 500000, 1000000); 23 my @threads = (1); 24 my @batchsize = (100); 32 #my @threads = (1,9); 33 my @threads = (9); 34 #my @threads = (1,2,3,4,5,6,7,8,9,10,11,12,13); 35 #my @batchsizes = (0); # Non-parallel 36 #my @batchsizes = (100); 37 my @batchsizes = (1000); 25 38 my $test_iterations = 1; 39 #my $test_iterations = 3; 26 40 #my $test_iterations = 9; 27 41 … … 45 59 $threads_str .= '-' . $threads[(scalar(@threads) - 1)]; 46 60 } 47 my $batch_str = 'b' . $batchsize [0];48 if (scalar(@batchsize ) > 1)49 { 50 $batch_str .= '-' . $batchsize [(scalar(@batchsize) - 1)];61 my $batch_str = 'b' . $batchsizes[0]; 62 if (scalar(@batchsizes) > 1) 63 { 64 $batch_str .= '-' . $batchsizes[(scalar(@batchsizes) - 1)]; 51 65 } 52 66 my $db_name = $machine_name . '_' . $os_name . '_' . $fs_name . '_' . $infodb_type . '_' . $sizes_str . '_' . $threads_str . '_' . $batch_str . '_i' . $test_iterations . '.db'; … … 70 84 print STDOUT " * Creating database tables\n"; 71 85 # create tests table 72 execSQL($db_path, 'CREATE TABLE IF NOT EXISTS tests (walltime INTEGER DEFAULT 0, collection TEXT, type TEXT, t estrun INTEGER, realtime REAL DEFAULT 0, systime REAL DEFAULT 0, usertime REAL DEFAULT 0, PRIMARY KEY (collection, type, testrun))');73 execSQL($db_path, 'CREATE TABLE IF NOT EXISTS testoutput (walltime INTEGER DEFAULT 0, collection TEXT, type TEXT, testrun INTEGER, output TEXT, PRIMARY KEY (collection, type, testrun))');86 execSQL($db_path, 'CREATE TABLE IF NOT EXISTS tests (walltime INTEGER DEFAULT 0, collection TEXT, type TEXT, threads INTEGER, batchsize INTEGER, testrun INTEGER, realtime REAL DEFAULT 0, systime REAL DEFAULT 0, usertime REAL DEFAULT 0, PRIMARY KEY (collection, type, testrun, threads, batchsize))'); 87 execSQL($db_path, 'CREATE TABLE IF NOT EXISTS testoutput (walltime INTEGER DEFAULT 0, collection TEXT, type TEXT, testrun INTEGER, threads INTEGER, batchsize INTEGER, output TEXT, PRIMARY KEY (collection, type, testrun, threads, batchsize))'); 74 88 75 89 # populate with anticpated tests … … 82 96 for (my $test_run = 1; $test_run <= $a_test_iterations; $test_run++) 83 97 { 84 my $sql = "INSERT INTO tests (collection, type, testrun) VALUES ('" . $collection . "','rm'," . $test_run . ")"; 85 print STDERR ' - sql: ' . $sql . "\n"; 86 execSQL($db_path, $sql); 87 $sql = "INSERT INTO tests (collection, type, testrun) VALUES ('" . $collection . "','import'," . $test_run . ")"; 88 print STDERR ' - sql: ' . $sql . "\n"; 89 execSQL($db_path, $sql); 90 $sql = "INSERT INTO testoutput (collection, type, testrun) VALUES ('" . $collection . "','rm'," . $test_run . ")"; 91 print STDERR ' - sql: ' . $sql . "\n"; 92 execSQL($db_path, $sql); 93 $sql = "INSERT INTO testoutput (collection, type, testrun) VALUES ('" . $collection . "','import'," . $test_run . ")"; 94 print STDERR ' - sql: ' . $sql . "\n"; 95 execSQL($db_path, $sql); 98 foreach my $threads_run (@threads) 99 { 100 foreach my $batchsize_run (@batchsizes) 101 { 102 my $sql = "INSERT INTO tests (collection, type, testrun, threads, batchsize) VALUES ('" . $collection . "','rm'," . $test_run . "," . $threads_run . "," . $batchsize_run . ")"; 103 print STDERR ' - sql: ' . $sql . "\n"; 104 execSQL($db_path, $sql); 105 $sql = "INSERT INTO tests (collection, type, testrun, threads, batchsize) VALUES ('" . $collection . "','import'," . $test_run . "," . $threads_run . "," . $batchsize_run . ")"; 106 print STDERR ' - sql: ' . $sql . "\n"; 107 execSQL($db_path, $sql); 108 $sql = "INSERT INTO testoutput (collection, type, testrun, threads, batchsize) VALUES ('" . $collection . "','rm'," . $test_run . "," . $threads_run . "," . $batchsize_run . ")"; 109 print STDERR ' - sql: ' . $sql . "\n"; 110 execSQL($db_path, $sql); 111 $sql = "INSERT INTO testoutput (collection, type, testrun, threads, batchsize) VALUES ('" . $collection . "','import'," . $test_run . "," . $threads_run . "," . $batchsize_run . ")"; 112 print STDERR ' - sql: ' . $sql . "\n"; 113 execSQL($db_path, $sql); 114 } 115 } 96 116 } 97 117 } … … 111 131 my $rtime; my $utime; my $stime; 112 132 # 4. Pick a random test (thread count and epoch) and run and time it 113 my ($counter, $collection, $test_run ) = getRecordSQL($db_path, 'SELECT _rowid_, collection, testrun FROM tests WHERE realtime=0 ORDER BY RANDOM()LIMIT 1');114 print STDOUT ' - running test import for collection=' . $collection . ', and test_run=' . $test_run . "\n";133 my ($counter, $collection, $test_run, $threads_run, $batchsize_run) = getRecordSQL($db_path, 'SELECT _rowid_, collection, testrun, threads, batchsize FROM tests WHERE realtime=0 ORDER BY _rowid_ LIMIT 1'); 134 print STDOUT ' - running test import for collection=' . $collection . ', test_run=' . $test_run . ", and threads=" . $threads_run . "\n"; 115 135 116 136 # Command one: run rm_archives.pl and record information in database … … 133 153 $stime = $1; 134 154 } 135 $result =~ s/ '//g;155 $result =~ s/['"]//g; 136 156 my $walltime = time(); 137 execSQL($db_path, 'UPDATE tests SET walltime=' . $walltime . ', realtime=' . $rtime . ', usertime=' . $utime . ', systime=' . $stime . ' WHERE collection=\'' . $collection . '\' AND type=\'rm\' AND testrun=' . $test_run );138 execSQL($db_path, 'UPDATE testoutput SET walltime=' . $walltime . ', output=\'' . $result . '\' WHERE collection=\'' . $collection . '\' AND type=\'rm\' AND testrun=' . $test_run );157 execSQL($db_path, 'UPDATE tests SET walltime=' . $walltime . ', realtime=' . $rtime . ', usertime=' . $utime . ', systime=' . $stime . ' WHERE collection=\'' . $collection . '\' AND type=\'rm\' AND testrun=' . $test_run . ' AND threads=' . $threads_run . ' AND batchsize=' . $batchsize_run); 158 execSQL($db_path, 'UPDATE testoutput SET walltime=' . $walltime . ', output=\'' . $result . '\' WHERE collection=\'' . $collection . '\' AND type=\'rm\' AND testrun=' . $test_run . ' AND threads=' . $threads_run . ' AND batchsize=' . $batchsize_run); 139 159 140 160 # Have a sleep to try and prevent any headaches caused by 'rm' influencing … … 169 189 170 190 # Command three: run import.pl and record information in database 171 $cmd = 'time -p import.pl -removeold -verbosity 0 ' . $collection . ' 2>&1'; 191 if ($batchsize_run == 0) 192 { 193 $cmd = 'time -p import.pl -removeold -verbosity 0 ' . $collection . ' 2>&1'; 194 } 195 # Very super special case: if parallel processing, but number of threads is 196 # one (i.e. non-parallel) we call import but specify a manifest file for the 197 # entire collection (otherwise the import would do a pre-scan, drastically 198 # altering the timing) 199 elsif ($threads_run == 1) 200 { 201 $cmd = 'time -p import.pl -keepold -verbosity 0 -manifest manifest.xml ' . $collection . ' 2>&1'; 202 } 203 else 204 { 205 # $cmd = 'time -p parallel_import.pl -removeold -verbosity 0 -epoch ' . $batchsize_run . ' -jobs ' . $threads_run . ' ' . $collection . ' 2>&1'; 206 $cmd = 'time -p parallel_import.pl -removeold -verbosity 42 -epoch ' . $batchsize_run . ' -jobs ' . $threads_run . ' ' . $collection . ' 2>&1'; 207 } 208 172 209 print STDOUT ' - command: ' . $cmd . "\n"; 173 $result = `$cmd`; 210 # $result = `$cmd`; 211 open(CMDINPUT, $cmd . ' |') or die("Failed to execute command: " . $cmd); 212 my $line = ''; 213 my $line_counter = 0; 214 while (defined($line = <CMDINPUT>)) 215 { 216 chomp($line); 217 print STDOUT "[" . $line_counter . "] " . $line . "\n"; 218 $line_counter++; 219 } 220 close(CMDINPUT); 221 174 222 $rtime = 0; 175 223 if ($result =~ /real\s+(\d+\.\d+)/) … … 187 235 $stime = $1; 188 236 } 189 $result =~ s/ '//g;237 $result =~ s/['"]//g; 190 238 $walltime = time(); 191 execSQL($db_path, 'UPDATE tests SET walltime=' . $walltime . ', realtime=' . $rtime . ', usertime=' . $utime . ', systime=' . $stime . ' WHERE collection=\'' . $collection . '\' AND type=\'import\' AND testrun=' . $test_run );192 execSQL($db_path, 'UPDATE testoutput SET walltime=' . $walltime . ', output=\'' . $result . '\' WHERE collection=\'' . $collection . '\' AND type=\'import\' AND testrun=' . $test_run );239 execSQL($db_path, 'UPDATE tests SET walltime=' . $walltime . ', realtime=' . $rtime . ', usertime=' . $utime . ', systime=' . $stime . ' WHERE collection=\'' . $collection . '\' AND type=\'import\' AND testrun=' . $test_run . ' AND threads=' . $threads_run . ' AND batchsize=' . $batchsize_run); 240 execSQL($db_path, 'UPDATE testoutput SET walltime=' . $walltime . ', output=\'' . $result . '\' WHERE collection=\'' . $collection . '\' AND type=\'import\' AND testrun=' . $test_run . ' AND threads=' . $threads_run . ' AND batchsize=' . $batchsize_run); 193 241 194 242 # Repeat until we have exhausted pending tests … … 235 283 if ($result =~ /Error:/) 236 284 { 237 die( $result);285 die("Fatal Error!\nSQL:" . $sql . "\nMsg:" . $result); 238 286 } 239 287 # trim
Note:
See TracChangeset
for help on using the changeset viewer.