From c3d408e3c180327bfbc88e9147e25bb793071bf6 Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Mon, 29 Oct 2018 13:16:09 -0700 Subject: [PATCH 1/2] build_image tune right-size image To more quickly settle on a no free space result, recognize that there is roughly 1/58.5 overhead managing the free space pool as determined experimentally. This algorithm carries with it some risk of being sensitive to any alterations in ext4. This also addresses the issue of a much larger apparent free space available calculated on the sample pass when deploying ext4 dedupe, and resolves the poorer estimation that happens without accounting for the overhead. The alternative of adding a second pass works to a similar, and likely more comforting algorithm and result. But doing so adds a minute to the typical incremental build time, or +50% to the time it takes to determine ext4 right sized images. Test: manual Bug: 111302946 Change-Id: Id5ae6645b9aa2d036e6fefe2fb17672e8f8ef6f0 --- tools/releasetools/build_image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py index b88171f28d..9c07b50ce9 100755 --- a/tools/releasetools/build_image.py +++ b/tools/releasetools/build_image.py @@ -297,7 +297,7 @@ def BuildImage(in_dir, prop_dict, out_file, target_out=None): logger.info( "Not worth reducing image %d <= %d.", free_size, reserved_size) else: - size -= free_size + size -= free_size + (free_size // 59) size += reserved_size if block_size <= 4096: size = common.RoundUpTo4K(size) From f0cef8d8bfacd6776e3fa894f21a0876e414370d Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Mon, 29 Oct 2018 10:55:06 -0700 Subject: [PATCH 2/2] build_image setup ext4 dedupe on more images. Add ext4 dedupe to system_other, product, product_services, odm and oem images. Experimental savings without any other configuration changes was 0%, .75%, 3.4% respectively for the raw image file size for the first three. Test: manual Bug: 111302946 Change-Id: Ia8fb5696151acad59bb144ea93f2c2ddac962bbd --- tools/releasetools/build_image.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py index 9c07b50ce9..dc882f2765 100755 --- a/tools/releasetools/build_image.py +++ b/tools/releasetools/build_image.py @@ -573,6 +573,7 @@ def ImagePropFromGlobalDict(glob_dict, mount_point): if not copy_prop("system_journal_size", "journal_size"): d["journal_size"] = "0" copy_prop("system_verity_block_device", "verity_block_device") + copy_prop("ext4_share_dup_blocks", "ext4_share_dup_blocks") copy_prop("system_squashfs_compressor", "squashfs_compressor") copy_prop("system_squashfs_compressor_opt", "squashfs_compressor_opt") copy_prop("system_squashfs_block_size", "squashfs_block_size") @@ -623,6 +624,7 @@ def ImagePropFromGlobalDict(glob_dict, mount_point): if not copy_prop("product_journal_size", "journal_size"): d["journal_size"] = "0" copy_prop("product_verity_block_device", "verity_block_device") + copy_prop("ext4_share_dup_blocks", "ext4_share_dup_blocks") copy_prop("product_squashfs_compressor", "squashfs_compressor") copy_prop("product_squashfs_compressor_opt", "squashfs_compressor_opt") copy_prop("product_squashfs_block_size", "squashfs_block_size") @@ -643,6 +645,7 @@ def ImagePropFromGlobalDict(glob_dict, mount_point): if not copy_prop("product_services_journal_size", "journal_size"): d["journal_size"] = "0" copy_prop("product_services_verity_block_device", "verity_block_device") + copy_prop("ext4_share_dup_blocks", "ext4_share_dup_blocks") copy_prop("product_services_squashfs_compressor", "squashfs_compressor") copy_prop("product_services_squashfs_compressor_opt", "squashfs_compressor_opt") @@ -665,6 +668,7 @@ def ImagePropFromGlobalDict(glob_dict, mount_point): if not copy_prop("odm_journal_size", "journal_size"): d["journal_size"] = "0" copy_prop("odm_verity_block_device", "verity_block_device") + copy_prop("ext4_share_dup_blocks", "ext4_share_dup_blocks") copy_prop("odm_squashfs_compressor", "squashfs_compressor") copy_prop("odm_squashfs_compressor_opt", "squashfs_compressor_opt") copy_prop("odm_squashfs_block_size", "squashfs_block_size") @@ -680,6 +684,7 @@ def ImagePropFromGlobalDict(glob_dict, mount_point): if not copy_prop("oem_journal_size", "journal_size"): d["journal_size"] = "0" copy_prop("oem_extfs_inode_count", "extfs_inode_count") + copy_prop("ext4_share_dup_blocks", "ext4_share_dup_blocks") if not copy_prop("oem_extfs_rsv_pct", "extfs_rsv_pct"): d["extfs_rsv_pct"] = "0" d["partition_name"] = mount_point