public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: elfutils-devel@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [PATCH 3/3] debuginfod: update mtime of interval_path as early as possible
Date: Tue, 10 May 2022 00:57:23 +0200	[thread overview]
Message-ID: <20220509225723.96902-4-mark@klomp.org> (raw)
In-Reply-To: <20220509225723.96902-1-mark@klomp.org>

Call utime on interval_path file as soon as the thread is committed to
cleanup the cache files. This will prevent other threads trying to
also commit to cleaning the cache files. Having multiple threads try
to clean the cache simultaniously doesn't improve cleanup speed
because the threads will try to delete the files in the same order.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 debuginfod/ChangeLog           | 5 +++++
 debuginfod/debuginfod-client.c | 7 +++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog
index c9aa4fcf..209a22a7 100644
--- a/debuginfod/ChangeLog
+++ b/debuginfod/ChangeLog
@@ -1,3 +1,8 @@
+2022-05-09  Mark Wielaard  <mark@klomp.org>
+
+	* debuginfod-client.c (debuginfod_clean_cache): Move utime call to
+	before fts traversal.
+
 2022-05-09  Mark Wielaard  <mark@klomp.org>
 
 	* debuginfod-client.c (debuginfod_init_cache): Remove.
diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c
index 6bdf1908..b7b65aff 100644
--- a/debuginfod/debuginfod-client.c
+++ b/debuginfod/debuginfod-client.c
@@ -297,6 +297,11 @@ debuginfod_clean_cache(debuginfod_client *c,
     /* Interval has not passed, skip cleaning.  */
     return 0;
 
+  /* Update timestamp representing when the cache was last cleaned.
+     Do it at the start to reduce the number of threads trying to do a
+     cleanup simultaniously.  */
+  utime (interval_path, NULL);
+
   /* Read max unused age value from config file.  */
   rc = debuginfod_config_cache(max_unused_path,
 			       cache_default_max_unused_age_s, &st);
@@ -351,8 +356,6 @@ debuginfod_clean_cache(debuginfod_client *c,
   fts_close (fts);
   regfree (&re);
 
-  /* Update timestamp representing when the cache was last cleaned.  */
-  utime (interval_path, NULL);
   return 0;
 }
 
-- 
2.30.2


  parent reply	other threads:[~2022-05-09 22:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-09 22:57 Optimize debuginfod-client cache lookup/cleanup a little Mark Wielaard
2022-05-09 22:57 ` [PATCH 1/3] debuginfod: Make sure debuginfod_config_cache always returns valid stat Mark Wielaard
2022-05-09 22:57 ` [PATCH 2/3] debuginfod: Remove debuginfod_init_cache Mark Wielaard
2022-05-09 22:57 ` Mark Wielaard [this message]
2022-05-14 22:36 ` Optimize debuginfod-client cache lookup/cleanup a little Mark Wielaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220509225723.96902-4-mark@klomp.org \
    --to=mark@klomp.org \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).