Uh oh!
There was an error while loading. Please reload this page.
Conversation
aee2e03 to
e8e7516Compare
This comment was marked as resolved.
This comment was marked as resolved.
This passes tests but it doesn't provide as big a window size as is required to decompress larger streams. The next commit in this branch will work towards that, without introducing an additional buffer.
instead of manually bitcast, use the handy dandy takeStruct function.
| /// If buffer that is written to is not big enough, some streams will fail with | ||
| /// `error.OutputBufferUndersize`. A safe value is `zstd.default_window_len * 2`. | ||
| pub fn init(input: *Reader, buffer: []u8, options: Options) Decompress { |
There was a problem hiding this comment.
I think some clarification on what "buffer" refers to in this doc comment and that of Options.window_len would be helpful. It's not currently clear that the buffer parameter of init is used for the Reader, but the buffer in the doc comment (and Options.window_len) refers to the Writer.
Seems to be a regression for many inputs where Test code for master branch: conststd=@import("std");
test"decompress" {
constwindow_buffer=trystd.testing.allocator.alloc(u8, std.compress.zstd.DecompressorOptions.default_window_buffer_len);
deferstd.testing.allocator.free(window_buffer);
constdata=@embedFile("input.zst");
varin_stream=std.io.fixedBufferStream(data);
varzstd_stream=std.compress.zstd.decompressor(in_stream.reader(), .{ .window_buffer=window_buffer });
constresult=tryzstd_stream.reader().readAllAlloc(std.testing.allocator, std.math.maxInt(usize));
deferstd.testing.allocator.free(result);
trystd.testing.expectEqualSlices(u8, @embedFile("input.orig"), result);
}Test code for this branch: conststd=@import("std");
test"decompress" {
constallocator=std.testing.allocator;
varout: std.ArrayListUnmanaged(u8) =.empty;
deferout.deinit(allocator);
tryout.ensureUnusedCapacity(allocator, std.compress.zstd.default_window_len);
constdata=@embedFile("input.zst");
varin: std.io.Reader= .fixed(data);
varzstd_stream: std.compress.zstd.Decompress= .init(&in, &.{}, .{});
tryzstd_stream.reader.appendRemaining(allocator, null, &out, .unlimited);
trystd.testing.expectEqualSlices(u8, @embedFile("input.orig"), out.items);
}Files that reproduce the error: The error: This seems to affect a lot of the generated files from zstd's |
andrewrk
commented
Jul 25, 2025
Sorry, I need to make the buffer size capacity requirements more clear. The output buffer is too small. Minimum is |
squeek502
commented
Jul 26, 2025
Unless I'm misunderstanding, upping the output buffer size doesn't fix the |
andrewrk
commented
Jul 26, 2025
trylist.ensureUnusedCapacity(gpa, 1);The So then your test code needs: tryzstd_stream.reader.appendRemaining(allocator, null, &out, .unlimited, zstd.block_size_max); |
Okay, switched to conststd=@import("std");
test"decompress" {
constallocator=std.testing.allocator;
constdata=@embedFile("input.zst");
varin: std.io.Reader= .fixed(data);
varzstd_stream: std.compress.zstd.Decompress= .init(&in, &.{}, .{
.window_len=std.compress.zstd.default_window_len,
});
varout: std.io.Writer.Allocating= .init(allocator);
deferout.deinit();
tryout.ensureUnusedCapacity(std.compress.zstd.default_window_len);
constlen=tryzstd_stream.reader.streamRemaining(&out.writer);
trystd.testing.expectEqual(@embedFile("input.orig").len, len);
trystd.testing.expectEqualSlices(u8, @embedFile("input.orig"), out.getWritten());
}(but note that the With this setup, generated inputs from zstd's decodecorpus tool are all passing as expected on this branch, so confirmed not a regression but more like a potential footgun. |
andrewrk
commented
Jul 26, 2025
Yep I hear you loud and clear. |
andrewrk
commented
Jul 26, 2025
Going to tack on documentation improvements and |
Uh oh!
There was an error while loading. Please reload this page.
L3P3
commented
Jul 26, 2025
The cache_ benchmarks got way worse. Why and what to do? |
@L3P3 The numbers all describe aspects of the same single benchmark. Details:The way I understand it, The other numbers tell us aspects of how the code ran, what the CPU/system did in this time. There's always room to try to make any code faster - in this case, we could investigate these changed values as a start. |
squeek502
commented
Jul 26, 2025
In my experience, cache usage metrics are also much more variable than the others, and much more affected by other things happening on the machine. |
Followup from #24329
It's basically the same logic, except reworked to use
std.Io.Readerandstd.Io.Writerand is therefore fully non-generic now.Performance
master.zig
branch.zig