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
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py
index b88171f..9c07b50 100755
--- a/tools/releasetools/build_image.py
+++ b/tools/releasetools/build_image.py
@@ -297,7 +297,7 @@
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)