Bug 1309657 - Update ccache stats parser for version 3.3. draft
authorTing-Yu Lin <tlin@mozilla.com>
Thu, 13 Oct 2016 11:20:58 +0800
changeset 424605 89d3ef5a7fb753e0f3225c04cf62fa6fb7926e35
parent 423604 7ae377917236b7e6111146aa9fb4c073c0efc7f4
child 533719 3761a9f6c870b7d61ccf89dac0ee1e4379ddc12b
push id32206
push userbmo:tlin@mozilla.com
push dateThu, 13 Oct 2016 03:58:11 +0000
bugs1309657
milestone52.0a1
Bug 1309657 - Update ccache stats parser for version 3.3. ccache 3.3 added two fields in the status. 1. "cache hit rate" https://github.com/ccache/ccache/issues/94 2. "cleanups performed" https://github.com/ccache/ccache/commit/0769ea3630efd6315303f7325fc16d73a0ef1a4d We just teach the parser the two fields. Nothing else. MozReview-Commit-ID: 9kZrDrpCopd
python/mozbuild/mozbuild/controller/building.py
python/mozbuild/mozbuild/test/controller/test_ccachestats.py
--- a/python/mozbuild/mozbuild/controller/building.py
+++ b/python/mozbuild/mozbuild/controller/building.py
@@ -475,16 +475,17 @@ class CCacheStats(object):
     of the captured stats.
 
     """
     STATS_KEYS = [
         # (key, description)
         # Refer to stats.c in ccache project for all the descriptions.
         ('cache_hit_direct', 'cache hit (direct)'),
         ('cache_hit_preprocessed', 'cache hit (preprocessed)'),
+        ('cache_hit_rate', 'cache hit rate'),
         ('cache_miss', 'cache miss'),
         ('link', 'called for link'),
         ('preprocessing', 'called for preprocessing'),
         ('multiple', 'multiple source files'),
         ('stdout', 'compiler produced stdout'),
         ('no_output', 'compiler produced no output'),
         ('empty_output', 'compiler produced empty output'),
         ('failed', 'compile failed'),
@@ -497,16 +498,17 @@ class CCacheStats(object):
         ('unsupported_lang', 'unsupported source language'),
         ('compiler_check_failed', 'compiler check failed'),
         ('autoconf', 'autoconf compile/link'),
         ('unsupported_compiler_option', 'unsupported compiler option'),
         ('out_stdout', 'output to stdout'),
         ('out_device', 'output to a non-regular file'),
         ('no_input', 'no input file'),
         ('bad_extra_file', 'error hashing extra file'),
+        ('num_cleanups', 'cleanups performed'),
         ('cache_files', 'files in cache'),
         ('cache_size', 'cache size'),
         ('cache_max_size', 'max cache size'),
     ]
 
     DIRECTORY_DESCRIPTION = "cache directory"
     PRIMARY_CONFIG_DESCRIPTION = "primary config"
     SECONDARY_CONFIG_DESCRIPTION = "secondary config      (readonly)"
--- a/python/mozbuild/mozbuild/test/controller/test_ccachestats.py
+++ b/python/mozbuild/mozbuild/test/controller/test_ccachestats.py
@@ -119,16 +119,44 @@ class TestCcacheStats(unittest.TestCase)
     autoconf compile/link               3669
     unsupported compiler option          187
     no input file                       1711
     files in cache                     17411
     cache size                           6.0 GB
     max cache size                       6.0 GB
     """
 
+    STAT6 = """
+    cache directory                     /Users/tlin/.ccache
+    primary config                      /Users/tlin/.ccache/ccache.conf
+    secondary config      (readonly)    /usr/local/Cellar/ccache/3.3.2/etc/ccache.conf
+    cache hit (direct)                319287
+    cache hit (preprocessed)          125987
+    cache miss                        749959
+    cache hit rate                     37.25 %
+    called for link                    87978
+    called for preprocessing          418591
+    multiple source files               1861
+    compiler produced no output          122
+    compiler produced empty output       174
+    compile failed                     14330
+    ccache internal error                  1
+    preprocessor error                  9459
+    can't use precompiled header           4
+    bad compiler arguments              2077
+    unsupported source language        18195
+    autoconf compile/link              51485
+    unsupported compiler option          322
+    no input file                     309538
+    cleanups performed                     1
+    files in cache                     17358
+    cache size                          15.4 GB
+    max cache size                      17.2 GB
+    """
+
     def test_parse_garbage_stats_message(self):
         self.assertRaises(ValueError, CCacheStats, self.STAT_GARBAGE)
 
     def test_parse_zero_stats_message(self):
         stats = CCacheStats(self.STAT0)
         self.assertEqual(stats.cache_dir, "/home/tlin/.ccache")
         self.assertEqual(stats.hit_rates(), (0, 0, 0))
 
@@ -163,10 +191,18 @@ class TestCcacheStats(unittest.TestCase)
     def test_cache_size_shrinking(self):
         stat4 = CCacheStats(self.STAT4)
         stat5 = CCacheStats(self.STAT5)
         stats_diff = stat5 - stat4
         self.assertTrue(stat4)
         self.assertTrue(stat5)
         self.assertTrue(stats_diff)
 
+    def test_stats_version33(self):
+        stat3 = CCacheStats(self.STAT3)
+        stat6 = CCacheStats(self.STAT6)
+        stats_diff = stat6 - stat3
+        self.assertTrue(stat6)
+        self.assertTrue(stat3)
+        self.assertTrue(stats_diff)
+
 if __name__ == '__main__':
     main()