Changeset 25118


Ignore:
Timestamp:
02/21/12 13:35:11 (9 years ago)
Author:
jmt12
Message:

Significant changes to support the latest round of batch tests (for instance allowing varying number of threads)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs2-extensions/parallel-building/trunk/src/bin/script/batch-testing.pl

    r24695 r25118  
    1515
    1616# 0. Configuration
    17 #my $infodb_type = 'GDBM';
     17my $infodb_type = 'GDBM';
    1818#my $infodb_type = 'GDBMServer';
    1919#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);
     28my @sizes = (500000);
     29#my @sizes = (1000000);
     30#my @sizes = (500000, 1000000);
    2231#my @sizes = (100, 500, 1000, 5000, 10000, 50000, 100000, 500000, 1000000);
    23 my @threads = (1);
    24 my @batchsize = (100);
     32#my @threads = (1,9);
     33my @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);
     37my @batchsizes = (1000);
    2538my $test_iterations = 1;
     39#my $test_iterations = 3;
    2640#my $test_iterations = 9;
    2741
     
    4559  $threads_str .= '-' . $threads[(scalar(@threads) - 1)];
    4660}
    47 my $batch_str = 'b' . $batchsize[0];
    48 if (scalar(@batchsize) > 1)
    49 {
    50   $batch_str .= '-' . $batchsize[(scalar(@batchsize) - 1)];
     61my $batch_str = 'b' . $batchsizes[0];
     62if (scalar(@batchsizes) > 1)
     63{
     64  $batch_str .= '-' . $batchsizes[(scalar(@batchsizes) - 1)];
    5165}
    5266my $db_name = $machine_name . '_' . $os_name . '_' . $fs_name . '_' . $infodb_type . '_' . $sizes_str . '_' . $threads_str . '_' . $batch_str . '_i' . $test_iterations . '.db';
     
    7084  print STDOUT " * Creating database tables\n";
    7185  # create tests table
    72   execSQL($db_path, 'CREATE TABLE IF NOT EXISTS tests (walltime INTEGER DEFAULT 0, collection TEXT, type TEXT, testrun 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))');
    7488
    7589  # populate with anticpated tests
     
    8296    for (my $test_run = 1; $test_run <= $a_test_iterations; $test_run++)
    8397    {
    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      }
    96116    }
    97117  }
     
    111131  my $rtime; my $utime; my $stime;
    112132  # 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";
    115135
    116136  # Command one: run rm_archives.pl and record information in database
     
    133153    $stime = $1;
    134154  }
    135   $result =~ s/'//g;
     155  $result =~ s/['"]//g;
    136156  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);
    139159
    140160  # Have a sleep to try and prevent any headaches caused by 'rm' influencing
     
    169189
    170190  # 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
    172209  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
    174222  $rtime = 0;
    175223  if ($result =~ /real\s+(\d+\.\d+)/)
     
    187235    $stime = $1;
    188236  }
    189   $result =~ s/'//g;
     237  $result =~ s/['"]//g;
    190238  $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);
    193241
    194242  # Repeat until we have exhausted pending tests
     
    235283  if ($result =~ /Error:/)
    236284  {
    237     die($result);
     285    die("Fatal Error!\nSQL:" . $sql . "\nMsg:" . $result);
    238286  }
    239287  # trim
Note: See TracChangeset for help on using the changeset viewer.