Skip to contentSkip to conversation

cache: Emit load progress only at integer percentage boundaries

PATCH New [email protected] 1 participant 1 message Sep 23

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cache: Emit load progress only at integer percentage boundaries

From: Etienne Cordonnier <[email protected]>

The check added in bdd7813d8 ("Show the user progress when loading the cache") was meant to fire events only on whole percentage boundaries, which Python 2's integer division provided. Since the move to Python 3, "/" returns a float that increases on every cache entry, so a progress event is sent for each of the ~5,000 entries in a typical cached parse. Use floor division to restore the intended ~100 events.

Cached parse-only startup improved from 5.03s to 4.54s on average across three alternating runs each.

AI-Generated: Uses OpenAI Codex

---
 lib/bb/cache.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/cache.py +1 -1
index 2361c5684..24bde62a9 100644
@@ -736,7 +736,7 @@ class MulticonfigCache(Mapping):
                 # we might have calculated incorrect total size because a file
                 # might've been written out just after we checked its size
                 cachesize = current_progress
-            current_percent = 100 * current_progress / cachesize
+            current_percent = 100 * current_progress // cachesize
             if current_percent > previous_percent:
                 previous_percent = current_percent
                 bb.event.fire(bb.event.CacheLoadProgress(current_progress, cachesize),
Signature · 1 line
2.43.0