Speed up TLV serialization length accounting#4642
Conversation
|
👋 Thanks for assigning @TheBlueMatt as a reviewer! |
|
I've completed a thorough review of all changes in this PR. Here's my analysis: Verification points checked:
No issues found. |
7afe504 to
084d0ac
Compare
|
👋 The first review has been submitted! Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer. |
084d0ac to
b0e52bd
Compare
| let mut data = Vec::with_capacity(8192); | ||
| std::io::stdin().read_to_end(&mut data).unwrap(); | ||
| zbase32_test(&data, test_logger::Stdout {}); | ||
| if std::env::var_os("LDK_FUZZ_SUPPRESS_LOGS").is_some() { |
There was a problem hiding this comment.
Bleh. Tell claude env variables for runtime decisions is gross and not the clean solution it thinks it is. If the point of stdin-fuzz is to be used to replicate tests, we should leave stdout, if its purpose is as a fuzz target, it should be DevNull.
There was a problem hiding this comment.
I wanted this, not Claude 😅 I use stdin_fuzz also to run big sets of test cases using a runner that parallelizes and also continues on failure to examine the rest. That wouldn't work using the cargo test and test_cases dir approach.
There was a problem hiding this comment.
Open to other suggestions for a convenient way to feed strings without intermediate files, while being able to switch logging on or off.
There was a problem hiding this comment.
For the time being, moved to #4646 to unblock this PR.
b0e52bd to
78817b6
Compare
78817b6 to
2060cff
Compare
|
Dropped commit, so no clean diff is possible anymore. |
7dd5bca to
70b69e4
Compare
Add direct serialized length implementations for common serialization wrappers. This avoids routing field payload length calculations through in-memory writers for common nested serialization paths used by the existing TLV length helpers.
Add a write-only TLV helper macro that emits both write and serialized_length from the same field list. Reuse the shared TLV length helper from impl_writeable_tlv_based so the existing generated writer path and the new custom-read path stay aligned. Use the new helper for the hot channel funding and commitment transaction TLV writers while leaving their custom read implementations unchanged.
70b69e4 to
18a137a
Compare
|
|
||
| #[inline] | ||
| fn serialized_length(&self) -> usize { | ||
| (**self).serialized_length() |
There was a problem hiding this comment.
nit: can we use the same syntax as the write?
| /// [`Writeable`]: crate::util::ser::Writeable | ||
| /// [`impl_writeable_tlv_based`]: crate::impl_writeable_tlv_based | ||
| /// [`write_tlv_fields`]: crate::write_tlv_fields | ||
| macro_rules! impl_writeable_only_tlv_fields { |
There was a problem hiding this comment.
Should we rename the existing macro(s) to impl_ser_tlv_based so that writeable_only_tlv_fields isn't so awkward?
Recent splice fuzzing coverage made it clear that some chanmon consistency inputs spend a surprising amount of time encoding snapshots. This PR tightens the serialization length path used by those snapshots.
Slow fuzz byte string used while checking this:
a1a0a3ffa2a1ffffa2a1ff00a2a1ffa2a1a0a3ffa2a1ff19ffffffffffffffacFor that byte string, median real time over 5 runs with target output suppressed: