Loading startop/scripts/app_startup/run_app_with_prefetch.py +10 −2 Original line number Diff line number Diff line Loading @@ -228,6 +228,9 @@ def run(readahead: str, # Drop all caches to get cold starts. adb_utils.vm_drop_cache() if readahead != 'warm' and readahead != 'cold': iorapd_utils.enable_iorapd_readahead() print_utils.debug_print('Running with timeout {}'.format(timeout)) pre_launch_timestamp = adb_utils.logcat_save_timestamp() Loading Loading @@ -272,12 +275,17 @@ def perform_post_launch_cleanup(readahead: str, A bool indicates whether the cleanup succeeds or not. """ if readahead != 'warm' and readahead != 'cold': return iorapd_utils.wait_for_iorapd_finish(package, passed = iorapd_utils.wait_for_iorapd_finish(package, activity, timeout, debug, logcat_timestamp) if not passed: return passed return iorapd_utils.disable_iorapd_readahead() # Don't need to do anything for warm or cold. return True Loading startop/scripts/app_startup/run_app_with_prefetch_test.py +4 −0 Original line number Diff line number Diff line Loading @@ -243,6 +243,8 @@ def test_run_with_vm_cache_drop_and_post_launch_cleanup(): debug=False) calls = [call('adb shell "echo 3 > /proc/sys/vm/drop_caches"'), call('bash -c "source {}; iorapd_readahead_enable"'. format(run.IORAP_COMMON_BASH_SCRIPT)), call('adb shell "date -u +\'%Y-%m-%d %H:%M:%S.%N\'"'), call( 'timeout {timeout} "{DIR}/launch_application" "{package}" "{activity}" | ' Loading @@ -262,6 +264,8 @@ def test_run_with_vm_cache_drop_and_post_launch_cleanup(): activity='MainActivity', timestamp='123:123', script_path=run.IORAP_COMMON_BASH_SCRIPT)), call('bash -c "source {}; iorapd_readahead_disable"'. format(run.IORAP_COMMON_BASH_SCRIPT)), call('adb shell ps | grep "music" | awk \'{print $2;}\''), call('adb shell "kill 9999"')] mock_run_shell_command.assert_has_calls(calls) Loading startop/scripts/iorap/lib/iorapd_utils.py +25 −0 Original line number Diff line number Diff line Loading @@ -86,3 +86,28 @@ def wait_for_iorapd_finish(package: str, [package, activity, logcat_timestamp, str(timeout)]) return passed def enable_iorapd_readahead() -> bool: """ Disable readahead. Subsequent launches of an application will be sped up by iorapd readahead prefetching. Returns: A bool indicates whether the enabling is done successfully or not. """ passed, _ = cmd_utils.run_shell_func(IORAP_COMMON_BASH_SCRIPT, 'iorapd_readahead_enable', []) return passed def disable_iorapd_readahead() -> bool: """ Disable readahead. Subsequent launches of an application will be not be sped up by iorapd readahead prefetching. Returns: A bool indicates whether the disabling is done successfully or not. """ passed, _ = cmd_utils.run_shell_func(IORAP_COMMON_BASH_SCRIPT, 'iorapd_readahead_disable', []) return passed startop/scripts/lib/cmd_utils.py +10 −4 Original line number Diff line number Diff line Loading @@ -44,10 +44,16 @@ def run_shell_func(script_path: str, A tuple of running status (True=succeeded, False=failed or timed out) and std output (string contents of stdout with trailing whitespace removed) . """ if args: cmd = 'bash -c "source {script_path}; {func} {args}"'.format( script_path=script_path, func=func, args=' '.join("'{}'".format(arg) for arg in args)) else: cmd = 'bash -c "source {script_path}; {func}"'.format( script_path=script_path, func=func) print_utils.debug_print(cmd) return run_shell_command(cmd) Loading Loading
startop/scripts/app_startup/run_app_with_prefetch.py +10 −2 Original line number Diff line number Diff line Loading @@ -228,6 +228,9 @@ def run(readahead: str, # Drop all caches to get cold starts. adb_utils.vm_drop_cache() if readahead != 'warm' and readahead != 'cold': iorapd_utils.enable_iorapd_readahead() print_utils.debug_print('Running with timeout {}'.format(timeout)) pre_launch_timestamp = adb_utils.logcat_save_timestamp() Loading Loading @@ -272,12 +275,17 @@ def perform_post_launch_cleanup(readahead: str, A bool indicates whether the cleanup succeeds or not. """ if readahead != 'warm' and readahead != 'cold': return iorapd_utils.wait_for_iorapd_finish(package, passed = iorapd_utils.wait_for_iorapd_finish(package, activity, timeout, debug, logcat_timestamp) if not passed: return passed return iorapd_utils.disable_iorapd_readahead() # Don't need to do anything for warm or cold. return True Loading
startop/scripts/app_startup/run_app_with_prefetch_test.py +4 −0 Original line number Diff line number Diff line Loading @@ -243,6 +243,8 @@ def test_run_with_vm_cache_drop_and_post_launch_cleanup(): debug=False) calls = [call('adb shell "echo 3 > /proc/sys/vm/drop_caches"'), call('bash -c "source {}; iorapd_readahead_enable"'. format(run.IORAP_COMMON_BASH_SCRIPT)), call('adb shell "date -u +\'%Y-%m-%d %H:%M:%S.%N\'"'), call( 'timeout {timeout} "{DIR}/launch_application" "{package}" "{activity}" | ' Loading @@ -262,6 +264,8 @@ def test_run_with_vm_cache_drop_and_post_launch_cleanup(): activity='MainActivity', timestamp='123:123', script_path=run.IORAP_COMMON_BASH_SCRIPT)), call('bash -c "source {}; iorapd_readahead_disable"'. format(run.IORAP_COMMON_BASH_SCRIPT)), call('adb shell ps | grep "music" | awk \'{print $2;}\''), call('adb shell "kill 9999"')] mock_run_shell_command.assert_has_calls(calls) Loading
startop/scripts/iorap/lib/iorapd_utils.py +25 −0 Original line number Diff line number Diff line Loading @@ -86,3 +86,28 @@ def wait_for_iorapd_finish(package: str, [package, activity, logcat_timestamp, str(timeout)]) return passed def enable_iorapd_readahead() -> bool: """ Disable readahead. Subsequent launches of an application will be sped up by iorapd readahead prefetching. Returns: A bool indicates whether the enabling is done successfully or not. """ passed, _ = cmd_utils.run_shell_func(IORAP_COMMON_BASH_SCRIPT, 'iorapd_readahead_enable', []) return passed def disable_iorapd_readahead() -> bool: """ Disable readahead. Subsequent launches of an application will be not be sped up by iorapd readahead prefetching. Returns: A bool indicates whether the disabling is done successfully or not. """ passed, _ = cmd_utils.run_shell_func(IORAP_COMMON_BASH_SCRIPT, 'iorapd_readahead_disable', []) return passed
startop/scripts/lib/cmd_utils.py +10 −4 Original line number Diff line number Diff line Loading @@ -44,10 +44,16 @@ def run_shell_func(script_path: str, A tuple of running status (True=succeeded, False=failed or timed out) and std output (string contents of stdout with trailing whitespace removed) . """ if args: cmd = 'bash -c "source {script_path}; {func} {args}"'.format( script_path=script_path, func=func, args=' '.join("'{}'".format(arg) for arg in args)) else: cmd = 'bash -c "source {script_path}; {func}"'.format( script_path=script_path, func=func) print_utils.debug_print(cmd) return run_shell_command(cmd) Loading