From 427fea8b493f4c6e1fe34a3992da61e0401c7c1c Mon Sep 17 00:00:00 2001 From: Daniel Zheng Date: Wed, 15 May 2024 11:14:11 -0700 Subject: [PATCH 1/2] Add build configs for wearable tunables Low memory devices place special emphasis on memory constraints and cpu utilization. We want to expose a set of build configurations that allow these devices to fine tune resource usage during OTA installation. Our strategy will be the following. 1. For any tunable needed in first stage init, read the .ro prop during ota installation, propogate the configuration to SnapshotUpdateStatus proto, then read the property from /metadata upon first reboot (since .ro properties are not available here) 2. For tunables which aren't needed until second stage init, read the .ro prop directly. This first CL will just add the build configurations to the build system. Subsequent CL's will forward the configs to protobufs and snapuserd daemon Bug: 332255580 Test: th Change-Id: I31b36b42f8fba997c772fe1a4ba99b17128b3eca --- target/product/virtual_ab_ota/vabc_features.mk | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/target/product/virtual_ab_ota/vabc_features.mk b/target/product/virtual_ab_ota/vabc_features.mk index 3f484e4f3e..1219763b0d 100644 --- a/target/product/virtual_ab_ota/vabc_features.mk +++ b/target/product/virtual_ab_ota/vabc_features.mk @@ -34,6 +34,21 @@ PRODUCT_VENDOR_PROPERTIES += ro.virtual_ab.userspace.snapshots.enabled=true PRODUCT_VENDOR_PROPERTIES += ro.virtual_ab.io_uring.enabled=true PRODUCT_VENDOR_PROPERTIES += ro.virtual_ab.compression.xor.enabled=true PRODUCT_VENDOR_PROPERTIES += ro.virtual_ab.batch_writes=true +# Low memory device configurations. If memory usage and cpu utilization is +# a bottleneck during OTA, the below configurations can be added to a +# device's .mk file improve performance for low mem devices. Disabling +# ro.virtual_ab.compression.xor.enabled and ro.virtual_ab.io_uring.enabled +# is also recommended +# +# PRODUCT_VENDOR_PROPERTIES += ro.virtual_ab.o_direct.enabled=true +# PRODUCT_VENDOR_PROPERTIES += ro.virtual_ab.merge_thread_priority=19 +# PRODUCT_VENDOR_PROPERTIES += ro.virtual_ab.worker_thread_priority=0 +# PRODUCT_VENDOR_PROPERTIES += ro.virtual_ab.num_worker_threads=3 +# PRODUCT_VENDOR_PROPERTIES += ro.virtual_ab.num_merge_threads=1 +# PRODUCT_VENDOR_PROPERTIES += ro.virtual_ab.num_verify_threads=1 +# PRODUCT_VENDOR_PROPERTIES += ro.virtual_ab.cow_op_merge_size=16 +# PRODUCT_VENDOR_PROPERTIES += ro.virtual_ab.verify_threshold_size=1073741824 +# PRODUCT_VENDOR_PROPERTIES += ro.virtual_ab.verify_block_size=1048576 # Enabling this property, will improve OTA install time # but will use an additional CPU core From 60922a45efb1a07e0b7a992c27b3a918b4779292 Mon Sep 17 00:00:00 2001 From: Daniel Zheng Date: Wed, 15 May 2024 14:06:24 -0700 Subject: [PATCH 2/2] ota_from_target_files: allow cow version override With our version compatibility check, overriding our cow version no longer works. Updating this check to only apply if a command line vabc_cow_version is not specified. NOTE: the ota may not successfully apply, depending on device if we override the cow version Test: th Change-Id: Ibbed6cf94cc2e91597d0c249dc8ade314b8341a2 --- tools/releasetools/ota_from_target_files.py | 38 +++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py index 432ea199bb..5a024cec54 100755 --- a/tools/releasetools/ota_from_target_files.py +++ b/tools/releasetools/ota_from_target_files.py @@ -914,12 +914,13 @@ def GenerateAbOtaPackage(target_file, output_file, source_file=None): # and install time performance. All OTA's with # both the source build and target build with VIRTUAL_AB_COW_VERSION = 3 # can support the new format. Otherwise, fallback on older versions - if not source_info.vabc_cow_version or not target_info.vabc_cow_version: - logger.info("Source or Target doesn't have VABC_COW_VERSION specified, default to version 2") - OPTIONS.vabc_cow_version = 2 - elif source_info.vabc_cow_version != target_info.vabc_cow_version: - logger.info("Source and Target have different cow VABC_COW_VERSION specified, default to minimum version") - OPTIONS.vabc_cow_version = min(source_info.vabc_cow_version, target_info.vabc_cow_version) + if not OPTIONS.vabc_cow_version: + if not source_info.vabc_cow_version or not target_info.vabc_cow_version: + logger.info("Source or Target doesn't have VABC_COW_VERSION specified, default to version 2") + OPTIONS.vabc_cow_version = 2 + elif source_info.vabc_cow_version != target_info.vabc_cow_version: + logger.info("Source and Target have different cow VABC_COW_VERSION specified, default to minimum version") + OPTIONS.vabc_cow_version = min(source_info.vabc_cow_version, target_info.vabc_cow_version) # Virtual AB Compression was introduced in Androd S. # Later, we backported VABC to Android R. But verity support was not @@ -933,19 +934,20 @@ def GenerateAbOtaPackage(target_file, output_file, source_file=None): assert "ab_partitions" in OPTIONS.info_dict, \ "META/ab_partitions.txt is required for ab_update." source_info = None - if not target_info.vabc_cow_version: + if not OPTIONS.vabc_cow_version: + if not target_info.vabc_cow_version: + OPTIONS.vabc_cow_version = 2 + elif target_info.vabc_cow_version >= "3" and target_info.vendor_api_level < 35: + logger.warning( + "This full OTA is configured to use VABC cow version" + " 3 which is supported since" + " Android API level 35, but device is " + "launched with {} . If this full OTA is" + " served to a device running old build, OTA might fail due to " + "unsupported vabc cow version. For safety, version 2 is used because " + "it's supported since day 1.".format( + target_info.vendor_api_level)) OPTIONS.vabc_cow_version = 2 - elif target_info.vabc_cow_version >= "3" and target_info.vendor_api_level < 35: - logger.warning( - "This full OTA is configured to use VABC cow version" - " 3 which is supported since" - " Android API level 35, but device is " - "launched with {} . If this full OTA is" - " served to a device running old build, OTA might fail due to " - "unsupported vabc cow version. For safety, version 2 is used because " - "it's supported since day 1.".format( - target_info.vendor_api_level)) - OPTIONS.vabc_cow_version = 2 if OPTIONS.vabc_compression_param is None and vabc_compression_param: minimum_api_level_required = VABC_COMPRESSION_PARAM_SUPPORT[ vabc_compression_param]