Title: [266272] trunk/Tools
Revision
266272
Author
[email protected]
Date
2020-08-27 20:24:23 -0700 (Thu, 27 Aug 2020)

Log Message

REGRESSION(r266221) Layout tests step hanging due to slow WaveDiff comparison
https://bugs.webkit.org/show_bug.cgi?id=215886

Reviewed by Darin Adler.

After r266221, a couple of webaudio tests generated WAV files with a
small difference in a large number of samples. This caused the
WaveDiff comparison to take too long.

While it works fine for small diffs, this ends up creating repeatedly
large strings for each concatenation, bringing the comparisons to a
halt.

Instead of relying on string concatenation, use a list to collect then
and only concat when actually retrieving the full string.

* Scripts/webkitpy/common/wavediff.py:
(WaveDiff.__init__):
(WaveDiff._diffParam):
(WaveDiff._diffSample):
(WaveDiff.diffText):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (266271 => 266272)


--- trunk/Tools/ChangeLog	2020-08-28 03:07:06 UTC (rev 266271)
+++ trunk/Tools/ChangeLog	2020-08-28 03:24:23 UTC (rev 266272)
@@ -1,3 +1,27 @@
+2020-08-27  Lauro Moura  <[email protected]>
+
+        REGRESSION(r266221) Layout tests step hanging due to slow WaveDiff comparison
+        https://bugs.webkit.org/show_bug.cgi?id=215886
+
+        Reviewed by Darin Adler.
+
+        After r266221, a couple of webaudio tests generated WAV files with a
+        small difference in a large number of samples. This caused the
+        WaveDiff comparison to take too long.
+
+        While it works fine for small diffs, this ends up creating repeatedly
+        large strings for each concatenation, bringing the comparisons to a
+        halt.
+
+        Instead of relying on string concatenation, use a list to collect then
+        and only concat when actually retrieving the full string.
+
+        * Scripts/webkitpy/common/wavediff.py:
+        (WaveDiff.__init__):
+        (WaveDiff._diffParam):
+        (WaveDiff._diffSample):
+        (WaveDiff.diffText):
+
 2020-08-27  Carlos Alberto Lopez Perez  <[email protected]>
 
         [webkitpy] repository svn version is incorrect when working on a branch

Modified: trunk/Tools/Scripts/webkitpy/common/wavediff.py (266271 => 266272)


--- trunk/Tools/Scripts/webkitpy/common/wavediff.py	2020-08-28 03:07:06 UTC (rev 266271)
+++ trunk/Tools/Scripts/webkitpy/common/wavediff.py	2020-08-28 03:24:23 UTC (rev 266272)
@@ -45,7 +45,7 @@
         params1 = waveFile1.getparams()
         params2 = waveFile2.getparams()
 
-        self._diff = ''
+        self._diff = []
 
         self._filesAreIdentical = not sum(map(self._diffParam, params1, params2, self._paramNames))
         self._filesAreIdenticalWithinTolerance = self._filesAreIdentical
@@ -72,19 +72,19 @@
         self._filesAreIdenticalWithinTolerance = not len(list(filter(lambda x: x > self._tolerance, results)))
 
         if differingSampleCount:
-            self._diff += '\n'
-            self._diff += 'Total differing samples: %d\n' % differingSampleCount
-            self._diff += 'Percentage of differing samples: %0.3f%%\n' % (100 * float(differingSampleCount) / max(frameCount1, frameCount2))
-            self._diff += 'Cumulative sample difference: %d\n' % cumulativeSampleDiff
-            self._diff += 'Average sample difference: %f\n' % (float(cumulativeSampleDiff) / differingSampleCount)
+            self._diff.append('')
+            self._diff.append('Total differing samples: %d' % differingSampleCount)
+            self._diff.append('Percentage of differing samples: %0.3f%%' % (100 * float(differingSampleCount) / max(frameCount1, frameCount2)))
+            self._diff.append('Cumulative sample difference: %d' % cumulativeSampleDiff)
+            self._diff.append('Average sample difference: %f' % (float(cumulativeSampleDiff) / differingSampleCount))
 
     def _diffParam(self, param1, param2, paramName):
         if param1 == param2:
             return False
-        self._diff += paramName + '\n'
-        self._diff += '< %s\n' % str(param1)
-        self._diff += '---\n'
-        self._diff += '> %s\n' % str(param2)
+        self._diff.append(paramName)
+        self._diff.append('< %s' % str(param1))
+        self._diff.append('---')
+        self._diff.append('> %s' % str(param2))
         return True
 
     @staticmethod
@@ -95,10 +95,10 @@
 
     def _diffSample(self, data1, data2, i):
         if (data1 != data2):
-            self._diff += 'Sample #%d\n' % i
-            self._diff += '< %d\n' % data1
-            self._diff += '---\n'
-            self._diff += '> %d\n' % data2
+            self._diff.append('Sample #%d' % i)
+            self._diff.append('< %d' % data1)
+            self._diff.append('---')
+            self._diff.append('> %d' % data2)
         return abs(data1 - data2)
 
     def filesAreIdentical(self):
@@ -108,4 +108,4 @@
         return self._filesAreIdenticalWithinTolerance
 
     def diffText(self):
-        return self._diff
+        return '\n'.join(self._diff)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to