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 84269384F01E for ; Mon, 9 May 2022 22:57:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 84269384F01E 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 60CDE3000599 for ; Tue, 10 May 2022 00:57:51 +0200 (CEST) Received: by reform (Postfix, from userid 1000) id A22A62E8237E; Tue, 10 May 2022 00:57:50 +0200 (CEST) From: Mark Wielaard To: elfutils-devel@sourceware.org Subject: Optimize debuginfod-client cache lookup/cleanup a little Date: Tue, 10 May 2022 00:57:20 +0200 Message-Id: <20220509225723.96902-1-mark@klomp.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, 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:57:55 -0000 Hi, debuginfod-client would try to create the cache config files twice, once through debuginfod_init_cache, which was always called before the debuginfod_clean_cache check. Which called debuginfod_config_cache which also tried to create the config files when they didn't exist yet. debuginfod_config_cache however had a small bug that meant it would not provide a valid struct stat if the config file didn't exist yet. The first patch fixes that: [PATCH 1/3] debuginfod: Make sure debuginfod_config_cache always returns valid stat Then the second patch removes debuginfod_init_cache which saves two stat calls (but introduces a new mkdir call). [PATCH 2/3] debuginfod: Remove debuginfod_init_cache Finally as soon as debuginfod_clean_cache commits to clean the cache dir we immediately update the mtime of the interval config file so other threads will not try to simultaniously also try to clean up the cache dir. Because that is just duplicate work. [PATCH 3/3] debuginfod: update mtime of interval_path as early as possible Cheers, Mark