예제 #1
0
    def testClusterOffsets(self):
        processor = TestSymbolOffsetProcessor([
            SimpleTestSymbol('linker_script_start_of_text', 0, 0),
            SimpleTestSymbol('1', 1000, 999),
            SimpleTestSymbol('2', 2000, 999),
            SimpleTestSymbol('3', 3000, 999),
            SimpleTestSymbol('4', 4000, 16),
            SimpleTestSymbol('5', 5000, 16),
            SimpleTestSymbol('6', 6000, 999),
            SimpleTestSymbol('7', 7000, 16),
            SimpleTestSymbol('8', 8000, 999),
            SimpleTestSymbol('9', 9000, 16),
        ])
        mgr = TestProfileManager({
            ProfileFile(40, 0, ''): [1000, 2000, 3000],
            ProfileFile(50, 1, ''): [3000, 4000, 5000],
            ProfileFile(51, 0, 'renderer'): [2000, 3000, 6000],
            ProfileFile(51, 1, 'gpu-process'): [6000, 7000],
            ProfileFile(70, 0, ''): [1000, 2000, 6000, 8000, 9000],
            ProfileFile(70, 1, ''): [9000, 5000, 3000]
        })
        syms = cluster.ClusterOffsets(mgr, processor, limit_cluster_size=False)
        self.assertListEqual(list('236148957'), syms)

        syms = cluster.ClusterOffsets(mgr, processor, limit_cluster_size=True)
        self.assertListEqual(list('236489517'), syms)
예제 #2
0
    def _ProcessPhasedOrderfile(self, files):
        """Process the phased orderfiles produced by system health benchmarks.

    The offsets will be placed in _GetUnpatchedOrderfileFilename().

    Args:
      file: Profile files pulled locally.
    """
        self._step_recorder.BeginStep('Process Phased Orderfile')
        profiles = process_profiles.ProfileManager(files)
        processor = process_profiles.SymbolOffsetProcessor(
            self._compiler.lib_chrome_so)
        ordered_symbols = cluster.ClusterOffsets(profiles, processor)
        if not ordered_symbols:
            raise Exception('Failed to get ordered symbols')
        self._output_data['offsets_kib'] = processor.SymbolsSize(
            ordered_symbols) / 1024
        with open(self._GetUnpatchedOrderfileFilename(), 'w') as orderfile:
            orderfile.write('\n'.join(ordered_symbols))
    def _ProcessPhasedOrderfile(self, files):
        """Process the phased orderfiles produced by system health benchmarks.

    The offsets will be placed in _GetUnpatchedOrderfileFilename().

    Args:
      file: Profile files pulled locally.
    """
        self._step_recorder.BeginStep('Process Phased Orderfile')
        profiles = process_profiles.ProfileManager(files)
        processor = process_profiles.SymbolOffsetProcessor(
            self._compiler.lib_chrome_so)
        ordered_symbols = cluster.ClusterOffsets(profiles, processor)
        if not ordered_symbols:
            raise Exception('Failed to get ordered symbols')
        for sym in ordered_symbols:
            assert not sym.startswith('OUTLINED_FUNCTION_'), (
                'Outlined function found in instrumented function, very likely '
                'something has gone very wrong!')
        self._output_data['offsets_kib'] = processor.SymbolsSize(
            ordered_symbols) / 1024
        with open(self._GetUnpatchedOrderfileFilename(), 'w') as orderfile:
            orderfile.write('\n'.join(ordered_symbols))
