From 87831fa19e241803f93556cbeaad153e6ba89b6c Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 29 Apr 2025 12:29:32 +0200 Subject: [PATCH] hardlink: fix performance regression (inefficient signal evaluation) During work on better verbose output, I found a regression between v2.40 and v2.41 (and v2.42). In the new version, hardlink is 3-4 times slower. The problem is in the function where we verify signals. It calls the function signal() even though no signal is delivered. It's called in code loops where hardlink scans files, making it a performance-sensitive area. Another significant performance improvement is using an inline function for handle_interrupt(). This simple patch improves hardlink performance by 10 times. Fixes: http://github.com/util-linux/util-linux/commit/1453200e22dd4ec858be027653c167225f2fb358 Signed-off-by: Karel Zak --- misc-utils/hardlink.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/misc-utils/hardlink.c b/misc-utils/hardlink.c index 7e7beffdd..d32d0c6da 100644 --- a/misc-utils/hardlink.c +++ b/misc-utils/hardlink.c @@ -433,9 +433,11 @@ static void print_stats(void) /** * handle_interrupt - Handle a signal */ -static void handle_interrupt(void) +static inline void handle_interrupt(void) { switch (last_signal) { + case 0: + break; case SIGUSR1: print_stats(); putchar('\n'); -- 2.47.2