Skip to content

Commit

Permalink
Bug 1782344 - Avoid the duplication of stats_zeroed in CCacheStats se…
Browse files Browse the repository at this point in the history
…rialization. r=firefox-build-system-reviewers,ahochheiden

Differential Revision: https://phabricator.services.mozilla.com/D166633
  • Loading branch information
glandium committed Jan 13, 2023
1 parent b4de983 commit 82477fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 8 additions & 2 deletions python/mozbuild/mozbuild/controller/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,8 +842,7 @@ class CCacheStats(object):
STATS_KEYS = [
# (key, description)
# Refer to stats.c in ccache project for all the descriptions.
("stats_zeroed", "stats zero time"), # Old name prior to ccache 3.4
("stats_zeroed", "stats zeroed"),
("stats_zeroed", ("stats zeroed", "stats zero time")),
("stats_updated", "stats updated"),
("cache_hit_direct", "cache hit (direct)"),
("cache_hit_preprocessed", "cache hit (preprocessed)"),
Expand Down Expand Up @@ -1032,6 +1031,10 @@ def _parse_line(self, line):

@staticmethod
def _strip_prefix(line, prefix):
if isinstance(prefix, tuple):
for p in prefix:
line = CCacheStats._strip_prefix(line, p)
return line
return line[len(prefix) :].strip() if line.startswith(prefix) else line

@staticmethod
Expand Down Expand Up @@ -1121,6 +1124,9 @@ def __str__(self):
else:
value = "%8u" % value

if isinstance(stat_description, tuple):
stat_description = stat_description[0]

lines.append("%s%s" % (stat_description.ljust(LEFT_ALIGN), value))

return "\n".join(lines)
Expand Down
2 changes: 0 additions & 2 deletions python/mozbuild/mozbuild/test/controller/test_ccachestats.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,6 @@ def test_stats_version34(self):
stat8 = CCacheStats(self.STAT8)
self.assertEqual(
str(stat8),
f"stats zero time {int(TIMESTAMP)}\n"
f"stats zeroed {int(TIMESTAMP)}\n"
"cache hit (direct) 571\n"
"cache hit (preprocessed) 1203\n"
Expand All @@ -656,7 +655,6 @@ def test_stats_version35(self):
stat9 = CCacheStats(self.STAT9)
self.assertEqual(
str(stat9),
f"stats zero time {int(TIMESTAMP)}\n"
f"stats zeroed {int(TIMESTAMP)}\n"
f"stats updated {int(TIMESTAMP2)}\n"
"cache hit (direct) 80147\n"
Expand Down

0 comments on commit 82477fe

Please sign in to comment.