Changeset 126374 in webkit


Ignore:
Timestamp:
Aug 22, 2012 6:08:25 PM (12 years ago)
Author:
dpranke@chromium.org
Message:

Baseline optimizer should try to optimize per-port if global optimization fails
https://bugs.webkit.org/show_bug.cgi?id=94665

Reviewed by Adam Barth.

Add a fallback strategy for optimizing baselines if the default
one fails; this one simply attempts to shift baselines up in the
tree and consolidates them if a parent and child in the fallback
path have the same result. This strategy is somewhat flawed in
that we will always put something in a parent dir even if we
"shouldn't"; for example, if chromium-mac produces a different
result from chromium-win and chromium-linux, then the new
algorithm will move the mac result into platform/chromium,
leaving chromium-mac empty. This result is still correct, but
perhaps confusing.

I haven't done much testing of this algorithm yet, so it's not
clear how many cases where this does a better job than the
default algorithm and how many it'll do a worse job.

  • Scripts/webkitpy/common/checkout/baselineoptimizer.py:

(BaselineOptimizer._find_optimal_result_placement):
(BaselineOptimizer._optimize_by_most_specific_common_directory):
(BaselineOptimizer):
(BaselineOptimizer._optimize_by_pushing_results_up):
(BaselineOptimizer._find_in_fallbackpath):

  • Scripts/webkitpy/common/checkout/baselineoptimizer_unittest.py:

(BaselineOptimizerTest.test_platform_mac_different):

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r126371 r126374  
     12012-08-22  Dirk Pranke  <dpranke@chromium.org>
     2
     3        Baseline optimizer should try to optimize per-port if global optimization fails
     4        https://bugs.webkit.org/show_bug.cgi?id=94665
     5
     6        Reviewed by Adam Barth.
     7
     8        Add a fallback strategy for optimizing baselines if the default
     9        one fails; this one simply attempts to shift baselines up in the
     10        tree and consolidates them if a parent and child in the fallback
     11        path have the same result. This strategy is somewhat flawed in
     12        that we will always put something in a parent dir even if we
     13        "shouldn't"; for example, if chromium-mac produces a different
     14        result from chromium-win and chromium-linux, then the new
     15        algorithm will move the mac result into platform/chromium,
     16        leaving chromium-mac empty. This result is still correct, but
     17        perhaps confusing.
     18
     19        I haven't done much testing of this algorithm yet, so it's not
     20        clear how many cases where this does a better job than the
     21        default algorithm and how many it'll do a worse job.
     22
     23        * Scripts/webkitpy/common/checkout/baselineoptimizer.py:
     24        (BaselineOptimizer._find_optimal_result_placement):
     25        (BaselineOptimizer._optimize_by_most_specific_common_directory):
     26        (BaselineOptimizer):
     27        (BaselineOptimizer._optimize_by_pushing_results_up):
     28        (BaselineOptimizer._find_in_fallbackpath):
     29        * Scripts/webkitpy/common/checkout/baselineoptimizer_unittest.py:
     30        (BaselineOptimizerTest.test_platform_mac_different):
     31
    1322012-08-22  Dirk Pranke  <dpranke@chromium.org>
    233
  • trunk/Tools/Scripts/webkitpy/common/checkout/baselineoptimizer.py

    r126371 r126374  
    2727# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828
     29import copy
    2930import logging
    3031
     
    126127        port_names_by_result = _invert_dictionary(results_by_port_name)
    127128
    128         results_by_directory, new_results_by_directory = self._optimize_by_most_specific_common_directory(results_by_directory, results_by_port_name, port_names_by_result)
     129        new_results_by_directory = self._optimize_by_most_specific_common_directory(results_by_directory, results_by_port_name, port_names_by_result)
    129130        if not new_results_by_directory:
    130             pass  # FIXME: Try something else.
     131            new_results_by_directory = self._optimize_by_pushing_results_up(results_by_directory, results_by_port_name, port_names_by_result)
    131132
    132133        return results_by_directory, new_results_by_directory
     
    145146
    146147            if len(new_unsatisfied_port_names_by_result.values()) >= len(unsatisfied_port_names_by_result.values()):
    147                 break  # Frowns. We do not appear to be converging.
     148                return {}  # Frowns. We do not appear to be converging.
    148149            unsatisfied_port_names_by_result = new_unsatisfied_port_names_by_result
    149150
    150         return results_by_directory, new_results_by_directory
     151        return new_results_by_directory
     152
     153    def _optimize_by_pushing_results_up(self, results_by_directory, results_by_port_name, port_names_by_result):
     154        results_by_directory = results_by_directory
     155        best_so_far = results_by_directory
     156        while True:
     157            new_results_by_directory = copy.copy(best_so_far)
     158            for port_name in self._hypergraph.keys():
     159                fallback_path = self._hypergraph[port_name]
     160                current_index, current_directory = self._find_in_fallbackpath(fallback_path, results_by_port_name[port_name], results_by_directory)
     161                current_result = results_by_port_name[port_name]
     162                for index in range(current_index + 1, len(fallback_path)):
     163                    new_directory = fallback_path[index]
     164                    if not new_directory in new_results_by_directory:
     165                        new_results_by_directory[new_directory] = current_result
     166                        if current_directory in new_results_by_directory:
     167                            del new_results_by_directory[current_directory]
     168                    elif new_results_by_directory[new_directory] == current_result:
     169                        if current_directory in new_results_by_directory:
     170                            del new_results_by_directory[current_directory]
     171                    else:
     172                        # The new_directory contains a different result, so stop trying to push results up.
     173                        break
     174
     175            if len(new_results_by_directory) >= len(best_so_far):
     176                # We've failed to improve, so give up.
     177                break
     178            best_so_far = new_results_by_directory
     179
     180        return best_so_far
     181
     182    def _find_in_fallbackpath(self, fallback_path, current_result, results_by_directory):
     183        for index, directory in enumerate(fallback_path):
     184            if directory in results_by_directory and (results_by_directory[directory] == current_result):
     185                return index, directory
     186        assert False, "result %s not found in fallback_path %s, %s" % (current_result, fallback_path, results_by_directory)
    151187
    152188    def _filtered_results_by_port_name(self, results_by_directory):
  • trunk/Tools/Scripts/webkitpy/common/checkout/baselineoptimizer_unittest.py

    r126371 r126374  
    7575        self.assertEqual(host.filesystem.read_binary_file('/mock-checkout/LayoutTests/platform/chromium/another/test-expected.txt'), 'result A')
    7676
    77     def disabled_test_platform_mac_different(self):
     77    def test_platform_mac_different(self):
    7878        self._assertOptimization({
    7979            'LayoutTests': '462d03b9c025db1b0392d7453310dbee5f9a9e74',
Note: See TracChangeset for help on using the changeset viewer.