WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
proposed patch
perftestsmemory.patch (text/plain), 12.01 KB, created by
Zoltan Horvath
on 2012-10-08 18:10:24 PDT
(
hide
)
Description:
proposed patch
Filename:
MIME Type:
Creator:
Zoltan Horvath
Created:
2012-10-08 18:10:24 PDT
Size:
12.01 KB
patch
obsolete
>diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index c0ebe37..e0d3c1b 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,18 @@ >+2012-10-08 Zoltan Horvath <zoltan@webkit.org> >+ >+ Pageload tests should measure memory usage >+ https://bugs.webkit.org/show_bug.cgi?id=93958 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add JS Heap and Heap memory measurement to PageLoad tests. >+ >+ * heap/HeapStatistics.cpp: >+ (JSC::HeapStatistics::usedJSHeap): Add new private function to expose the used JS Heap size. >+ (JSC): >+ * heap/HeapStatistics.h: >+ (HeapStatistics): Add new private function to expose the used JS Heap size. >+ > 2012-10-05 Mark Hahnenberg <mhahnenberg@apple.com> > > JSC should have a way to gather and log Heap memory use and pause times >diff --git a/Source/JavaScriptCore/heap/HeapStatistics.cpp b/Source/JavaScriptCore/heap/HeapStatistics.cpp >index 8340bfa..68044e0 100644 >--- a/Source/JavaScriptCore/heap/HeapStatistics.cpp >+++ b/Source/JavaScriptCore/heap/HeapStatistics.cpp >@@ -138,6 +138,12 @@ void HeapStatistics::reportSuccess() > > #endif // OS(UNIX) > >+size_t HeapStatistics::usedJSHeap() >+{ >+ JSGlobalData* globalData = &JSGlobalData::sharedInstance(); >+ return globalData->heap.size(); >+} >+ > size_t HeapStatistics::parseMemoryAmount(char* s) > { > size_t multiplier = 1; >diff --git a/Source/JavaScriptCore/heap/HeapStatistics.h b/Source/JavaScriptCore/heap/HeapStatistics.h >index 0800f0c..34d05af 100644 >--- a/Source/JavaScriptCore/heap/HeapStatistics.h >+++ b/Source/JavaScriptCore/heap/HeapStatistics.h >@@ -36,6 +36,7 @@ class HeapStatistics { > public: > NO_RETURN static void exitWithFailure(); > JS_EXPORT_PRIVATE static void reportSuccess(); >+ JS_EXPORT_PRIVATE static size_t usedJSHeap(); > > static void initialize(); > static void recordGCPauseTime(double start, double end); >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index d51db51..74c31ed 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,29 @@ >+2012-10-08 Zoltan Horvath <zoltan@webkit.org> >+ >+ Pageload tests should measure memory usage >+ https://bugs.webkit.org/show_bug.cgi?id=93958 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add JS Heap and Heap memory measurement to PageLoad tests. >+ >+ * DumpRenderTree/mac/DumpRenderTree.mm: >+ (dump): Print memory results with DRT. >+ * Scripts/old-run-webkit-tests: >+ (readFromDumpToolWithTimer): Hadle memory results. >+ * Scripts/webkitpy/layout_tests/port/driver.py: >+ (DriverOutput.__init__): Add new parameter for the results. >+ (Driver.__init__): Initialize the new parameter. >+ (Driver.run_test): >+ (Driver._read_first_block): Add support for the new headers. >+ (Driver._process_stdout_line): >+ (ContentBlock.__init__): >+ * Scripts/webkitpy/performance_tests/perftest.py: >+ (PageLoadingPerfTest.calculate_statistics): Move statistics calculation into a function. >+ (PageLoadingPerfTest.run): Handle the new memory results. >+ (PageLoadingPerfTest.run.in): >+ (PageLoadingPerfTest): >+ > 2012-10-05 Mark Hahnenberg <mhahnenberg@apple.com> > > JSC should have a way to gather and log Heap memory use and pause times >diff --git a/Tools/DumpRenderTree/mac/DumpRenderTree.mm b/Tools/DumpRenderTree/mac/DumpRenderTree.mm >index 1c01d53..f70e262 100644 >--- a/Tools/DumpRenderTree/mac/DumpRenderTree.mm >+++ b/Tools/DumpRenderTree/mac/DumpRenderTree.mm >@@ -89,6 +89,7 @@ > #import <getopt.h> > #import <objc/objc-runtime.h> > #import <wtf/Assertions.h> >+#import <wtf/FastMalloc.h> > #import <wtf/RetainPtr.h> > #import <wtf/Threading.h> > #import <wtf/ObjcRuntimeExtras.h> >@@ -1183,6 +1184,10 @@ void dump() > if (gTestRunner->dumpAsAudio()) > printf("Content-Transfer-Encoding: base64\n"); > >+ WTF::FastMallocStatistics mallocStats = WTF::fastMallocStatistics(); >+ printf("DumpMalloc: %li\n", mallocStats.committedVMBytes); >+ printf("DumpJSHeap: %li\n", JSC::HeapStatistics::usedJSHeap()); >+ > if (resultData) { > fwrite([resultData bytes], 1, [resultData length], stdout); > >diff --git a/Tools/Scripts/old-run-webkit-tests b/Tools/Scripts/old-run-webkit-tests >index c6d815a..89e4abc 100755 >--- a/Tools/Scripts/old-run-webkit-tests >+++ b/Tools/Scripts/old-run-webkit-tests >@@ -2378,6 +2378,8 @@ sub readFromDumpToolWithTimer(**) > } elsif (!$haveSeenContentTransferEncoding && $lineIn =~ /^Content-Transfer-Encoding: (\S+)$/) { > $encoding = $1; > $haveSeenContentTransferEncoding = 1; >+ } elsif ($lineIn =~ /^DumpMalloc|^DumpJSHeap: (\S+)$/) { >+ # Ignored. Only used in performance tests. > } elsif ($lineIn =~ /(.*)#EOF$/) { > if ($1 ne "") { > push @output, $1; >diff --git a/Tools/Scripts/webkitpy/layout_tests/port/driver.py b/Tools/Scripts/webkitpy/layout_tests/port/driver.py >index 4bf53d4..7993d05 100644 >--- a/Tools/Scripts/webkitpy/layout_tests/port/driver.py >+++ b/Tools/Scripts/webkitpy/layout_tests/port/driver.py >@@ -76,7 +76,7 @@ class DriverOutput(object): > strip_patterns.append((re.compile('scrolled to [0-9]+,[0-9]+'), 'scrolled')) > > def __init__(self, text, image, image_hash, audio, crash=False, >- test_time=0, timeout=False, error='', crashed_process_name='??', >+ test_time=0, measurements=None, timeout=False, error='', crashed_process_name='??', > crashed_pid=None, crash_log=None): > # FIXME: Args could be renamed to better clarify what they do. > self.text = text >@@ -89,6 +89,7 @@ class DriverOutput(object): > self.crashed_pid = crashed_pid > self.crash_log = crash_log > self.test_time = test_time >+ self.measurements = measurements > self.timeout = timeout > self.error = error # stderr output > >@@ -138,6 +139,8 @@ class Driver(object): > self.err_seen_eof = False > self._server_process = None > >+ self._measurements = {} >+ > def __del__(self): > self.stop() > >@@ -193,7 +196,7 @@ class Driver(object): > crash_log += '\nstdout:\n%s\nstderr:\n%s\n' % (text, self.error_from_test) > > return DriverOutput(text, image, actual_image_hash, audio, >- crash=crashed, test_time=time.time() - test_begin_time, >+ crash=crashed, test_time=time.time() - test_begin_time, measurements=self._measurements, > timeout=timed_out, error=self.error_from_test, > crashed_process_name=self._crashed_process_name, > crashed_pid=self._crashed_pid, crash_log=crash_log) >@@ -360,6 +363,10 @@ class Driver(object): > def _read_first_block(self, deadline): > # returns (text_content, audio_content) > block = self._read_block(deadline) >+ if block.malloc: >+ self._measurements['Malloc'] = float(block.malloc) >+ if block.js_heap: >+ self._measurements['JSHeap'] = float(block.js_heap) > if block.content_type == 'audio/wav': > return (None, block.decoded_content) > return (block.decoded_content, None) >@@ -384,7 +391,9 @@ class Driver(object): > if (self._read_header(block, line, 'Content-Type: ', 'content_type') > or self._read_header(block, line, 'Content-Transfer-Encoding: ', 'encoding') > or self._read_header(block, line, 'Content-Length: ', '_content_length', int) >- or self._read_header(block, line, 'ActualHash: ', 'content_hash')): >+ or self._read_header(block, line, 'ActualHash: ', 'content_hash') >+ or self._read_header(block, line, 'DumpMalloc: ', 'malloc') >+ or self._read_header(block, line, 'DumpJSHeap: ', 'js_heap')): > return > # Note, we're not reading ExpectedHash: here, but we could. > # If the line wasn't a header, we just append it to the content. >@@ -450,6 +459,8 @@ class ContentBlock(object): > # Content is treated as binary data even though the text output is usually UTF-8. > self.content = str() # FIXME: Should be bytearray() once we require Python 2.6. > self.decoded_content = None >+ self.malloc = None >+ self.js_heap = None > > def decode_content(self): > if self.encoding == 'base64' and self.content is not None: >diff --git a/Tools/Scripts/webkitpy/performance_tests/perftest.py b/Tools/Scripts/webkitpy/performance_tests/perftest.py >index 360fe4c..965e8ed 100644 >--- a/Tools/Scripts/webkitpy/performance_tests/perftest.py >+++ b/Tools/Scripts/webkitpy/performance_tests/perftest.py >@@ -213,8 +213,33 @@ class PageLoadingPerfTest(PerfTest): > super(PageLoadingPerfTest, self).run_single(driver, self.force_gc_test, time_out_ms, False) > return super(PageLoadingPerfTest, self).run_single(driver, path_or_url, time_out_ms, should_run_pixel_test) > >+ def calculate_statistics(self, input_list, unit): >+ sorted_input_list = sorted(input_list) >+ >+ # Compute the mean and variance using Knuth's online algorithm (has good numerical stability). >+ squareSum = 0 >+ mean = 0 >+ for i, time in enumerate(sorted_input_list): >+ delta = time - mean >+ sweep = i + 1.0 >+ mean += delta / sweep >+ squareSum += delta * (time - mean) >+ >+ middle = int(len(sorted_input_list) / 2) >+ result = {'values': input_list, >+ 'avg': mean, >+ 'min': sorted_input_list[0], >+ 'max': sorted_input_list[-1], >+ 'median': sorted_input_list[middle] if len(sorted_input_list) % 2 else (sorted_input_list[middle - 1] + sorted_input_list[middle]) / 2, >+ 'stdev': math.sqrt(squareSum / (len(sorted_input_list) - 1)), >+ 'unit': unit} >+ return result >+ > def run(self, driver, time_out_ms): >- test_times = [] >+ results = {} >+ results.setdefault(self.test_name(), []) >+ results[self.test_name() + ' unit'] = 'ms' >+ ordered_results_keys = [self.test_name()] > > for i in range(0, 20): > output = self.run_single(driver, self.path_or_url(), time_out_ms) >@@ -222,28 +247,23 @@ class PageLoadingPerfTest(PerfTest): > return None > if i == 0: > continue >- test_times.append(output.test_time * 1000) > >- sorted_test_times = sorted(test_times) >+ results[self.test_name()].append(output.test_time * 1000) > >- # Compute the mean and variance using Knuth's online algorithm (has good numerical stability). >- squareSum = 0 >- mean = 0 >- for i, time in enumerate(sorted_test_times): >- delta = time - mean >- sweep = i + 1.0 >- mean += delta / sweep >- squareSum += delta * (time - mean) >+ for result_class, result in output.measurements.items(): >+ name = self.test_name() + result_class >+ results.setdefault(name, []) >+ results[name].append(result) >+ if result_class == 'Malloc' or result_class == 'JSHeap': >+ results[name + ' unit'] = 'bytes' >+ if name not in ordered_results_keys: >+ ordered_results_keys.append(name) >+ >+ for result_class in ordered_results_keys: >+ results[result_class] = self.calculate_statistics(results[result_class], results[result_class + ' unit']) >+ del(results[result_class + ' unit']) >+ self.output_statistics(result_class, results[result_class], '') > >- middle = int(len(test_times) / 2) >- results = {'values': test_times, >- 'avg': mean, >- 'min': sorted_test_times[0], >- 'max': sorted_test_times[-1], >- 'median': sorted_test_times[middle] if len(sorted_test_times) % 2 else (sorted_test_times[middle - 1] + sorted_test_times[middle]) / 2, >- 'stdev': math.sqrt(squareSum / (len(sorted_test_times) - 1)), >- 'unit': 'ms'} >- self.output_statistics(self.test_name(), results, '') > return {self.test_name(): results} > >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
rniwa
:
review-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 93958
:
160965
|
160966
|
167662
|
167802
|
167881
|
169649