-
Notifications
You must be signed in to change notification settings - Fork 0
Further optimization #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
a57a504
c6236a1
5142a3d
1f964de
3627f85
1ebdc7b
a93e21b
d8d77f1
2d7323e
19e4fe3
ce93d55
0314bc7
834e3fd
c4b047d
2211802
dc080a9
1c627e0
146611d
e8a96e6
b36bdd0
d1ae9b8
db7ed70
1a94603
674511a
e944c6f
7a41ac9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -225,7 +225,7 @@ fn usage() -> String { | |
| let mut message = String::new(); | ||
| message.push_str("Usage:\n"); | ||
| message.push_str( | ||
| " cargo run -p perf-probe --release --no-default-features --features <liblzma-sys|xz-sys> -- \\\n", | ||
| " cargo run -p perf-probe --release --no-default-features --features <xz|xz-sys|liblzma-sys> -- \\\n", | ||
| ); | ||
| message.push_str(" --workload <encode|decode|size|crc32|crc64> [options]\n\n"); | ||
| message.push_str("Options:\n"); | ||
|
|
@@ -527,6 +527,16 @@ unsafe fn backend_decode(compressed: &[u8], out_size: usize) -> Vec<u8> { | |
| ) | ||
| }; | ||
| assert_eq!(ret, LZMA_OK, "{BACKEND_NAME} decode failed with {ret}"); | ||
| assert_eq!( | ||
| in_pos, | ||
| compressed.len(), | ||
| "{BACKEND_NAME} decode left trailing input: consumed {in_pos} of {} bytes", | ||
| compressed.len() | ||
| ); | ||
|
Comment on lines
+534
to
+539
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: Yes, liblzma's lzma_stream_buffer_decode allows trailing bytes by returning LZMA_OK (success) and advancing *in_pos to the position of the first unused byte after successfully decoding a complete .xz Stream or .lzma file from the input buffer. This behavior follows the single-call decoding pattern in liblzma, where like lzma_code, it consumes only the necessary bytes for one complete stream and updates *in_pos accordingly, leaving any trailing data unconsumed without error if the decoding succeeded. The official documentation states that *in_pos and *out_pos are updated only if decoding succeeds (LZMA_OK), confirming partial consumption on success. Analogous streaming decoders (e.g., Python's LZMADecompressor) explicitly provide unconsumed_tail for trailing bytes after LZMA_STREAM_END, supporting this design. Citations:
🏁 Script executed: cat -n perf-probe/src/main.rs | sed -n '525,540p'Repository: youknowone/xz-rs Length of output: 639 🏁 Script executed: cat -n perf-probe/src/main.rs | sed -n '500,545p'Repository: youknowone/xz-rs Length of output: 1659 🏁 Script executed: rg -n "backend_decode\(" perf-probe/src/main.rsRepository: youknowone/xz-rs Length of output: 281 🏁 Script executed: cat -n perf-probe/src/main.rs | sed -n '355,385p'Repository: youknowone/xz-rs Length of output: 1357 🏁 Script executed: rg -n "fn load_compressed_input" perf-probe/src/main.rsRepository: youknowone/xz-rs Length of output: 151 🏁 Script executed: cat -n perf-probe/src/main.rs | sed -n '299,330p'Repository: youknowone/xz-rs Length of output: 1394 🏁 Script executed: rg -n "compressed.input" perf-probe/src/main.rs | head -20Repository: youknowone/xz-rs Length of output: 1277 Don't require full input consumption for
🤖 Prompt for AI Agents |
||
| assert_eq!( | ||
| out_pos, out_size, | ||
| "{BACKEND_NAME} decode produced {out_pos} bytes, expected {out_size}" | ||
| ); | ||
| out.truncate(out_pos); | ||
| out | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
In Cargo, when the same crate appears in[dependencies]and[dev-dependencies], are features unified for benches/examples/tests, and do default features from the dev-dependency stay enabled?💡 Result:
Yes, when the same crate appears in both [dependencies] and [dev-dependencies], Cargo unifies the features for builds that include dev-dependencies (benches, examples, tests). This uses the union of features specified in both sections. Default features from the dev-dependency declaration remain enabled unless explicitly disabled there (via default-features = false). For normal builds (cargo build on lib/bin), only [dependencies] features apply (dev-deps ignored). This behavior depends on the feature resolver version (default "2" for edition 2021+, controlled by top-level resolver field). Resolver v2 avoids unwanted unification but includes dev-dep features when building dev targets like tests/examples/benches. Example from docs: [dependencies] serde = {version = "1.0", default-features = false} [dev-dependencies] serde = {version = "1.0", features = ["std"]} - cargo build: serde without features (defaults off). - cargo test: serde with "std" (union, defaults from dev-dep enabled since not disabled).
Citations:
🏁 Script executed:
Repository: youknowone/xz-rs
Length of output: 1680
liblzma-sysstill enablesbindgenfor dev targets.Line 45 defines a target-specific dev-dependency
liblzma-sys = { path = "liblzma-sys" }withoutdefault-features = false. When benches/examples/tests are built with theliblzma-sysfeature, Cargo unifies features across dependencies and dev-dependencies, re-enabling the defaultbindgenfeature from the dev-dependency. This defeats the goal of disabling it at Line 25 and keeps the libclang requirement around for those builds.♻️ Proposed fix
[target.'cfg(not(target_family = "wasm"))'.dev-dependencies] xz-sys = { path = "xz-sys" } -liblzma-sys = { path = "liblzma-sys" } +liblzma-sys = { path = "liblzma-sys", default-features = false }🤖 Prompt for AI Agents