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
This commit is contained in:
Mark Salyzyn 2018-10-29 13:16:09 -07:00
parent 89fe71180b
commit c3d408e3c1

View file

@ -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)