Bug 1782344 - Remove cache directory and configs from CCacheStats. r=firefox-build-system-reviewers,ahochheiden

The info is unused and not part of the ccache --print-stats output that
we're going to use shortly.

Differential Revision: https://phabricator.services.mozilla.com/D166631
This commit is contained in:
Mike Hommey 2023-01-13 00:47:56 +00:00
Родитель 708b0943a7
Коммит 2cef595382
2 изменённых файлов: 31 добавлений и 75 удалений

Просмотреть файл

@ -877,9 +877,11 @@ class CCacheStats(object):
("cache_max_size", "max cache size"), ("cache_max_size", "max cache size"),
] ]
DIRECTORY_DESCRIPTION = "cache directory" SKIP_LINES = (
PRIMARY_CONFIG_DESCRIPTION = "primary config" "cache directory",
SECONDARY_CONFIG_DESCRIPTION = "secondary config" "primary config",
"secondary config",
)
STATS_KEYS_4_4 = [ STATS_KEYS_4_4 = [
("stats_updated", "Summary/Stats updated"), ("stats_updated", "Summary/Stats updated"),
@ -938,6 +940,9 @@ class CCacheStats(object):
] ]
SKIP_KEYS_4_4 = [ SKIP_KEYS_4_4 = [
"Summary/Cache directory",
"Summary/Primary config",
"Summary/Secondary config",
"Summary/Uncacheable", "Summary/Uncacheable",
"Summary/Misses/Direct", "Summary/Misses/Direct",
"Summary/Misses/Preprocessed", "Summary/Misses/Preprocessed",
@ -946,10 +951,6 @@ class CCacheStats(object):
"Errors/Could not find compiler", "Errors/Could not find compiler",
] ]
DIRECTORY_DESCRIPTION_4_4 = "Summary/Cache directory"
PRIMARY_CONFIG_DESCRIPTION_4_4 = "Summary/Primary config"
SECONDARY_CONFIG_DESCRIPTION_4_4 = "Summary/Secondary config"
ABSOLUTE_KEYS = {"cache_files", "cache_size", "cache_max_size"} ABSOLUTE_KEYS = {"cache_files", "cache_size", "cache_max_size"}
FORMAT_KEYS = {"cache_size", "cache_max_size"} FORMAT_KEYS = {"cache_size", "cache_max_size"}
@ -960,9 +961,6 @@ class CCacheStats(object):
def __init__(self, output=None, is_version_4_4_or_newer=False): def __init__(self, output=None, is_version_4_4_or_newer=False):
"""Construct an instance from the output of ccache -s.""" """Construct an instance from the output of ccache -s."""
self._values = {} self._values = {}
self.cache_dir = ""
self.primary_config = ""
self.secondary_config = ""
if not output: if not output:
return return
@ -996,13 +994,6 @@ class CCacheStats(object):
subhead = "" subhead = ""
def _parse_line_4_4_plus(self, key, value): def _parse_line_4_4_plus(self, key, value):
if key.startswith(self.DIRECTORY_DESCRIPTION_4_4):
self.cache_dir = value
elif key.startswith(self.PRIMARY_CONFIG_DESCRIPTION_4_4):
self.primary_config = value
elif key.startswith(self.SECONDARY_CONFIG_DESCRIPTION_4_4):
self.secondary_config = value
else:
for seq in self.STATS_KEYS_4_4: for seq in self.STATS_KEYS_4_4:
stat_key = seq[0] stat_key = seq[0]
stat_description = seq[1] stat_description = seq[1]
@ -1019,9 +1010,7 @@ class CCacheStats(object):
else: else:
if key not in self.SKIP_KEYS_4_4: if key not in self.SKIP_KEYS_4_4:
raise ValueError( raise ValueError(
"Failed to parse ccache stats output: '{}' '{}'".format( "Failed to parse ccache stats output: '{}' '{}'".format(key, value)
key, value
)
) )
def _parse_human_format(self, output): def _parse_human_format(self, output):
@ -1032,24 +1021,13 @@ class CCacheStats(object):
def _parse_line(self, line): def _parse_line(self, line):
line = six.ensure_text(line) line = six.ensure_text(line)
if line.startswith(self.DIRECTORY_DESCRIPTION):
self.cache_dir = self._strip_prefix(line, self.DIRECTORY_DESCRIPTION)
elif line.startswith(self.PRIMARY_CONFIG_DESCRIPTION):
self.primary_config = self._strip_prefix(
line, self.PRIMARY_CONFIG_DESCRIPTION
)
elif line.startswith(self.SECONDARY_CONFIG_DESCRIPTION):
self.secondary_config = self._strip_prefix(
self._strip_prefix(line, self.SECONDARY_CONFIG_DESCRIPTION),
"(readonly)",
)
else:
for stat_key, stat_description in self.STATS_KEYS: for stat_key, stat_description in self.STATS_KEYS:
if line.startswith(stat_description): if line.startswith(stat_description):
raw_value = self._strip_prefix(line, stat_description) raw_value = self._strip_prefix(line, stat_description)
self._values[stat_key] = self._parse_value(raw_value) self._values[stat_key] = self._parse_value(raw_value)
break break
else: else:
if not line.startswith(self.SKIP_LINES):
raise ValueError("Failed to parse ccache stats output: %s" % line) raise ValueError("Failed to parse ccache stats output: %s" % line)
@staticmethod @staticmethod
@ -1113,7 +1091,6 @@ class CCacheStats(object):
def __sub__(self, other): def __sub__(self, other):
result = CCacheStats() result = CCacheStats()
result.cache_dir = self.cache_dir
for k, prefix in self.STATS_KEYS: for k, prefix in self.STATS_KEYS:
if k not in self._values and k not in other._values: if k not in self._values and k not in other._values:
@ -1133,11 +1110,6 @@ class CCacheStats(object):
LEFT_ALIGN = 34 LEFT_ALIGN = 34
lines = [] lines = []
if self.cache_dir:
lines.append(
"%s%s" % (self.DIRECTORY_DESCRIPTION.ljust(LEFT_ALIGN), self.cache_dir)
)
for stat_key, stat_description in self.STATS_KEYS: for stat_key, stat_description in self.STATS_KEYS:
if stat_key not in self._values: if stat_key not in self._values:
continue continue

