From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id 1F1703856DF9 for ; Mon, 9 May 2022 22:58:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1F1703856DF9 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from reform (deer0x07.wildebeest.org [172.31.17.137]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id D125930007D1; Tue, 10 May 2022 00:57:58 +0200 (CEST) Received: by reform (Postfix, from userid 1000) id B23402E8237E; Tue, 10 May 2022 00:57:58 +0200 (CEST) From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: Mark Wielaard Subject: [PATCH 3/3] debuginfod: update mtime of interval_path as early as possible Date: Tue, 10 May 2022 00:57:23 +0200 Message-Id: <20220509225723.96902-4-mark@klomp.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220509225723.96902-1-mark@klomp.org> References: <20220509225723.96902-1-mark@klomp.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 May 2022 22:58:01 -0000 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 --- 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 + + * debuginfod-client.c (debuginfod_clean_cache): Move utime call to + before fts traversal. + 2022-05-09 Mark Wielaard * 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