Speeding up sbuild / PPA / distro builds (optiPNG)

Michał Sawicz michal.sawicz at canonical.com
Fri Jun 21 21:22:47 UTC 2013

Hey all,

There are times, when you *really* want for a package to build
already... It's almost there... the tests passed... the package is
built! And then optiPNG kicks in and takes 33 minutes ([1] vs. [2]) to

For unity8 that time was Tuesday night - it took some 25 minutes to
build the package on armhf and then pkgbinarymangler went ahead and
optimized the PNGs, which on a pandaboard took another half an hour.

On the plus side, this saved us 571kB in image size (or 9.4%).

But it's done for every package build, for each architecture separately
- the time sacrifice was just too big. It doesn't have to be!
See [3], which is:

$ optipng -o7 `find -name *png`

Because of -o7 (slowest) we saved another 112kB, or 2%. Then, added
export NO_PNG_PKG_MANGLE=1 to debian/rules and voilá! that's a _lot_ of
our pandas' time saved.

The drawback is that you need to remember to optimize the PNGs when
adding new ones or changing them. It could be possible to mark the
already-optimized PNGs somehow (tagging comes to mind, but that would
usually survive modifications), so that we don't re-optimize them again
during pkgbinarymangle? We could probably use some manifest, but that
would mean shipping it in the binary package (is it possible to ship in
DEBIAN/ so that it isn't installed anywhere?), and we'd need to make
sure modified files are not omitted, so some kind of checksum would need
to be used - still much faster than optipng, probably...

Anyway! I recommend to all and everyone to consider pre-optimizing their
PNGs (that might be the case for other image formats / files as well,
not sure what else pkgbinarymangler [4] does). It might save you time,
the builders time, save power, trees, babies, baby pandas and bunnies.
For real!

[1] https://launchpad.net/~phablet-team/+archive/ppa/+build/4729025
[2] https://launchpad.net/~phablet-team/+archive/ppa/+build/4735955
[3] https://code.launchpad.net/~saviq/unity/8.optimize-pngs/+merge/170619
[4] https://launchpad.net/pkgbinarymangler/

Have a good weekend, people!
Michał (Saviq) Sawicz <michal.sawicz at canonical.com>
Canonical Services Ltd.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 899 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ubuntu.com/archives/ubuntu-devel/attachments/20130621/3fe52186/attachment.pgp>

More information about the ubuntu-devel mailing list