]> git.baikalelectronics.ru Git - uboot.git/commit
lzma: Fix decompression speed regression
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Wed, 5 Jul 2023 08:34:26 +0000 (10:34 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 14 Jul 2023 19:21:08 +0000 (15:21 -0400)
commit2ffb640d7062b003d7eaeaab710c62f36cc4c053
tree3ba2c8b3a524d132d8bfb5c252a084e41cd138e7
parentc471fbf558e16173ea9546101fa130b487f926b8
lzma: Fix decompression speed regression

Uncompressing a 1.7Mbytes FIT image on U-boot 2023.04 takes
approx 7s on a powerpc 8xx.
The same on U-boot 2023.07-rc6 takes approx 28s unless watchdog
is disabled.

During that decompression, LzmaDec_DecodeReal() calls schedule
1.6 million times, that is every 4µs in average.

In the past it used to be a call to WATCHDOG_RESET() which was
just calling hw_watchdog_reset().

But the combination of commit fbf631445b9 ("cyclic: Use schedule()
instead of WATCHDOG_RESET()") and commit f67b0ab35cf ("watchdog:
mpc8xxx: Make it generic") results in an heavier processing.

However, there is absolutely no point in calling schedule() that
often.

By moving and keeping only one call to schedule() in the main
loop the number of calls is reduced to 1.2 million which is still
too much. So add logic to only call schedule every 1024 times.
That leads to a call to schedule approx every 6ms which is still
far enough to entertain the watchdog which has a 1s timeout on
powerpc 8xx.

powerpc 8xx being one of the slowest targets we have today in
U-boot, and most other watchdogs having a timeout of one minutes
instead of one second like the 8xx, this fix should not have
negative impact on other targets.

Fixes: fbf631445b9 ("cyclic: Use schedule() instead of WATCHDOG_RESET()")
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Simon Glass <sjg@chromium.org>
lib/lzma/LzmaDec.c