def find_min_xmx(options, args): # Args will be destroyed assert len(args) == 0 # If we can run in 128 MB then we are good (which we can for small examples # or D8 on medium sized examples) if options.find_min_xmx_min_memory: not_working = options.find_min_xmx_min_memory elif options.compiler == 'd8': not_working = 128 else: not_working = 1024 if options.find_min_xmx_max_memory: working = options.find_min_xmx_max_memory else: working = 1024 * 8 exit_code = 0 range = int(options.find_min_xmx_range_size) while working - not_working > range: next_candidate = int(working - ((working - not_working) / 2)) print('working: %s, non_working: %s, next_candidate: %s' % (working, not_working, next_candidate)) extra_args = ['-Xmx%sM' % next_candidate] t0 = time.time() exit_code = run_with_options(options, [], extra_args) t1 = time.time() print('Running took: %s ms' % (1000.0 * (t1 - t0))) if exit_code != 0: if exit_code not in [OOM_EXIT_CODE, TIMEOUT_KILL_CODE]: print('Non OOM/Timeout error executing, exiting') return 2 if exit_code == 0: working = next_candidate elif exit_code == TIMEOUT_KILL_CODE: print('Timeout. Continue to the next candidate.') not_working = next_candidate else: assert exit_code == OOM_EXIT_CODE not_working = next_candidate assert working - not_working <= range found_range = 'Found range: %s - %s' % (not_working, working) print(found_range) if options.find_min_xmx_archive: sha = utils.get_HEAD_sha1() (version, _) = get_version_and_data(options) destination = os.path.join(utils.R8_TEST_RESULTS_BUCKET, FIND_MIN_XMX_DIR, sha, options.compiler, options.compiler_build, options.app, version, get_type(options)) gs_destination = 'gs://%s' % destination utils.archive_value(FIND_MIN_XMX_FILE, gs_destination, found_range + '\n') return 0
def archive_log(stdout, stderr, exitcode, timed_out, cmd): sha = utils.get_HEAD_sha1() cmd_dir = cmd.replace(' ', '_').replace('/', '_') destination = os.path.join(get_sha_destination(sha), cmd_dir) gs_destination = 'gs://%s' % destination url = 'https://storage.cloud.google.com/%s' % destination log('Archiving logs to: %s' % gs_destination) utils.archive_value(EXITCODE, gs_destination, exitcode) utils.archive_value(TIMED_OUT, gs_destination, timed_out) utils.archive_file(STDOUT, gs_destination, stdout) utils.archive_file(STDERR, gs_destination, stderr) log('Logs available at: %s' % url)
def put_magic_file(name, sha): utils.archive_value(name, get_magic_file_base_path(), sha)
def archive_status(failed): gs_destination = 'gs://%s' % get_sha_destination(utils.get_HEAD_sha1()) utils.archive_value('status', gs_destination, failed)