]> git.ipfire.org Git - pakfire.git/commitdiff
compress: Enable parallel compression for Zstandard if available
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 16 Mar 2023 09:04:33 +0000 (09:04 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 16 Mar 2023 09:04:33 +0000 (09:04 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/compress.c

index 43b19afabbe93e2f04b753938945bb2a3d9a673c..dbe470d59aa9a346e3802d36704815528e874e9b 100644 (file)
@@ -1148,6 +1148,27 @@ int pakfire_compress_create_archive(struct pakfire* pakfire, struct archive** ar
                                        goto ERROR;
                                }
                        }
+
+#if ARCHIVE_VERSION_NUMBER >= 3006000
+                       // Fetch numbers of processors
+                       long processors = sysconf(_SC_NPROCESSORS_ONLN);
+
+                       if (processors > 1) {
+                               r = pakfire_string_format(value, "%ld", processors);
+                               if (r) {
+                                       ERROR(pakfire, "Could not format threads: %m\n");
+                                       goto ERROR;
+                               }
+
+                               // Try using multiple threads
+                               r = archive_write_set_filter_option(a, NULL, "threads", threads);
+                               if (r) {
+                                       ERROR(pakfire, "Could not enable %s threads for compression: %s\n",
+                                               threads, archive_error_string(a));
+                                       goto ERROR;
+                               }
+                       }
+#endif
        }
 
        // Write archive to f