From eedb0d0aa34000af448d92d59f634df4d203f378 Mon Sep 17 00:00:00 2001 From: Evelina Dumitrescu Date: Fri, 26 Aug 2016 23:42:55 -0700 Subject: user activity: Normalize the pathname from pprof and CWP data. I noticed that lots of files have .. symbols in the pathname. BUG=None TEST=None Change-Id: I7dbdc84b36b9496f2d8fa21ec4fafe0f1417f256 Reviewed-on: https://chrome-internal-review.googlesource.com/282197 Tested-by: Evelina Dumitrescu Commit-Queue: Evelina Dumitrescu Reviewed-by: George Burgess Reviewed-by: Ting-Yuan Huang Reviewed-on: https://chromium-review.googlesource.com/435905 Commit-Ready: Luis Lozano Tested-by: Luis Lozano Reviewed-by: Luis Lozano --- user_activity_benchmarks/process_hot_functions.py | 29 ++++++++++++++-------- .../testdata/input/parse_cwp_statistics.csv | 8 +++--- .../testdata/input/pprof/file2.pprof | 2 +- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/user_activity_benchmarks/process_hot_functions.py b/user_activity_benchmarks/process_hot_functions.py index 3c7d65df..f021e8c7 100755 --- a/user_activity_benchmarks/process_hot_functions.py +++ b/user_activity_benchmarks/process_hot_functions.py @@ -110,7 +110,7 @@ class HotFunctionsProcessor(object): for statistic in statistics_reader: function_name = statistic['function'] - file_name = statistic['file'] + file_name = os.path.normpath(statistic['file']) dso_name = statistic['dso'] inclusive_count = statistic['inclusive_count'] @@ -153,7 +153,10 @@ class HotFunctionsProcessor(object): pprof_files = os.listdir(pprof_path) cwp_statistics = self.ParseCWPStatistics(cwp_functions_file) function_statistic_regex = re.compile(r'\S+\s+\S+%\s+\S+%\s+\S+\s+\S+%') - function_regex = re.compile(r'[a-zA-Z0-9-/_:.~\[\]]+[ a-zA-Z0-9-/_~:.]*') + function_regex = re.compile(r'[a-zA-Z0-9-_:.~\[\]]+') + # TODO(evelinad): Consider the case where the file name can have other + # characters. + file_regex = re.compile(r'[a-zA-Z0-9-/_.]+') for pprof_file in pprof_files: # In the pprof output, the statistics of the functions start from the @@ -168,15 +171,21 @@ class HotFunctionsProcessor(object): function_statistic_regex.search(pprof_statistic) function_statistic = \ ','.join(function_statistic_match.group(0).split()) - function_match = function_regex.search(pprof_statistic[ - function_statistic_match.end():]) - function = ','.join(function_match.group(0).split()) - - if function in cwp_statistics: - cwp_statistic = cwp_statistics[function] - output_lines.append(','.join([function, cwp_statistic[0], + lookup_index = function_statistic_match.end() + function_match = function_regex.search(pprof_statistic[lookup_index:]) + function_name = function_match.group(0) + lookup_index += function_match.end() + file_match = file_regex.search(pprof_statistic[lookup_index:]) + if file_match: + key = ",".join([function_name, os.path.normpath(file_match.group(0))]) + else: + key = function_name + + if key in cwp_statistics: + cwp_statistic = cwp_statistics[key] + output_lines.append(','.join([key, cwp_statistic[0], function_statistic])) - cwp_statistics[function] = (cwp_statistic[0], self.COMMON_FUNCTION) + cwp_statistics[key] = (cwp_statistic[0], self.COMMON_FUNCTION) with open(os.path.join(common_functions_path, pprof_file), 'w') \ as output_file: diff --git a/user_activity_benchmarks/testdata/input/parse_cwp_statistics.csv b/user_activity_benchmarks/testdata/input/parse_cwp_statistics.csv index 833beeed..a4c7ced9 100644 --- a/user_activity_benchmarks/testdata/input/parse_cwp_statistics.csv +++ b/user_activity_benchmarks/testdata/input/parse_cwp_statistics.csv @@ -1,6 +1,6 @@ function,file,dso,inclusive_count -dummy_method1,dummy_file1,dummy_object1,1 -dummy_method2,dummy_file2,dummy_object2,2 +dummy_method1,dummy_file1/a/b/../../,dummy_object1,1 +dummy_method2,dummy_file2//,dummy_object2,2 ,,321223321,1 -dummy_method3,dummy_file3,dummy_object3,3 -dummy_method4,dummy_file4,dummy_object4,4 +dummy_method3,dummy_file3/a/../,dummy_object3,3 +dummy_method4,dummy_file4/./,dummy_object4,4 diff --git a/user_activity_benchmarks/testdata/input/pprof/file2.pprof b/user_activity_benchmarks/testdata/input/pprof/file2.pprof index c1e6331d..6d22bff3 100644 --- a/user_activity_benchmarks/testdata/input/pprof/file2.pprof +++ b/user_activity_benchmarks/testdata/input/pprof/file2.pprof @@ -4,7 +4,7 @@ Type: instructions_event Showing nodes accounting for 48939666671, 42.14% of 116136877744 total Dropped 35196 nodes (cum <= 580684388) flat flat% sum% cum cum% - 4585860529 3.95% 3.95% 13583834527 11.70% blink::InvalidationSet::invalidatesElement /home/chrome-bot/chrome_root/src/third_party/WebKit/Source/core/css/invalidation/InvalidationSet.cpp + 4585860529 3.95% 3.95% 13583834527 11.70% blink::InvalidationSet::invalidatesElement /home/chrome-bot/chrome_root/src/third_party/WebKit/Source/core/css/invalidation/a/b/../../InvalidationSet.cpp 3791928512 3.27% 7.21% 35145646088 30.26% blink::StyleInvalidator::invalidate /home/chrome-bot/chrome_root/src/third_party/WebKit/Source/core/css/invalidation/StyleInvalidator.cpp 2871318565 2.47% 9.69% 2979878602 2.57% blink::StyleInvalidator::RecursionCheckpoint::~RecursionCheckpoint /home/chrome-bot/chrome_root/src/third_party/WebKit/Source/core/css/invalidation/StyleInvalidator.h (inline) 1914657964 1.65% 11.33% 2164475253 1.86% WTF::StringImpl::lower /home/chrome-bot/chrome_root/src/third_party/WebKit/Source/wtf/text/StringImpl.cpp -- cgit v1.2.3