Snap for 5179425 from f0311c252f09e4acf1ef416970a845ea98528a9f to qt-release
Change-Id: I57356c820a453d15e6de64df72b568c0224e5778
diff --git a/build/apex/ld.config.txt b/build/apex/ld.config.txt
index ac4d1eb..fddb17e 100644
--- a/build/apex/ld.config.txt
+++ b/build/apex/ld.config.txt
@@ -1 +1,24 @@
-# TODO: Write me.
+# Copyright (C) 2018 The Android Open Source Project
+#
+# Bionic loader config file for the Runtime APEX.
+#
+# There are no versioned APEX paths here - this APEX module does not support
+# having several versions mounted.
+
+dir.runtime = /apex/com.android.runtime/bin/
+
+[runtime]
+additional.namespaces = platform
+
+# Keep in sync with runtime namespace in /system/etc/ld.config.txt.
+namespace.default.isolated = true
+namespace.default.search.paths = /apex/com.android.runtime/${LIB}
+namespace.default.links = platform
+# TODO(b/119867084): Restrict fallback to platform namespace to PALette library.
+namespace.default.link.platform.allow_all_shared_libs = true
+
+# Keep in sync with default namespace in /system/etc/ld.config.txt.
+namespace.platform.isolated = true
+namespace.platform.search.paths = /system/${LIB}
+namespace.platform.links = default
+namespace.platform.link.default.shared_libs = libc.so:libdl.so:libm.so
diff --git a/build/apex/runtests.sh b/build/apex/runtests.sh
index c19c7bd..924c44b 100755
--- a/build/apex/runtests.sh
+++ b/build/apex/runtests.sh
@@ -33,6 +33,11 @@
sudo apt-get install libguestfs-tools
"
+which tree > /dev/null || die "This script requires the 'tree' tool.
+On Debian-based systems, this can be installed with:
+
+ sudo apt-get install tree
+"
[[ -n "$ANDROID_PRODUCT_OUT" ]] \
|| die "You need to source and lunch before you can use this script."
@@ -66,8 +71,16 @@
shift
done
-work_dir=$(mktemp -d)
-mount_point="$work_dir/image"
+
+# build_apex APEX_MODULE
+# ----------------------
+# Build APEX package APEX_MODULE.
+function build_apex {
+ if $build_apex_p; then
+ local apex_module=$1
+ say "Building package $apex_module" && make "$apex_module" || die "Cannot build $apex_module"
+ fi
+}
function check_binary {
[[ -x "$mount_point/bin/$1" ]] || die "Cannot find binary '$1' in mounted image"
@@ -91,36 +104,22 @@
|| die "Cannot find library '$1' in mounted image"
}
-function build_apex {
- if $build_apex_p; then
- say "Building package $1" && make "$1" || die "Cannot build $1"
- fi
-}
-
-function check_contents {
-
+# Check contents of APEX payload located in `$mount_point`.
+function check_release_contents {
# Check that the mounted image contains a manifest.
[[ -f "$mount_point/apex_manifest.json" ]] || die "no manifest"
# Check that the mounted image contains ART base binaries.
check_multilib_binary dalvikvm
- # TODO: Does not work yet.
+ # TODO: Does not work yet (b/119942078).
: check_binary_symlink dalvikvm
check_binary dex2oat
check_binary dexoptanalyzer
check_binary profman
- # Check that the mounted image contains ART tools binaries.
- check_binary dexdiag
- check_binary dexdump
- check_binary dexlist
# oatdump is only in device apex's due to build rules
- # check_binary oatdump
-
- # Check that the mounted image contains ART debug binaries.
- check_binary dex2oatd
- check_binary dexoptanalyzerd
- check_binary profmand
+ # TODO: Check for it when it is also built for host.
+ : check_binary oatdump
# Check that the mounted image contains ART libraries.
check_library libart-compiler.so
@@ -135,20 +134,6 @@
check_library libdexfile.so
check_library libprofile.so
- # Check that the mounted image contains ART debug libraries.
- check_library libartd-compiler.so
- check_library libartd.so
- check_library libopenjdkd.so
- check_library libopenjdkjvmd.so
- check_library libopenjdkjvmtid.so
- check_library libadbconnectiond.so
- # TODO: Should we check for these libraries too, even if they are not explicitly
- # listed as dependencies in the Android Runtime APEX module rule?
- check_library libdexfiled.so
- check_library libartbased.so
- check_library libartd-dexlayout.so
- check_library libprofiled.so
-
# TODO: Should we check for other libraries, such as:
#
# libbacktrace.so
@@ -164,105 +149,197 @@
# ?
}
+# Check debug contents of APEX payload located in `$mount_point`.
+function check_debug_contents {
+ # Check that the mounted image contains ART tools binaries.
+ check_binary dexdiag
+ check_binary dexdump
+ check_binary dexlist
-# *****************************************
-# * Testing for com.android.runtime.debug *
-# *****************************************
+ # Check that the mounted image contains ART debug binaries.
+ check_binary dex2oatd
+ check_binary dexoptanalyzerd
+ check_binary profmand
-# Garbage collection.
-function finish_device_debug {
- # Don't fail early during cleanup.
- set +e
+ # Check that the mounted image contains ART debug libraries.
+ check_library libartd-compiler.so
+ check_library libartd.so
+ check_library libopenjdkd.so
+ check_library libopenjdkjvmd.so
+ check_library libopenjdkjvmtid.so
+ check_library libadbconnectiond.so
+ # TODO: Should we check for these libraries too, even if they are not explicitly
+ # listed as dependencies in the Android Runtime APEX module rule?
+ check_library libdexfiled.so
+ check_library libartbased.so
+ check_library libartd-dexlayout.so
+ check_library libprofiled.so
+}
+
+# Testing target (device) APEX packages.
+# ======================================
+
+# Clean-up.
+function cleanup_target {
guestunmount "$mount_point"
rm -rf "$work_dir"
}
-trap finish_device_debug EXIT
+# Garbage collection.
+function finish_target {
+ # Don't fail early during cleanup.
+ set +e
+ cleanup_target
+}
-# TODO: Also exercise the Release Runtime APEX (`com.android.runtime.release`).
+# setup_target_apex APEX_MODULE MOUNT_POINT
+# -----------------------------------------
+# Extract image from target APEX_MODULE and mount it in MOUNT_POINT.
+function setup_target_apex {
+ local apex_module=$1
+ local mount_point=$2
+ local system_apexdir="$ANDROID_PRODUCT_OUT/system/apex"
+ local apex_package="$system_apexdir/$apex_module.apex"
+
+ say "Extracting and mounting image"
+
+ # Extract the payload from the Android Runtime APEX.
+ local image_filename="apex_payload.img"
+ unzip -q "$apex_package" "$image_filename" -d "$work_dir"
+ mkdir "$mount_point"
+ local image_file="$work_dir/$image_filename"
+
+ # Check filesystems in the image.
+ local image_filesystems="$work_dir/image_filesystems"
+ virt-filesystems -a "$image_file" >"$image_filesystems"
+ # We expect a single partition (/dev/sda) in the image.
+ local partition="/dev/sda"
+ echo "$partition" | cmp "$image_filesystems" -
+
+ # Mount the image from the Android Runtime APEX.
+ guestmount -a "$image_file" -m "$partition" "$mount_point"
+
+ # List the contents of the mounted image (optional).
+ $list_image_files_p \
+ && say "Listing image files" && ls -ld "$mount_point" && tree -ap "$mount_point"
+}
+
+# Testing release APEX package (com.android.runtime.release).
+# -----------------------------------------------------------
+
+apex_module="com.android.runtime.release"
+
+work_dir=$(mktemp -d)
+mount_point="$work_dir/image"
+
+trap finish_target EXIT
+
+# Build the APEX package (optional).
+build_apex "$apex_module"
+
+# Set up APEX package.
+setup_target_apex "$apex_module" "$mount_point"
+
+# Run tests on APEX package.
+say "Checking APEX package $apex_module"
+check_release_contents
+
+# Clean up.
+trap - EXIT
+cleanup_target
+
+say "$apex_module tests passed"
+
+# Testing debug APEX package (com.android.runtime.debug).
+# -------------------------------------------------------
+
apex_module="com.android.runtime.debug"
-# Build the Android Runtime APEX package (optional).
-build_apex $apex_module
+work_dir=$(mktemp -d)
+mount_point="$work_dir/image"
-system_apexdir="$ANDROID_PRODUCT_OUT/system/apex"
-apex_package="$system_apexdir/$apex_module.apex"
+trap finish_target EXIT
-say "Extracting and mounting image"
+# Build the APEX package (optional).
+build_apex "$apex_module"
-# Extract the payload from the Android Runtime APEX.
-image_filename="apex_payload.img"
-unzip -q "$apex_package" "$image_filename" -d "$work_dir"
-mkdir "$mount_point"
-image_file="$work_dir/$image_filename"
+# Set up APEX package.
+setup_target_apex "$apex_module" "$mount_point"
-# Check filesystems in the image.
-image_filesystems="$work_dir/image_filesystems"
-virt-filesystems -a "$image_file" >"$image_filesystems"
-# We expect a single partition (/dev/sda) in the image.
-partition="/dev/sda"
-echo "$partition" | cmp "$image_filesystems" -
-
-# Mount the image from the Android Runtime APEX.
-guestmount -a "$image_file" -m "$partition" "$mount_point"
-
-# List the contents of the mounted image (optional).
-$list_image_files_p && say "Listing image files" && ls -ld "$mount_point" && tree -ap "$mount_point"
-
-say "Running tests"
-
-check_contents
-
-# Check for files pulled in from device-only oatdump.
+# Run tests on APEX package.
+say "Checking APEX package $apex_module"
+check_release_contents
+check_debug_contents
+# Check for files pulled in from debug target-only oatdump.
check_binary oatdump
check_library libart-disassembler.so
-# Cleanup
+# Clean up.
trap - EXIT
-guestunmount "$mount_point"
-rm -rf "$work_dir"
+cleanup_target
-say "$apex_module Tests passed"
+say "$apex_module tests passed"
-# ****************************************
-# * Testing for com.android.runtime.host *
-# ****************************************
+
+# Testing host APEX package (com.android.runtime.host).
+# =====================================================
+
+# Clean-up.
+function cleanup_host {
+ rm -rf "$work_dir"
+}
# Garbage collection.
function finish_host {
# Don't fail early during cleanup.
set +e
- rm -rf "$work_dir"
+ cleanup_host
}
+# setup_host_apex APEX_MODULE MOUNT_POINT
+# ---------------------------------------
+# Extract Zip file from host APEX_MODULE and extract it in MOUNT_POINT.
+function setup_host_apex {
+ local apex_module=$1
+ local mount_point=$2
+ local system_apexdir="$ANDROID_HOST_OUT/apex"
+ local apex_package="$system_apexdir/$apex_module.zipapex"
+
+ say "Extracting payload"
+
+ # Extract the payload from the Android Runtime APEX.
+ local image_filename="apex_payload.zip"
+ unzip -q "$apex_package" "$image_filename" -d "$work_dir"
+ mkdir "$mount_point"
+ local image_file="$work_dir/$image_filename"
+
+ # Unzipping the payload
+ unzip -q "$image_file" -d "$mount_point"
+}
+
+apex_module="com.android.runtime.host"
+
work_dir=$(mktemp -d)
mount_point="$work_dir/zip"
trap finish_host EXIT
-apex_module="com.android.runtime.host"
+# Build the APEX package (optional).
+build_apex "$apex_module"
-# Build the Android Runtime APEX package (optional).
-build_apex $apex_module
+# Set up APEX package.
+setup_host_apex "$apex_module" "$mount_point"
-system_apexdir="$ANDROID_HOST_OUT/apex"
-apex_package="$system_apexdir/$apex_module.zipapex"
+# Run tests on APEX package.
+say "Checking APEX package $apex_module"
+check_release_contents
+check_debug_contents
-say "Extracting payload"
+# Clean up.
+trap - EXIT
+cleanup_host
-# Extract the payload from the Android Runtime APEX.
-image_filename="apex_payload.zip"
-unzip -q "$apex_package" "$image_filename" -d "$work_dir"
-mkdir "$mount_point"
-image_file="$work_dir/$image_filename"
+say "$apex_module tests passed"
-# Unzipping the payload
-unzip -q "$image_file" -d "$mount_point"
-say "Running tests"
-
-check_contents
-
-say "$apex_module Tests passed"
-
-say "Tests passed"
+say "All Android Runtime APEX tests passed"
diff --git a/runtime/gc/allocator/dlmalloc.cc b/runtime/gc/allocator/dlmalloc.cc
index e508d5f..11ad8a8 100644
--- a/runtime/gc/allocator/dlmalloc.cc
+++ b/runtime/gc/allocator/dlmalloc.cc
@@ -38,6 +38,7 @@
#pragma GCC diagnostic ignored "-Wempty-body"
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#pragma GCC diagnostic ignored "-Wnull-pointer-arithmetic"
+#pragma GCC diagnostic ignored "-Wexpansion-to-defined"
#include "../../../external/dlmalloc/malloc.c"
// Note: malloc.c uses a DEBUG define to drive debug code. This interferes with the DEBUG severity
// of libbase, so undefine it now.
diff --git a/runtime/gc/collector/garbage_collector.cc b/runtime/gc/collector/garbage_collector.cc
index 46ff7dc..2ef3d92 100644
--- a/runtime/gc/collector/garbage_collector.cc
+++ b/runtime/gc/collector/garbage_collector.cc
@@ -90,13 +90,14 @@
Thread* self = Thread::Current();
uint64_t start_time = NanoTime();
uint64_t thread_cpu_start_time = ThreadCpuNanoTime();
- GetHeap()->CalculateWeightedAllocatedBytes();
+ GetHeap()->CalculatePreGcWeightedAllocatedBytes();
Iteration* current_iteration = GetCurrentIteration();
current_iteration->Reset(gc_cause, clear_soft_references);
// Note transaction mode is single-threaded and there's no asynchronous GC and this flag doesn't
// change in the middle of a GC.
is_transaction_active_ = Runtime::Current()->IsActiveTransaction();
RunPhases(); // Run all the GC phases.
+ GetHeap()->CalculatePostGcWeightedAllocatedBytes();
// Add the current timings to the cumulative timings.
cumulative_timings_.AddLogger(*GetTimings());
// Update cumulative statistics with how many bytes the GC iteration freed.
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index bfb1019..dc79731 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -214,8 +214,10 @@
long_pause_log_threshold_(long_pause_log_threshold),
long_gc_log_threshold_(long_gc_log_threshold),
process_cpu_start_time_ns_(ProcessCpuNanoTime()),
- last_process_cpu_time_ns_(process_cpu_start_time_ns_),
- weighted_allocated_bytes_(0.0),
+ pre_gc_last_process_cpu_time_ns_(process_cpu_start_time_ns_),
+ post_gc_last_process_cpu_time_ns_(process_cpu_start_time_ns_),
+ pre_gc_weighted_allocated_bytes_(0.0),
+ post_gc_weighted_allocated_bytes_(0.0),
ignore_max_footprint_(ignore_max_footprint),
zygote_creation_lock_("zygote creation lock", kZygoteCreationLock),
zygote_space_(nullptr),
@@ -1070,12 +1072,25 @@
}
}
-void Heap::CalculateWeightedAllocatedBytes() {
- uint64_t current_process_cpu_time = ProcessCpuNanoTime();
+double Heap::CalculateGcWeightedAllocatedBytes(uint64_t gc_last_process_cpu_time_ns,
+ uint64_t current_process_cpu_time) const {
uint64_t bytes_allocated = GetBytesAllocated();
- double weight = current_process_cpu_time - last_process_cpu_time_ns_;
- weighted_allocated_bytes_ += weight * bytes_allocated;
- last_process_cpu_time_ns_ = current_process_cpu_time;
+ double weight = current_process_cpu_time - gc_last_process_cpu_time_ns;
+ return weight * bytes_allocated;
+}
+
+void Heap::CalculatePreGcWeightedAllocatedBytes() {
+ uint64_t current_process_cpu_time = ProcessCpuNanoTime();
+ pre_gc_weighted_allocated_bytes_ +=
+ CalculateGcWeightedAllocatedBytes(pre_gc_last_process_cpu_time_ns_, current_process_cpu_time);
+ pre_gc_last_process_cpu_time_ns_ = current_process_cpu_time;
+}
+
+void Heap::CalculatePostGcWeightedAllocatedBytes() {
+ uint64_t current_process_cpu_time = ProcessCpuNanoTime();
+ post_gc_weighted_allocated_bytes_ +=
+ CalculateGcWeightedAllocatedBytes(post_gc_last_process_cpu_time_ns_, current_process_cpu_time);
+ post_gc_last_process_cpu_time_ns_ = current_process_cpu_time;
}
uint64_t Heap::GetTotalGcCpuTime() {
@@ -1157,8 +1172,12 @@
}
process_cpu_start_time_ns_ = ProcessCpuNanoTime();
- last_process_cpu_time_ns_ = process_cpu_start_time_ns_;
- weighted_allocated_bytes_ = 0u;
+
+ pre_gc_last_process_cpu_time_ns_ = process_cpu_start_time_ns_;
+ pre_gc_weighted_allocated_bytes_ = 0u;
+
+ post_gc_last_process_cpu_time_ns_ = process_cpu_start_time_ns_;
+ post_gc_weighted_allocated_bytes_ = 0u;
total_bytes_freed_ever_ = 0;
total_objects_freed_ever_ = 0;
diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h
index 57c7376..504eff2 100644
--- a/runtime/gc/heap.h
+++ b/runtime/gc/heap.h
@@ -397,11 +397,16 @@
REQUIRES(!Locks::heap_bitmap_lock_)
REQUIRES(Locks::mutator_lock_);
- double GetWeightedAllocatedBytes() const {
- return weighted_allocated_bytes_;
+ double GetPreGcWeightedAllocatedBytes() const {
+ return pre_gc_weighted_allocated_bytes_;
}
- void CalculateWeightedAllocatedBytes();
+ double GetPostGcWeightedAllocatedBytes() const {
+ return post_gc_weighted_allocated_bytes_;
+ }
+
+ void CalculatePreGcWeightedAllocatedBytes();
+ void CalculatePostGcWeightedAllocatedBytes();
uint64_t GetTotalGcCpuTime();
uint64_t GetProcessCpuStartTime() const {
@@ -858,6 +863,9 @@
REQUIRES(!*gc_complete_lock_);
void FinishGC(Thread* self, collector::GcType gc_type) REQUIRES(!*gc_complete_lock_);
+ double CalculateGcWeightedAllocatedBytes(uint64_t gc_last_process_cpu_time_ns,
+ uint64_t current_process_cpu_time) const;
+
// Create a mem map with a preferred base address.
static MemMap MapAnonymousPreferredAddress(const char* name,
uint8_t* request_begin,
@@ -1175,11 +1183,14 @@
// Starting time of the new process; meant to be used for measuring total process CPU time.
uint64_t process_cpu_start_time_ns_;
- // Last time GC started; meant to be used to measure the duration between two GCs.
- uint64_t last_process_cpu_time_ns_;
+ // Last time (before and after) GC started; meant to be used to measure the
+ // duration between two GCs.
+ uint64_t pre_gc_last_process_cpu_time_ns_;
+ uint64_t post_gc_last_process_cpu_time_ns_;
- // allocated_bytes * (current_process_cpu_time - last_process_cpu_time)
- double weighted_allocated_bytes_;
+ // allocated_bytes * (current_process_cpu_time - [pre|post]_gc_last_process_cpu_time)
+ double pre_gc_weighted_allocated_bytes_;
+ double post_gc_weighted_allocated_bytes_;
// If we ignore the max footprint it lets the heap grow until it hits the heap capacity, this is
// useful for benchmarking since it reduces time spent in GC to a low %.
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 69ef2fb..d2c915e 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -320,7 +320,8 @@
}
if (dump_gc_performance_on_shutdown_) {
- heap_->CalculateWeightedAllocatedBytes();
+ heap_->CalculatePreGcWeightedAllocatedBytes();
+ heap_->CalculatePostGcWeightedAllocatedBytes();
uint64_t process_cpu_end_time = ProcessCpuNanoTime();
ScopedLogSeverity sls(LogSeverity::INFO);
// This can't be called from the Heap destructor below because it
@@ -335,9 +336,15 @@
<< " out of process CPU time " << PrettyDuration(process_cpu_time)
<< " (" << ratio << ")"
<< "\n";
- double weighted_allocated_bytes = heap_->GetWeightedAllocatedBytes() / process_cpu_time;
- LOG_STREAM(INFO) << "Weighted bytes allocated over CPU time: "
- << " (" << PrettySize(weighted_allocated_bytes) << ")"
+ double pre_gc_weighted_allocated_bytes =
+ heap_->GetPreGcWeightedAllocatedBytes() / process_cpu_time;
+ double post_gc_weighted_allocated_bytes =
+ heap_->GetPostGcWeightedAllocatedBytes() / process_cpu_time;
+
+ LOG_STREAM(INFO) << "Pre GC weighted bytes allocated over CPU time: "
+ << " (" << PrettySize(pre_gc_weighted_allocated_bytes) << ")";
+ LOG_STREAM(INFO) << "Post GC weighted bytes allocated over CPU time: "
+ << " (" << PrettySize(post_gc_weighted_allocated_bytes) << ")"
<< "\n";
}
diff --git a/tools/luci/config/cr-buildbucket.cfg b/tools/luci/config/cr-buildbucket.cfg
index 29cca39..8df8433 100644
--- a/tools/luci/config/cr-buildbucket.cfg
+++ b/tools/luci/config/cr-buildbucket.cfg
@@ -27,8 +27,6 @@
swarming {
hostname: "chromium-swarm.appspot.com"
builder_defaults {
- dimensions: "cores:8"
- dimensions: "cpu:x86-64"
dimensions: "pool:luci.art.ci"
service_account: "art-ci-builder@chops-service-accounts.iam.gserviceaccount.com"
execution_timeout_secs: 10800 # 3h
diff --git a/tools/luci/config/luci-milo.cfg b/tools/luci/config/luci-milo.cfg
index ce22293..60e8404 100644
--- a/tools/luci/config/luci-milo.cfg
+++ b/tools/luci/config/luci-milo.cfg
@@ -6,6 +6,7 @@
repo_url: "https://android.googlesource.com/platform/art"
refs: "refs/heads/master"
manifest_name: "REVISION"
+ include_experimental_builds: true
builders {
name: "buildbucket/luci.art.ci/angler-armv7-debug"