]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
feat(tracing): Add more trace points
authorJoel Rosdahl <joel@rosdahl.net>
Mon, 16 Aug 2021 19:17:16 +0000 (21:17 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 16 Aug 2021 19:22:20 +0000 (21:22 +0200)
src/ccache.cpp
src/storage/Storage.cpp
src/storage/primary/PrimaryStorage.cpp

index bc52fee62a20f9a8d6617cbdcaccadde19064223..1d73e4dc0d6162c1fb9815b25e01b45672c8fc15 100644 (file)
@@ -2194,6 +2194,7 @@ do_cache_compilation(Context& ctx, const char* const* argv)
   result_key = *digest;
   if (ctx.config.direct_mode()) {
     ASSERT(manifest_key);
+    MTR_SCOPE("cache", "update_manifest");
     update_manifest_file(ctx, *manifest_key, *result_key);
   }
 
index 85c0a6da937fb00de2825a1226f27a65ce03f72c..7c2d0dff8762979bde25914477650a2c616bd720 100644 (file)
@@ -21,6 +21,7 @@
 #include <Checksum.hpp>
 #include <Config.hpp>
 #include <Logging.hpp>
+#include <MiniTrace.hpp>
 #include <TemporaryFile.hpp>
 #include <Util.hpp>
 #include <assertions.hpp>
@@ -229,6 +230,8 @@ Storage::finalize()
 nonstd::optional<std::string>
 Storage::get(const Digest& key, const core::CacheEntryType type)
 {
+  MTR_SCOPE("storage", "get");
+
   const auto path = primary.get(key, type);
   primary.increment_statistic(path ? core::Statistic::primary_storage_hit
                                    : core::Statistic::primary_storage_miss);
@@ -290,6 +293,8 @@ Storage::put(const Digest& key,
              const core::CacheEntryType type,
              const storage::EntryWriter& entry_writer)
 {
+  MTR_SCOPE("storage", "put");
+
   const auto path = primary.put(key, type, entry_writer);
   if (!path) {
     return false;
@@ -318,6 +323,8 @@ Storage::put(const Digest& key,
 void
 Storage::remove(const Digest& key, const core::CacheEntryType type)
 {
+  MTR_SCOPE("storage", "remove");
+
   primary.remove(key, type);
   remove_from_secondary_storage(key);
 }
@@ -452,6 +459,8 @@ Storage::get_backend(SecondaryStorageEntry& entry,
 nonstd::optional<std::pair<std::string, bool>>
 Storage::get_from_secondary_storage(const Digest& key)
 {
+  MTR_SCOPE("secondary_storage", "get");
+
   for (const auto& entry : m_secondary_storages) {
     auto backend = get_backend(*entry, key, "getting from", false);
     if (!backend) {
@@ -491,6 +500,8 @@ Storage::put_in_secondary_storage(const Digest& key,
                                   const std::string& value,
                                   bool only_if_missing)
 {
+  MTR_SCOPE("secondary_storage", "put");
+
   for (const auto& entry : m_secondary_storages) {
     auto backend = get_backend(*entry, key, "putting in", true);
     if (!backend) {
@@ -518,6 +529,8 @@ Storage::put_in_secondary_storage(const Digest& key,
 void
 Storage::remove_from_secondary_storage(const Digest& key)
 {
+  MTR_SCOPE("secondary_storage", "remove");
+
   for (const auto& entry : m_secondary_storages) {
     auto backend = get_backend(*entry, key, "removing from", true);
     if (!backend) {
index 175285135093c84e1a90f9fa2f18c4622e310b57..bbe4d53f1e9c6dfd49dceb7ac06c047630ef4f20 100644 (file)
@@ -181,6 +181,8 @@ PrimaryStorage::finalize()
 nonstd::optional<std::string>
 PrimaryStorage::get(const Digest& key, const core::CacheEntryType type) const
 {
+  MTR_SCOPE("primary_storage", "get");
+
   const auto cache_file = look_up_cache_file(key, type);
   if (!cache_file.stat) {
     LOG("No {} in primary storage", key.to_string());
@@ -200,6 +202,8 @@ PrimaryStorage::put(const Digest& key,
                     const core::CacheEntryType type,
                     const storage::EntryWriter& entry_writer)
 {
+  MTR_SCOPE("primary_storage", "put");
+
   const auto cache_file = look_up_cache_file(key, type);
   switch (type) {
   case core::CacheEntryType::manifest:
@@ -246,6 +250,8 @@ PrimaryStorage::put(const Digest& key,
 void
 PrimaryStorage::remove(const Digest& key, const core::CacheEntryType type)
 {
+  MTR_SCOPE("primary_storage", "remove");
+
   const auto cache_file = look_up_cache_file(key, type);
   if (cache_file.stat) {
     Util::unlink_safe(cache_file.path);