Updated performance values in README.

Added ability to ignore xattrs & permissions.
Ignore setting xattr errors due to an unknown issues.
This commit is contained in:
Caleb J. Gardner
2026-03-04 13:28:29 -06:00
parent edfe919c1b
commit a4e23a840d
3 changed files with 25 additions and 13 deletions
+9 -8
View File
@@ -37,17 +37,18 @@ Most features are present except for the following:
This is some basic observation's I've made about this library's performance when compared to `unsquashfs`. Unless otherwise stated, most observations were made when extracting my test archive (which is fairly small and uses zstd compression) and with `--release=fast`. This is some basic observation's I've made about this library's performance when compared to `unsquashfs`. Unless otherwise stated, most observations were made when extracting my test archive (which is fairly small and uses zstd compression) and with `--release=fast`.
* Under ideal circumstances, my library is ~70% slower (.11s vs .18s) * Under ideal circumstances, my library is ~60% slower (.12s vs .19s).
* Mutli-threading on small archives significantly increases extraction times (when using C libraries) (.18s vs .57s). This should theoretically reverse on larger archives with many inodes, but I haven't tested that yet. * Using Zig decompression libraries *significantly* increases decompression time by ~600%. Under ideal circumstances.
* Using Zig libraries *significantly* increases decompression time by ~600% under ideal circumstances. * Performance improvements/regressions will be common. I'm still learning Zig.
Example Times: Example Times:
* *unsquashfs*: .11s * *unsquashfs, multi-threaded*: .12s
* *C-libs, single-threaded*: .18s * *unsquashfs, single-threaded*: .13s
* *C-libs, multi-threaded*: .57s * *C-libs, single-threaded*: .56s
* *Zig-libs, single-threaded*: 5.87s * *C-libs, multi-threaded*: .19s
* *Zig-libs, multi-threaded*: 1.10s * *Zig-libs, single-threaded*: 5.78s
* *Zig-libs, multi-threaded*: 1.08s
## Build considerations ## Build considerations
+12
View File
@@ -14,6 +14,8 @@ const help_mgs =
\\ -d <location> Extract to the given location instead of "squashfs-root" \\ -d <location> Extract to the given location instead of "squashfs-root"
\\ \\
\\ -o <offset> Start reading the archive at the given offset. \\ -o <offset> Start reading the archive at the given offset.
\\ -dx Don't set xattr values
\\ -dp Don't set permissions (includes setting uid & gid owner)
\\ \\
\\ -p <threads> Specify how many threads to use. If no present or zero, the system's logical cores count is used. \\ -p <threads> Specify how many threads to use. If no present or zero, the system's logical cores count is used.
\\ -v Verbose \\ -v Verbose
@@ -30,6 +32,8 @@ var extLoc: []const u8 = "squashfs-root";
var offset: u64 = 0; var offset: u64 = 0;
var threads: u32 = 0; var threads: u32 = 0;
var verbose: bool = false; var verbose: bool = false;
var ignore_xattrs: bool = false;
var ignore_permissions: bool = false;
pub fn main() !void { pub fn main() !void {
const alloc = std.heap.smp_allocator; const alloc = std.heap.smp_allocator;
@@ -50,6 +54,8 @@ pub fn main() !void {
.threads = if (threads == 0) try std.Thread.getCpuCount() else threads, .threads = if (threads == 0) try std.Thread.getCpuCount() else threads,
.verbose = verbose, .verbose = verbose,
.verbose_writer = if (verbose) &out.interface else null, .verbose_writer = if (verbose) &out.interface else null,
.ignore_xattr = ignore_xattrs,
.ignore_permissions = ignore_permissions,
}; };
try arc.extract(alloc, extLoc, options); //TODO: Handle error gracefully. try arc.extract(alloc, extLoc, options); //TODO: Handle error gracefully.
} }
@@ -92,6 +98,12 @@ fn handleArgs(alloc: std.mem.Allocator, out: *Writer) !void {
} else if (std.mem.eql(u8, arg, "-v")) { } else if (std.mem.eql(u8, arg, "-v")) {
verbose = true; verbose = true;
continue; continue;
} else if (std.mem.eql(u8, arg, "-dx")) {
ignore_xattrs = true;
continue;
} else if (std.mem.eql(u8, arg, "-dp")) {
ignore_permissions = true;
continue;
} else if (std.mem.eql(u8, arg, "--version")) { } else if (std.mem.eql(u8, arg, "--version")) {
try out.print("zig-unsquashfs v", .{}); try out.print("zig-unsquashfs v", .{});
try config.version.format(out); try config.version.format(out);
+4 -5
View File
@@ -183,15 +183,14 @@ pub fn setMetadata(self: Inode, alloc: std.mem.Allocator, archive: *Archive, fil
const xattrs = try archive.xattr_table.get(alloc, idx); const xattrs = try archive.xattr_table.get(alloc, idx);
defer alloc.free(xattrs); defer alloc.free(xattrs);
for (xattrs) |kv| { for (xattrs) |kv| {
defer {
alloc.free(kv.key);
alloc.free(kv.value);
}
const res = std.os.linux.fsetxattr(fil.handle, @ptrCast(kv.key), @ptrCast(kv.value), kv.value.len, 0); const res = std.os.linux.fsetxattr(fil.handle, @ptrCast(kv.key), @ptrCast(kv.value), kv.value.len, 0);
alloc.free(kv.key);
alloc.free(kv.value);
if (res != 0) { if (res != 0) {
if (options.verbose) if (options.verbose)
options.verbose_writer.?.print("fsetxattr has result of: {}\n", .{res}) catch {}; options.verbose_writer.?.print("fsetxattr has result of: {}\n", .{res}) catch {};
return error.SetXattr; //TODO: Currently this seems a bit flakey, so we just ignore the result... for now.
// return error.SetXattr;
} }
} }
} }