def bench_jsimage(bench_conf, out, err, extra_options=None): if extra_options is None: extra_options = [] image_dir, js_image_name, image_path = _bench_image_params(bench_conf) if not exists(image_path): native_image = mx_substratevm.vm_native_image_path( mx_substratevm._graalvm_js_config) if not exists(native_image): mx_substratevm.build_native_image_image( mx_substratevm._graalvm_js_config) with _timedelta('IMAGEBUILD: ', out=out): out('INFO: EXECUTE IMAGEBUILD: svmimage-%s\n' % bench_conf) _, image_building_options = _bench_configs[bench_conf] command = [ native_image, '--language:js', '-H:Path=' + image_dir, '-H:Name=' + js_image_name ] + image_building_options + extra_options # Print out the command. print(' '.join(command)) # Run the command and copy the output to out so it can be examined for metrics. runner = mx_substratevm.ProcessRunner(command, stderr=subprocess.STDOUT) returncode, stdoutdata, _ = runner.run(timeout=240) out(stdoutdata) if runner.timedout: mx.abort( 'Javascript image building for js-benchmarks timed out.') if returncode != 0: mx.abort('Javascript image building for js-benchmarks failed.') # Generate the image size metric. image_statinfo = os.stat(image_path) image_size = image_statinfo.st_size / 1024.0 / 1024.0 out('INFO: IMAGESIZE: %0.2f MiB\n' % image_size) return image_path
def run_js(vmArgs, jsArgs, nonZeroIsFatal, out, err, cwd): bench_conf, should_bench_compile_server = _get_bench_conf(vmArgs) _, _, image_path = _bench_image_params(bench_conf) if should_bench_compile_server and not exists(image_path): for _ in range(_IMAGE_BENCH_REPETITIONS): with mx_substratevm.native_image_context(): _bench_compile_server(bench_conf, out) image_path = bench_jsimage(bench_conf, out=out, err=err) if image_path: vmArgs = [ vmArg for vmArg in vmArgs if not (vmArg.startswith(_conf_arg_prefix) or vmArg == '--bench-compilation-server') ] all_args = vmArgs + jsArgs mx.logv("Running substratevm image '%s' with '%s' i.e.:" % (image_path, all_args)) mx.logv(image_path + " " + " ".join(all_args)) runner = mx_substratevm.ProcessRunner([image_path] + all_args, stderr=subprocess.STDOUT) timeout_factor, _ = _bench_configs[bench_conf] with _timedelta('IMAGERUN: ', out=out): returncode, stdoutdata, _ = runner.run(8 * 60 * timeout_factor) if runner.timedout: if nonZeroIsFatal: mx.abort('Javascript benchmark timeout') return -1 out(stdoutdata) return returncode if nonZeroIsFatal: mx.abort('Javascript image building for js-benchmarks failed') return -1