]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hardlink: fix performance regression (inefficient signal evaluation)
authorKarel Zak <kzak@redhat.com>
Tue, 29 Apr 2025 10:29:32 +0000 (12:29 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 19 Jun 2025 08:28:45 +0000 (10:28 +0200)
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 <kzak@redhat.com>
(cherry picked from commit 87831fa19e241803f93556cbeaad153e6ba89b6c)

misc-utils/hardlink.c

index 1c15266e837c39f9e31176aeeea282e164a87899..218360a0bebcc8b72214906dc4d088dc8166a0d7 100644 (file)
@@ -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');