Changeset 109264 in webkit


Ignore:
Timestamp:
Feb 29, 2012 2:40:32 PM (12 years ago)
Author:
dpranke@chromium.org
Message:

nrwt: support more than two drivers in DriverProxy
https://bugs.webkit.org/show_bug.cgi?id=79736

Reviewed by Adam Barth.

Now that we can support per-test command lines for
Drivers, modify DriverProxy to keep a map of running
drivers for each needed command-line; this will allow
us to transparently maintain a pool of appropriately
configured DRTs without having to constantly start and stop
them.

Note that this potentially raises a garbage collection
problem - the number of running DRTs will grow with the
number of different sets of command line args. For now
this is no worse than the current code - if you're running
with pixel tests, you will only need one DRT per worker,
and if you aren't, you'll need two (one for text-only tests,
and one for reftests).

An alternative would be to only ever have one running driver,
and restart the driver as the command line changes, but this
might (?) slow down execution in the text-only case - we
should benchmark this because it would be simpler and possibly
allow us to eliminate DriverProxy altogether.

  • Scripts/webkitpy/layout_tests/port/driver.py:

(DriverProxy.init):
(DriverProxy):
(DriverProxy._make_driver):
(DriverProxy.run_test):
(DriverProxy.has_crashed):
(DriverProxy.stop):
(DriverProxy.cmd_line):
(DriverProxy._cmd_line_as_key):

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r109258 r109264  
     12012-02-29  Dirk Pranke  <dpranke@chromium.org>
     2
     3        nrwt: support more than two drivers in DriverProxy
     4        https://bugs.webkit.org/show_bug.cgi?id=79736
     5
     6        Reviewed by Adam Barth.
     7
     8        Now that we can support per-test command lines for
     9        Drivers, modify DriverProxy to keep a map of running
     10        drivers for each needed command-line; this will allow
     11        us to transparently maintain a pool of appropriately
     12        configured DRTs without having to constantly start and stop
     13        them.
     14
     15        Note that this potentially raises a garbage collection
     16        problem - the number of running DRTs will grow with the
     17        number of different sets of command line args. For now
     18        this is no worse than the current code - if you're running
     19        with pixel tests, you will only need one DRT per worker,
     20        and if you aren't, you'll need two (one for text-only tests,
     21        and one for reftests).
     22
     23        An alternative would be to only ever have one running driver,
     24        and restart the driver as the command line changes, but this
     25        might (?) slow down execution in the text-only case - we
     26        should benchmark this because it would be simpler and possibly
     27        allow us to eliminate DriverProxy altogether.
     28
     29        * Scripts/webkitpy/layout_tests/port/driver.py:
     30        (DriverProxy.__init__):
     31        (DriverProxy):
     32        (DriverProxy._make_driver):
     33        (DriverProxy.run_test):
     34        (DriverProxy.has_crashed):
     35        (DriverProxy.stop):
     36        (DriverProxy.cmd_line):
     37        (DriverProxy._cmd_line_as_key):
     38
    1392012-02-29  Adrienne Walker  <enne@google.com>
    240
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/driver.py

    r109242 r109264  
    173173
    174174    def __init__(self, port, worker_number, driver_instance_constructor, pixel_tests, no_timeout):
     175        self._port = port
     176        self._worker_number = worker_number
     177        self._driver_instance_constructor = driver_instance_constructor
     178        self._no_timeout = no_timeout
    175179        self._pixel_tests = pixel_tests
    176         self._driver = driver_instance_constructor(port, worker_number, pixel_tests, no_timeout)
    177         if pixel_tests:
    178             self._reftest_driver = self._driver
    179         else:
    180             self._reftest_driver = driver_instance_constructor(port, worker_number, True, no_timeout)
    181 
     180
     181        # FIXME: We shouldn't need to create a driver until we actually run a test.
     182        self._driver = self._make_driver(pixel_tests)
     183        self._running_drivers = {}
     184        self._running_drivers[self._cmd_line_as_key(pixel_tests, [])] = self._driver
     185
     186    def _make_driver(self, pixel_tests):
     187        return self._driver_instance_constructor(self._port, self._worker_number, pixel_tests, self._no_timeout)
     188
     189    # FIXME: this should be a @classmethod (or implemented on Port instead).
    182190    def is_http_test(self, test_name):
    183191        return self._driver.is_http_test(test_name)
    184192
     193    # FIXME: this should be a @classmethod (or implemented on Port instead).
    185194    def test_to_uri(self, test_name):
    186195        return self._driver.test_to_uri(test_name)
    187196
     197    # FIXME: this should be a @classmethod (or implemented on Port instead).
    188198    def uri_to_test(self, uri):
    189199        return self._driver.uri_to_test(uri)
    190200
    191201    def run_test(self, driver_input):
    192         if driver_input.is_reftest:
    193             return self._reftest_driver.run_test(driver_input)
    194         return self._driver.run_test(driver_input)
    195 
    196     def has_crashed(self):
    197         return self._driver.has_crashed() or self._reftest_driver.has_crashed()
     202        pixel_tests_needed = self._pixel_tests or driver_input.is_reftest
     203        cmd_line_key = self._cmd_line_as_key(pixel_tests_needed, [])
     204        if not cmd_line_key in self._running_drivers:
     205            self._running_drivers[cmd_line_key] = self._make_driver(pixel_tests_needed)
     206
     207        return self._running_drivers[cmd_line_key].run_test(driver_input)
    198208
    199209    def start(self):
     
    207217        self._driver.start(self._pixel_tests, [])
    208218
     219    def has_crashed(self):
     220        return any(driver.has_crashed() for driver in self._running_drivers.values())
     221
    209222    def stop(self):
    210         self._driver.stop()
    211         self._reftest_driver.stop()
    212 
    213     def cmd_line(self, pixel_tests, per_test_args):
    214         cmd_line = self._driver.cmd_line(pixel_tests, per_test_args)
    215         if self._driver != self._reftest_driver:
    216             cmd_line += ['; '] + self._reftest_driver.cmd_line(pixel_tests, per_test_args)
    217         return cmd_line
     223        for driver in self._running_drivers.values():
     224            driver.stop()
     225
     226    # FIXME: this should be a @classmethod (or implemented on Port instead).
     227    def cmd_line(self, pixel_tests=None, per_test_args=None):
     228        return self._driver.cmd_line(pixel_tests or self._pixel_tests, per_test_args or [])
     229
     230    def _cmd_line_as_key(self, pixel_tests, per_test_args):
     231        return ' '.join(self.cmd_line(pixel_tests, per_test_args))
Note: See TracChangeset for help on using the changeset viewer.