diff options
author | Artem Kotsiuba <artem.kotsiuba@linaro.org> | 2021-10-06 16:43:54 +0100 |
---|---|---|
committer | Artem Kotsiuba <artem.kotsiuba@linaro.org> | 2021-10-26 15:57:44 +0100 |
commit | d2c7d8b3e972e4f4ba2f1a2da71ffc9fbf0428c1 (patch) | |
tree | c897bd49c372bc3a8f022362246488ac37c3894d | |
parent | 5aa84a8e4378af7c1e747b94398cafaefa37f053 (diff) | |
download | art-build-scripts-d2c7d8b3e972e4f4ba2f1a2da71ffc9fbf0428c1.tar.gz |
ART: Add boot.oat support to compile statistics scripts
This change adds functionality to collect compilation
statistics when compiling boot.oat. Compilation of boot.oat
produces multiple files (.oat, .vdex and .art). The tool collects
statistics only for .oat files (boot.oat, boot-core-libart.oat,
boot-okhttp.oat, boot-apache-xml.oat and boot-bouncycastle.oat)
and outputs it to .json file using name of the output file
as a key.
Test: ./scripts/benchmarks/compilation_stats_target.sh boot.oat
--iterations 2 --skip-build
Change-Id: I086af96b0dd9fe02f23dbaa587b6eb912f89f16e
-rwxr-xr-x | benchmarks/compilation_stats_target.sh | 66 | ||||
-rw-r--r-- | utils/utils_benchmarks.sh | 30 |
2 files changed, 83 insertions, 13 deletions
diff --git a/benchmarks/compilation_stats_target.sh b/benchmarks/compilation_stats_target.sh index 8a093819..6bef4795 100755 --- a/benchmarks/compilation_stats_target.sh +++ b/benchmarks/compilation_stats_target.sh @@ -44,6 +44,7 @@ declare -A options_format=( ["list-devices"]="p:list_devices()" ["target-device"]="" ["dump-cfg"]="false" + ["boot-oat"]="false" ) declare -A options=() declare -a benchmarks=() @@ -51,6 +52,9 @@ declare -a benchmarks=() validate_apk_names() { local apk for apk in "${benchmarks[@]}"; do + if [[ ${apk} == "boot.oat" ]]; then + continue + fi if [[ ! -f "${apk}" ]]; then log E "APK file ${apk} does not exist" exit 1 @@ -59,9 +63,10 @@ validate_apk_names() { } usage() { - log I "Usage: $0 [OPTION]... [APK]..." + log I "Usage: $0 [OPTION]... [APK]... [boot.oat]" log I "" - log I "This script should be used for getting compile stats for APK(s) on a target device." + log I "This script should be used for getting compile stats for give APK(s) or" + log I "boot.oat (as a special case) on a target device" log I "The script expects a device to be connected. Use --list-devices to show supported" log I "devices." log I "" @@ -116,7 +121,7 @@ list_devices() { # Arguments: # ${1}: isa # ${2}: APK name -create_target_cmdline_sh() { +create_apk_target_cmdline_sh() { local isa="${1}" apk="${2}" @@ -148,6 +153,31 @@ EOM safe adb_shell "echo '${target_script}' > ${ART_TEST_CHROOT}/data/local/tmp/cmdline.sh" } +create_boot_oat_cmdline_sh() { + local isa="${1}" + + # use --no-watch-dog option to bypass 9.5 minutes timeout in dex2oat + read -r -d '' target_script << EOM + $(get_target_art_test_env_vars_exports) + rm -rf /data/local/tmp/boot-oat/${isa} + mkdir -p /data/local/tmp/boot-oat/${isa} + + cd /data/local/tmp/boot-oat/${isa} + mkdir symbols + + before=\$EPOCHREALTIME + $(get_target_dex2oat_boot_oat_cmd "${isa}" ".") --no-watch-dog -j1 + after=\$EPOCHREALTIME + + echo "Before: "\$before + echo "After: "\$after + \$@ +EOM + + safe adb_shell "mkdir -p ${ART_TEST_CHROOT}/data/local/tmp/" + safe adb_shell "echo '${target_script}' > ${ART_TEST_CHROOT}/data/local/tmp/cmdline.sh" +} + # Arguments: # ${1}: bitness # ${2}: device @@ -164,14 +194,26 @@ run_apks() { fi start_adb_section "run_benchmarks_${2}_${1}_${3}" - for apk in "${benchmarks[@]}"; do - log I "Processing $apk" - adb push "${apk}" "${ART_TEST_CHROOT}/data/local/tmp" - apk_name=$(basename "${apk}") - apk_basename=$(basename "${apk_name}" ".apk") - output_oat="${ART_TEST_CHROOT}/data/local/tmp/oat/${isa}/${apk_basename}.odex" + for benchmark in "${benchmarks[@]}"; do + log I "Processing ${benchmark}" - create_target_cmdline_sh "${isa}" "${apk_name}" + if [[ ${benchmark} != "boot.oat" ]]; then + adb push "${benchmark}" "${ART_TEST_CHROOT}/data/local/tmp" + apk_name=$(basename "${benchmark}") + apk_basename=$(basename "${apk_name}" ".apk") + output_oats=("${ART_TEST_CHROOT}/data/local/tmp/oat/${isa}/${apk_basename}.odex") + create_apk_target_cmdline_sh "${isa}" "${apk_name}" + else + apk_name="boot.oat" + local -r boot_oat_path="${ART_TEST_CHROOT}/data/local/tmp/boot-oat/${isa}" + output_oats=() + output_oats+=("${boot_oat_path}/boot.oat") + output_oats+=("${boot_oat_path}/boot-core-libart.oat") + output_oats+=("${boot_oat_path}/boot-okhttp.oat") + output_oats+=("${boot_oat_path}/boot-apache-xml.oat") + output_oats+=("${boot_oat_path}/boot-bouncycastle.oat") + create_boot_oat_cmdline_sh "${isa}" + fi export ART_COMMAND="chroot ${ART_TEST_CHROOT} sh /data/local/tmp/cmdline.sh " local run_cmd_options=() @@ -179,9 +221,9 @@ run_apks() { run_cmd_options+=("--iterations" "${options["iterations"]}") run_cmd_options+=("--mode" "${1}") run_cmd_options+=("--output-json" "${compilation_stats_file}") - run_cmd_options+=("--output-oat" "${output_oat}") - run_cmd_options+=("--target-copy-path" "${ART_TEST_CHROOT}/data/local/tmp") + run_cmd_options+=("--output-oat" "${output_oats[@]}") run_cmd_options+=("--add-pathname" "${apk_name}") + run_cmd_options+=("--target-copy-path" "${ART_TEST_CHROOT}/data/local/tmp") ./benchmarks/compilation_stats.py "${run_cmd_options[@]}" done end_adb_section "run_benchmarks_${2}_${1}_${3}" "$?" diff --git a/utils/utils_benchmarks.sh b/utils/utils_benchmarks.sh index c8899c3c..4234d84d 100644 --- a/utils/utils_benchmarks.sh +++ b/utils/utils_benchmarks.sh @@ -110,6 +110,33 @@ get_target_dex2oat_cmd() { --instruction-set-features=${isa_features}" } +# Get target dex2oat command for boot.oat compilation. +# Args: +# $1: ISA +# $2: output dir +# $3: ISA features (optional). +get_target_dex2oat_boot_oat_cmd() { + local -r isa=$1 + local -r oat_dir=$2 + local -r isa_features=${3:-default} + local -r path_to_jars="${ART_TEST_APEX_ART_ROOT}/javalib" + echo "dex2oat --base=0x70000000 --dex-file=${path_to_jars}/core-oj.jar \ + --dex-file=${path_to_jars}/core-libart.jar \ + --dex-file=${path_to_jars}/okhttp.jar \ + --dex-file=${path_to_jars}/bouncycastle.jar \ + --dex-file=${path_to_jars}/apache-xml.jar \ + --dex-location=${path_to_jars}/core-oj.jar \ + --dex-location=${path_to_jars}/core-libart.jar \ + --dex-location=${path_to_jars}/okhttp.jar \ + --dex-location=${path_to_jars}/bouncycastle.jar \ + --dex-location=${path_to_jars}/apache-xml.jar \ + --image-format=lz4hc \ + --oat-file=${oat_dir}/boot.oat \ + --oat-location=${oat_dir}/boot.oat \ + --image=${oat_dir}/boot.art --instruction-set=${isa} --no-inline-from=core-oj.jar \ + --instruction-set-features=${isa_features}" +} + # Assert that the cpu option is valid. # Args: # $1: the cpu option. @@ -271,7 +298,8 @@ list_devices_from_config() { done } -# Reads +# Prepares the environment for benchmark run +# ${1} - benchmark options set_environment_for_benchmark_run() { local -n bench_options=$1 set_environment_target |