예제 #4
0
    def testClusterOffsetsFromCallGraph(self):
        process1 = ('{"call_graph": [ {'
                    '"callee_offset": "1000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "0",'
                    '"count": "2"'
                    '} ],'
                    '"index": "61496"'
                    '}, {'
                    '"callee_offset": "7000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "1000",'
                    '"count": "2"'
                    '}, {'
                    '"caller_offset": "7500",'
                    '"count": "100"'
                    '} ],'
                    '"index": "61500"'
                    '}, {'
                    '"callee_offset": "6000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "1000",'
                    '"count": "4"'
                    '}, {'
                    '"caller_offset": "7000",'
                    '"count": "3"'
                    '}, {'
                    '"caller_offset": "7500",'
                    '"count": "2"'
                    '}, {'
                    '"caller_offset": "0",'
                    '"count": "3"'
                    '} ],'
                    '"index": "47860"'
                    '}, {'
                    '"callee_offset": "3000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "6000",'
                    '"count": "11"'
                    '} ],'
                    '"index": "47900"'
                    '} ],'
                    '"total_calls_count": "127"'
                    '}')

        process2 = ('{"call_graph": [ {'
                    '"callee_offset": "1000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "0",'
                    '"count": "2"'
                    '} ],'
                    '"index": "61496"'
                    '}, {'
                    '"callee_offset": "5000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "1000",'
                    '"count": "20"'
                    '}, {'
                    '"caller_offset": "5000",'
                    '"count": "100"'
                    '}, {'
                    '"caller_offset": "3000",'
                    '"count": "40"'
                    '} ],'
                    '"index": "61500"'
                    '}, {'
                    '"callee_offset": "3000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "5000",'
                    '"count": "10"'
                    '}, {'
                    '"caller_offset": "0",'
                    '"count": "10"'
                    '} ],'
                    '"index": "47860"'
                    '} ],'
                    '"total_calls_count": "182"'
                    '}')

        process3 = ('{"call_graph": [ {'
                    '"callee_offset": "8000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "0",'
                    '"count": "5"'
                    '} ],'
                    '"index": "61496"'
                    '}, {'
                    '"callee_offset": "2000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "8000",'
                    '"count": "100"'
                    '} ],'
                    '"index": "61500"'
                    '}, {'
                    '"callee_offset": "4000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "8000",'
                    '"count": "20"'
                    '} ],'
                    '"index": "61504"'
                    '}, {'
                    '"callee_offset": "9000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "8000",'
                    '"count": "50"'
                    '} ],'
                    '"index": "61512"'
                    '}, {'
                    '"callee_offset": "7000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "2000",'
                    '"count": "15"'
                    '}, {'
                    '"caller_offset": "4000",'
                    '"count": "20"'
                    '}, {'
                    '"caller_offset": "9000",'
                    '"count": "80"'
                    '}, {'
                    '"caller_offset": "0",'
                    '"count": "400"'
                    '} ],'
                    '"index": "61516"'
                    '} ],'
                    '"total_calls_count": "690"'
                    '}')

        process4 = ('{"call_graph": [ {'
                    '"callee_offset": "8000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "0",'
                    '"count": "10"'
                    '} ],'
                    '"index": "61496"'
                    '}, {'
                    '"callee_offset": "2000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "8000",'
                    '"count": "100"'
                    '} ],'
                    '"index": "61500"'
                    '}, {'
                    '"callee_offset": "6000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "7000",'
                    '"count": "10"'
                    '} , {'
                    '"caller_offset": "7500",'
                    '"count": "2"'
                    '} ],'
                    '"index": "61504"'
                    '}, {'
                    '"callee_offset": "7000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "8000",'
                    '"count": "300"'
                    '}, {'
                    '"caller_offset": "7500",'
                    '"count": "100"'
                    '}, {'
                    '"caller_offset": "2000",'
                    '"count": "15"'
                    '}, {'
                    '"caller_offset": "0",'
                    '"count": "50"'
                    '} ],'
                    '"index": "61516"'
                    '} ],'
                    '"total_calls_count": "587"'
                    '}')

        processor = TestSymbolOffsetProcessor([
            SimpleTestSymbol('linker_script_start_of_text', 0, 0),
            SimpleTestSymbol('1', 1000, 999),
            SimpleTestSymbol('2', 2000, 999),
            SimpleTestSymbol('3', 3000, 999),
            SimpleTestSymbol('4', 4000, 16),
            SimpleTestSymbol('5', 5000, 16),
            SimpleTestSymbol('6', 6000, 999),
            SimpleTestSymbol('7', 7000, 16),
            SimpleTestSymbol('8', 7100, 0),  # whitelist
            SimpleTestSymbol('9', 8000, 999),
            SimpleTestSymbol('10', 9000, 16)
        ])
        mgr = TestProfileManager({
            ProfileFile(40, 0, 'renderer'):
            json.loads(process1),
            ProfileFile(50, 1, 'renderer'):
            json.loads(process2),
            ProfileFile(51, 0, 'browser'):
            json.loads(process3),
            ProfileFile(51, 1, 'gpu-process'):
            json.loads(process4)
        })
        syms = cluster.ClusterOffsets(mgr,
                                      processor,
                                      limit_cluster_size=False,
                                      call_graph=True)
        self.assertListEqual(['7', '6', '1', '5', '3', '9', '2', '10', '4'],
                             syms)