Changeset 57399 in webkit


Ignore:
Timestamp:
Apr 9, 2010 7:17:44 PM (14 years ago)
Author:
abarth@webkit.org
Message:

2010-04-09 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Don't reinvent Executive.cpu_count for every port
https://bugs.webkit.org/show_bug.cgi?id=37377

mac.py and chromium_mac.py had some copy/paste code. This code doesn't
actually have anything to do with WebKit ports. It's really just
something in the multiprocessing package. The lame bit is that package
isn't available in older versions of Python, so we need to implement a
fallback. However, we already have the fallback in common. We don't
need to reinvent it specificly for layout_tests.

  • Scripts/webkitpy/common/system/executive.py:
  • Scripts/webkitpy/layout_tests/port/base.py:
  • Scripts/webkitpy/layout_tests/port/chromium.py:
  • Scripts/webkitpy/layout_tests/port/chromium_linux.py:
  • Scripts/webkitpy/layout_tests/port/chromium_mac.py:
  • Scripts/webkitpy/layout_tests/port/chromium_win.py:
  • Scripts/webkitpy/layout_tests/port/mac.py:
  • Scripts/webkitpy/layout_tests/port/test.py:
  • Scripts/webkitpy/layout_tests/run_webkit_tests.py:
Location:
trunk/WebKitTools
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r57398 r57399  
     12010-04-09  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Don't reinvent Executive.cpu_count for every port
     6        https://bugs.webkit.org/show_bug.cgi?id=37377
     7
     8        mac.py and chromium_mac.py had some copy/paste code.  This code doesn't
     9        actually have anything to do with WebKit ports.  It's really just
     10        something in the multiprocessing package.  The lame bit is that package
     11        isn't available in older versions of Python, so we need to implement a
     12        fallback.  However, we already have the fallback in common.  We don't
     13        need to reinvent it specificly for layout_tests.
     14
     15        * Scripts/webkitpy/common/system/executive.py:
     16        * Scripts/webkitpy/layout_tests/port/base.py:
     17        * Scripts/webkitpy/layout_tests/port/chromium.py:
     18        * Scripts/webkitpy/layout_tests/port/chromium_linux.py:
     19        * Scripts/webkitpy/layout_tests/port/chromium_mac.py:
     20        * Scripts/webkitpy/layout_tests/port/chromium_win.py:
     21        * Scripts/webkitpy/layout_tests/port/mac.py:
     22        * Scripts/webkitpy/layout_tests/port/test.py:
     23        * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
     24
    1252010-04-09  Adam Barth  <abarth@webkit.org>
    226
  • trunk/WebKitTools/Scripts/webkitpy/common/system/executive.py

    r57091 r57399  
    3535
    3636import os
     37import platform
    3738import StringIO
    3839import subprocess
     
    123124        if multiprocessing:
    124125            return multiprocessing.cpu_count()
     126        # Darn.  We don't have the multiprocessing package.
     127        system_name = platform.system()
     128        if system_name == "Dawin":
     129            return int(self.run_command(["sysctl", "-n", "hw.ncpu"]))
     130        elif system_name == "Windows":
     131            return int(os.environ.get('NUMBER_OF_PROCESSORS', 1))
     132        elif system_name == "Linux":
     133            num_cores = os.sysconf("SC_NPROCESSORS_ONLN")
     134            if isinstance(num_cores, int) and num_cores > 0:
     135                return num_cores
    125136        # This quantity is a lie but probably a reasonable guess for modern
    126137        # machines.
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/base.py

    r57398 r57399  
    286286        may be different (e.g., 'win-xp' instead of 'chromium-win-xp'."""
    287287        return self._name
    288 
    289     def num_cores(self):
    290         """Return the number of cores/cpus available on this machine.
    291 
    292         This routine is used to determine the default amount of parallelism
    293         used by run-chromium-webkit-tests."""
    294         raise NotImplementedError('Port.num_cores')
    295288
    296289    # FIXME: This could be replaced by functions in webkitpy.common.checkout.scm.
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py

    r57381 r57399  
    4545
    4646
     47# FIXME: This function doesn't belong in this package.
    4748def check_file_exists(path_to_file, file_description, override_step=None,
    4849                      logging=True):
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_linux.py

    r57256 r57399  
    7474        return result
    7575
    76     def num_cores(self):
    77         num_cores = os.sysconf("SC_NPROCESSORS_ONLN")
    78         if isinstance(num_cores, int) and num_cores > 0:
    79             return num_cores
    80         return 1
    81 
    8276    def test_platform_name(self):
    8377        # We use 'linux' instead of 'chromium-linux' in test_expectations.txt.
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_mac.py

    r57256 r57399  
    6666                       'MacBuildInstructions')
    6767        return result
    68 
    69     def num_cores(self):
    70         return int(subprocess.Popen(['sysctl','-n','hw.ncpu'],
    71                                     stdout=subprocess.PIPE).stdout.read())
    7268
    7369    def test_platform_name(self):
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_win.py

    r57256 r57399  
    7878        abspath = os.path.abspath(filename)
    7979        return abspath.replace('\\', '/')
    80 
    81     def num_cores(self):
    82         return int(os.environ.get('NUMBER_OF_PROCESSORS', 1))
    8380
    8481    def relative_test_filename(self, filename):
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/mac.py

    r57398 r57399  
    173173        return result
    174174
    175     def num_cores(self):
    176         ncores = int(executive.run_command(["sysctl", "-n", "hw.ncpu"]))
    177         # FIXME: new-run-webkit-tests is unstable running more than four
    178         # threads in parallel.
    179         # See https://bugs.webkit.org/show_bug.cgi?id=36622
    180         if ncores > 4:
    181             ncores = 4
    182         return ncores
    183 
    184175    def path_to_test_expectations_file(self):
    185176        return self.path_from_webkit_base('LayoutTests', 'platform',
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/test.py

    r55373 r57399  
    7070        return self._name
    7171
    72     def num_cores(self):
    73         return int(os.popen2("sysctl -n hw.ncpu")[1].read())
    74 
    7572    def options(self):
    7673        return self._options
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests.py

    r57381 r57399  
    5151import optparse
    5252import os
     53import platform
    5354import Queue
    5455import random
     
    7172from test_types import test_type_base
    7273from test_types import text_diff
     74
     75from webkitpy.common.system.executive import Executive
    7376
    7477import port
     
    13901393
    13911394    port_obj = port.get(options.platform, options)
     1395    executive = Executive()
    13921396
    13931397    if not options.configuration:
     
    14231427
    14241428    if not options.num_dump_render_trees:
    1425         # TODO(ojan): Investigate perf/flakiness impact of using numcores + 1.
    1426         options.num_dump_render_trees = port_obj.num_cores()
     1429        # FIXME: Investigate perf/flakiness impact of using cpu_count + 1.
     1430        options.num_dump_render_trees = executive.cpu_count()
     1431        # FIXME: new-run-webkit-tests is unstable on Mac running more than
     1432        # four threads in parallel.
     1433        # See https://bugs.webkit.org/show_bug.cgi?id=36622
     1434        if platform.system() == "Dawin" and options.num_dump_render_trees > 4:
     1435            options.num_dump_render_trees = 4
    14271436
    14281437    write = create_logging_writer(options, 'config')
     
    14621471        # all the test list parsing and ensures it's correct syntax (e.g. no
    14631472        # dupes).
    1464         for platform in port_obj.test_platform_names():
    1465             test_runner.parse_expectations(platform, is_debug_mode=True)
    1466             test_runner.parse_expectations(platform, is_debug_mode=False)
     1473        for platform_name in port_obj.test_platform_names():
     1474            test_runner.parse_expectations(platform_name, is_debug_mode=True)
     1475            test_runner.parse_expectations(platform_name, is_debug_mode=False)
    14671476        meter.update("")
    14681477        print ("If there are no fail messages, errors or exceptions, then the "
Note: See TracChangeset for help on using the changeset viewer.