Loading startop/scripts/app_startup/lib/adb_utils.py +2 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,8 @@ def logcat_save_timestamp() -> str: def vm_drop_cache(): """Free pagecache and slab object.""" cmd_utils.run_adb_shell_command('echo 3 > /proc/sys/vm/drop_caches') # Sleep a little bit to provide enougth time for cache cleanup. time.sleep(2) def root(): """Roots adb and successive adb commands will run under root.""" Loading startop/scripts/iorap/compiler.py +10 −6 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import re import sys import tempfile from pathlib import Path from datetime import timedelta from typing import Iterable, Optional, List DIR = os.path.abspath(os.path.dirname(__file__)) Loading Loading @@ -173,7 +174,7 @@ def build_protobuf(page_runs, inode2filename, filters=[]): return trace_file def calc_trace_end_time(trace2db: Trace2Db, trace_duration: Optional[int]) -> float: trace_duration: Optional[timedelta]) -> float: """ Calculates the end time based on the trace duration. The start time is the first receiving mm file map event. Loading @@ -189,9 +190,9 @@ def calc_trace_end_time(trace2db: Trace2Db, MmFilemapAddToPageCache.raw_ftrace_entry).order_by( RawFtraceEntry.timestamp).first() return first_event.raw_ftrace_entry.timestamp + trace_duration return first_event.raw_ftrace_entry.timestamp + trace_duration.total_seconds() def query_add_to_page_cache(trace2db: Trace2Db, trace_duration: Optional[int]): def query_add_to_page_cache(trace2db: Trace2Db, trace_duration: Optional[timedelta]): end_time = calc_trace_end_time(trace2db, trace_duration) # SELECT * FROM tbl ORDER BY id; return trace2db.session.query(MmFilemapAddToPageCache).join( Loading @@ -210,7 +211,7 @@ def transform_perfetto_trace_to_systrace(path_to_perfetto_trace: str, def run(sql_db_path:str, trace_file:str, trace_duration:Optional[int], trace_duration:Optional[timedelta], output_file:str, inode_table:str, filter:List[str]) -> int: Loading Loading @@ -292,11 +293,14 @@ def main(argv): if options.sql_db: sql_db_path = options.sql_db trace_duration = timedelta(milliseconds=options.trace_duration) if \ options.trace_duration is not None else None # if the input is systrace if options.trace_file: return run(sql_db_path, options.trace_file, options.trace_duration, trace_duration, options.output_file, inode_table, options.filter) Loading @@ -308,7 +312,7 @@ def main(argv): trace_file.name) return run(sql_db_path, trace_file.name, options.trace_duration, trace_duration, options.output_file, inode_table, options.filter) Loading startop/scripts/iorap/compiler_test.py +2 −2 Original line number Diff line number Diff line Loading @@ -70,9 +70,9 @@ def test_compiler_main(tmpdir): # 10ms duration expected = os.path.join(DIR, 'test_fixtures/compiler/test_result_with_duration.TraceFile.pb') assert_compile_result(output, expected, '--duration', '10') assert_compile_result(output, expected, '--duration', '10000') # 30ms duration expected = os.path.join(DIR, 'test_fixtures/compiler/test_result_without_duration.TraceFile.pb') assert_compile_result(output, expected, '--duration', '30') assert_compile_result(output, expected, '--duration', '30000') Loading
startop/scripts/app_startup/lib/adb_utils.py +2 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,8 @@ def logcat_save_timestamp() -> str: def vm_drop_cache(): """Free pagecache and slab object.""" cmd_utils.run_adb_shell_command('echo 3 > /proc/sys/vm/drop_caches') # Sleep a little bit to provide enougth time for cache cleanup. time.sleep(2) def root(): """Roots adb and successive adb commands will run under root.""" Loading
startop/scripts/iorap/compiler.py +10 −6 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import re import sys import tempfile from pathlib import Path from datetime import timedelta from typing import Iterable, Optional, List DIR = os.path.abspath(os.path.dirname(__file__)) Loading Loading @@ -173,7 +174,7 @@ def build_protobuf(page_runs, inode2filename, filters=[]): return trace_file def calc_trace_end_time(trace2db: Trace2Db, trace_duration: Optional[int]) -> float: trace_duration: Optional[timedelta]) -> float: """ Calculates the end time based on the trace duration. The start time is the first receiving mm file map event. Loading @@ -189,9 +190,9 @@ def calc_trace_end_time(trace2db: Trace2Db, MmFilemapAddToPageCache.raw_ftrace_entry).order_by( RawFtraceEntry.timestamp).first() return first_event.raw_ftrace_entry.timestamp + trace_duration return first_event.raw_ftrace_entry.timestamp + trace_duration.total_seconds() def query_add_to_page_cache(trace2db: Trace2Db, trace_duration: Optional[int]): def query_add_to_page_cache(trace2db: Trace2Db, trace_duration: Optional[timedelta]): end_time = calc_trace_end_time(trace2db, trace_duration) # SELECT * FROM tbl ORDER BY id; return trace2db.session.query(MmFilemapAddToPageCache).join( Loading @@ -210,7 +211,7 @@ def transform_perfetto_trace_to_systrace(path_to_perfetto_trace: str, def run(sql_db_path:str, trace_file:str, trace_duration:Optional[int], trace_duration:Optional[timedelta], output_file:str, inode_table:str, filter:List[str]) -> int: Loading Loading @@ -292,11 +293,14 @@ def main(argv): if options.sql_db: sql_db_path = options.sql_db trace_duration = timedelta(milliseconds=options.trace_duration) if \ options.trace_duration is not None else None # if the input is systrace if options.trace_file: return run(sql_db_path, options.trace_file, options.trace_duration, trace_duration, options.output_file, inode_table, options.filter) Loading @@ -308,7 +312,7 @@ def main(argv): trace_file.name) return run(sql_db_path, trace_file.name, options.trace_duration, trace_duration, options.output_file, inode_table, options.filter) Loading
startop/scripts/iorap/compiler_test.py +2 −2 Original line number Diff line number Diff line Loading @@ -70,9 +70,9 @@ def test_compiler_main(tmpdir): # 10ms duration expected = os.path.join(DIR, 'test_fixtures/compiler/test_result_with_duration.TraceFile.pb') assert_compile_result(output, expected, '--duration', '10') assert_compile_result(output, expected, '--duration', '10000') # 30ms duration expected = os.path.join(DIR, 'test_fixtures/compiler/test_result_without_duration.TraceFile.pb') assert_compile_result(output, expected, '--duration', '30') assert_compile_result(output, expected, '--duration', '30000')