Changeset 92153 in webkit


Ignore:
Timestamp:
Aug 1, 2011 5:07:14 PM (13 years ago)
Author:
abarth@webkit.org
Message:

webkit-patch needs to be able to "optimize" the storage of baselines on disk
https://bugs.webkit.org/show_bug.cgi?id=65418

Reviewed by Dimitri Glazkov.

If we're not careful when rebaselining tests, we can end up with lots
of duplicate expected results files in the tree. This patch adds a
webkit-patch command that optimizes the storage of expected results on
disk.

This command is similar to deduplicate-tests, except that it can move
test results around rather than just remove duplicate results.

Unfortunately, this problem is very tricky because the baseline search
structure is a hypergraph. This patch include a huerstic optimizer
that appears to work on a bunch of examples I've tried. We'll likely
need to refine it as gain experience.

  • Scripts/webkitpy/common/system/filesystem.py:
  • Scripts/webkitpy/tool/commands/rebaseline.py:
Location:
trunk/Tools
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r92147 r92153  
     12011-08-01  Adam Barth  <abarth@webkit.org>
     2
     3        webkit-patch needs to be able to "optimize" the storage of baselines on disk
     4        https://bugs.webkit.org/show_bug.cgi?id=65418
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        If we're not careful when rebaselining tests, we can end up with lots
     9        of duplicate expected results files in the tree.  This patch adds a
     10        webkit-patch command that optimizes the storage of expected results on
     11        disk.
     12
     13        This command is similar to deduplicate-tests, except that it can move
     14        test results around rather than just remove duplicate results.
     15
     16        Unfortunately, this problem is very tricky because the baseline search
     17        structure is a hypergraph.  This patch include a huerstic optimizer
     18        that appears to work on a bunch of examples I've tried.  We'll likely
     19        need to refine it as gain experience.
     20
     21        * Scripts/webkitpy/common/system/filesystem.py:
     22        * Scripts/webkitpy/tool/commands/rebaseline.py:
     23
    1242011-08-01  Dimitri Glazkov  <dglazkov@chromium.org>
    225
  • trunk/Tools/Scripts/webkitpy/common/system/filesystem.py

    r90702 r92153  
    3535import exceptions
    3636import glob
     37import hashlib
    3738import os
    3839import shutil
     
    223224        with codecs.open(path, 'w', 'utf8') as f:
    224225            f.write(contents)
     226
     227    def sha1(self, path):
     228        contents = self.read_binary_file(path)
     229        return hashlib.sha1(contents).hexdigest()
    225230
    226231    def relpath(self, path, start='.'):
  • trunk/Tools/Scripts/webkitpy/common/system/filesystem_mock.py

    r91210 r92153  
    2828
    2929import errno
     30import hashlib
    3031import os
    3132import re
     
    285286        return self.write_binary_file(path, contents.encode('utf-8'))
    286287
     288    def sha1(self, path):
     289        contents = self.read_binary_file(path)
     290        return hashlib.sha1(contents).hexdigest()
     291
    287292    def relpath(self, path, start='.'):
    288293        return ospath.relpath(path, start, self.abspath, self.sep)
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py

    r91877 r92153  
    542542        return self.path_from_webkit_base('LayoutTests')
    543543
     544    def webkit_base(self):
     545        return self._filesystem.abspath(self.path_from_webkit_base('.'))
     546
    544547    def skipped_layout_tests(self):
    545548        return []
  • trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline.py

    r92061 r92153  
    3333
    3434import webkitpy.common.config.urls as config_urls
     35from webkitpy.common.checkout.baselineoptimizer import BaselineOptimizer
    3536from webkitpy.common.net.buildbot import BuildBot
    3637from webkitpy.common.net.layouttestresults import LayoutTestResults
    3738from webkitpy.common.system.user import User
     39from webkitpy.layout_tests.layout_package.test_result_writer import TestResultWriter
    3840from webkitpy.layout_tests.models import test_failures
    3941from webkitpy.layout_tests.port import factory
     
    129131
    130132
     133class OptimizeBaselines(AbstractDeclarativeCommand):
     134    name = "optimize-baselines"
     135    help_text = "Reshuffles the baselines for a the given test to use as litte space on disk as possible."
     136    argument_names = "TEST_NAME"
     137
     138    # FIXME: Should TestResultWriter know how to compute this string?
     139    def _baseline_name(self, test_name, suffix):
     140        return self._tool.filesystem.splitext(test_name)[0] + TestResultWriter.FILENAME_SUFFIX_EXPECTED + suffix
     141
     142    def execute(self, options, args, tool):
     143        baseline_optimizer = BaselineOptimizer(tool.scm(), tool.filesystem)
     144
     145        test_name = args[0]
     146        for suffix in ['.png', '.txt']:
     147            baseline_name = self._baseline_name(test_name, suffix)
     148            if not baseline_optimizer.optimize(baseline_name):
     149                print "Hueristics failed to optimize %s" % baseline_name
     150
     151
    131152class Rebaseline(AbstractDeclarativeCommand):
    132153    name = "rebaseline"
Note: See TracChangeset for help on using the changeset viewer.