Просмотреть файл

@ -405,7 +405,6 @@ Uncacheable:
def test_parse_zero_stats_message(self): def test_parse_zero_stats_message(self):
stats = CCacheStats(self.STAT0) stats = CCacheStats(self.STAT0)
self.assertEqual(stats.cache_dir, "/home/tlin/.ccache")
self.assertEqual(stats.hit_rates(), (0, 0, 0)) self.assertEqual(stats.hit_rates(), (0, 0, 0))
def test_hit_rate_of_diff_stats(self): def test_hit_rate_of_diff_stats(self):
@ -435,7 +434,6 @@ Uncacheable:
stats_diff = stat3 - stat2 stats_diff = stat3 - stat2
self.assertEqual( self.assertEqual(
str(stat3), str(stat3),
"cache directory /Users/tlin/.ccache\n"
"cache hit (direct) 12004\n" "cache hit (direct) 12004\n"
"cache hit (preprocessed) 1786\n" "cache hit (preprocessed) 1786\n"
"cache miss 26348\n" "cache miss 26348\n"
@ -454,7 +452,6 @@ Uncacheable:
) )
self.assertEqual( self.assertEqual(
str(stats_diff), str(stats_diff),
"cache directory /Users/tlin/.ccache\n"
"cache hit (direct) 10104\n" "cache hit (direct) 10104\n"
"cache hit (preprocessed) 1486\n" "cache hit (preprocessed) 1486\n"
"cache miss 23748\n" "cache miss 23748\n"
@ -478,7 +475,6 @@ Uncacheable:
stats_diff = stat5 - stat4 stats_diff = stat5 - stat4
self.assertEqual( self.assertEqual(
str(stat4), str(stat4),
"cache directory /Users/tlin/.ccache\n"
"cache hit (direct) 21039\n" "cache hit (direct) 21039\n"
"cache hit (preprocessed) 2315\n" "cache hit (preprocessed) 2315\n"
"cache miss 39370\n" "cache miss 39370\n"
@ -498,7 +494,6 @@ Uncacheable:
) )
self.assertEqual( self.assertEqual(
str(stat5), str(stat5),
"cache directory /Users/tlin/.ccache\n"
"cache hit (direct) 21039\n" "cache hit (direct) 21039\n"
"cache hit (preprocessed) 2315\n" "cache hit (preprocessed) 2315\n"
"cache miss 39372\n" "cache miss 39372\n"
@ -518,7 +513,6 @@ Uncacheable:
) )
self.assertEqual( self.assertEqual(
str(stats_diff), str(stats_diff),
"cache directory /Users/tlin/.ccache\n"
"cache hit (direct) 0\n" "cache hit (direct) 0\n"
"cache hit (preprocessed) 0\n" "cache hit (preprocessed) 0\n"
"cache miss 2\n" "cache miss 2\n"
@ -544,7 +538,6 @@ Uncacheable:
stats_diff = stat6 - stat3 stats_diff = stat6 - stat3
self.assertEqual( self.assertEqual(
str(stat6), str(stat6),
"cache directory /Users/tlin/.ccache\n"
"cache hit (direct) 319287\n" "cache hit (direct) 319287\n"
"cache hit (preprocessed) 125987\n" "cache hit (preprocessed) 125987\n"
"cache hit rate 37\n" "cache hit rate 37\n"
@ -570,7 +563,6 @@ Uncacheable:
) )
self.assertEqual( self.assertEqual(
str(stat3), str(stat3),
"cache directory /Users/tlin/.ccache\n"
"cache hit (direct) 12004\n" "cache hit (direct) 12004\n"
"cache hit (preprocessed) 1786\n" "cache hit (preprocessed) 1786\n"
"cache miss 26348\n" "cache miss 26348\n"
@ -589,7 +581,6 @@ Uncacheable:
) )
self.assertEqual( self.assertEqual(
str(stats_diff), str(stats_diff),
"cache directory /Users/tlin/.ccache\n"
"cache hit (direct) 307283\n" "cache hit (direct) 307283\n"
"cache hit (preprocessed) 124201\n" "cache hit (preprocessed) 124201\n"
"cache hit rate 37\n" "cache hit rate 37\n"
@ -618,7 +609,6 @@ Uncacheable:
stat7 = CCacheStats(self.STAT7) stat7 = CCacheStats(self.STAT7)
self.assertEqual( self.assertEqual(
str(stat7), str(stat7),
"cache directory /Users/tlin/.ccache\n"
"cache hit (direct) 27035\n" "cache hit (direct) 27035\n"
"cache hit (preprocessed) 13939\n" "cache hit (preprocessed) 13939\n"
"cache hit rate 39\n" "cache hit rate 39\n"
@ -642,7 +632,6 @@ Uncacheable:
stat8 = CCacheStats(self.STAT8) stat8 = CCacheStats(self.STAT8)
self.assertEqual( self.assertEqual(
str(stat8), str(stat8),
"cache directory /home/psimonyi/.ccache\n"
f"stats zero time {int(TIMESTAMP)}\n" f"stats zero time {int(TIMESTAMP)}\n"
f"stats zeroed {int(TIMESTAMP)}\n" f"stats zeroed {int(TIMESTAMP)}\n"
"cache hit (direct) 571\n" "cache hit (direct) 571\n"
@ -667,7 +656,6 @@ Uncacheable:
stat9 = CCacheStats(self.STAT9) stat9 = CCacheStats(self.STAT9)
self.assertEqual( self.assertEqual(
str(stat9), str(stat9),
"cache directory /Users/tlin/.ccache\n"
f"stats zero time {int(TIMESTAMP)}\n" f"stats zero time {int(TIMESTAMP)}\n"
f"stats zeroed {int(TIMESTAMP)}\n" f"stats zeroed {int(TIMESTAMP)}\n"
f"stats updated {int(TIMESTAMP2)}\n" f"stats updated {int(TIMESTAMP2)}\n"
@ -702,7 +690,6 @@ Uncacheable:
stat10 = CCacheStats(self.STAT10, True) stat10 = CCacheStats(self.STAT10, True)
self.assertEqual( self.assertEqual(
str(stat10), str(stat10),
"cache directory /home/suer/.ccache\n"
f"stats updated {int(TIMESTAMP)}\n" f"stats updated {int(TIMESTAMP)}\n"
"cache hit (direct) 197\n" "cache hit (direct) 197\n"
"cache hit (preprocessed) 719\n" "cache hit (preprocessed) 719\n"
@ -726,7 +713,6 @@ Uncacheable:
stat11 = CCacheStats(self.STAT11, True) stat11 = CCacheStats(self.STAT11, True)
self.assertEqual( self.assertEqual(
str(stat11), str(stat11),
"cache directory /home/suer/.ccache\n"
f"stats updated {int(TIMESTAMP)}\n" f"stats updated {int(TIMESTAMP)}\n"
"cache hit (direct) 0\n" "cache hit (direct) 0\n"
"cache hit (preprocessed) 0\n" "cache hit (preprocessed) 0\n"
@ -741,7 +727,6 @@ Uncacheable:
stat12 = CCacheStats(self.STAT12, True) stat12 = CCacheStats(self.STAT12, True)
self.assertEqual( self.assertEqual(
str(stat12), str(stat12),
"cache directory /home/suer/.ccache\n"
"stats updated 0\n" "stats updated 0\n"
"cache hit (direct) 0\n" "cache hit (direct) 0\n"
"cache hit (preprocessed) 0\n" "cache hit (preprocessed) 0\n"
@ -756,7 +741,6 @@ Uncacheable:
stat13 = CCacheStats(self.STAT13, True) stat13 = CCacheStats(self.STAT13, True)
self.assertEqual( self.assertEqual(
str(stat13), str(stat13),
"cache directory /Users/leebc/.ccache\n"
f"stats updated {int(TIMESTAMP)}\n" f"stats updated {int(TIMESTAMP)}\n"
"cache hit (direct) 280542\n" "cache hit (direct) 280542\n"
"cache hit (preprocessed) 0\n" "cache hit (preprocessed) 0\n"