THRIFT-6288: Clarify the message-size TODOs in the Rust protocols - #3880
Merged
Merged
Conversation
Client: rs The TODO in check_container_size did not say what the check compares against today, or why the more precise check is missing. It holds the smallest size a container's elements can take to the whole max_message_size. The other bindings compare against what is left of the current message, a count they keep in their transports. In Rust every io::Read is a TReadTransport through one blanket impl, so a transport cannot supply its own count until trait specialization is stable. The comment now says that, and notes that up-front allocation does not depend on the check. The two matching TODOs in read_message_begin point to it. Comment-only change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
THRIFT-6288
Comment-only change: the three message-size TODOs in the Rust protocols now say what the code does today and why the more precise check is missing.
Background
The ticket quotes a TODO that is not the text in the tree. The actual comment in
check_container_size, there since THRIFT-5871 (42d0b71), reads:That comment names a real obstacle. The THRIFT-5871 commit message says the same: full message-size tracking was left out because trait specialization is not stable.
TReadTransportis implemented for everyio::Readby one blanket impl (transport/mod.rs). So no transport can supply its own remaining-bytes count without specialization or a change to the trait.TTransportand JavaTEndpointTransport.What the comment did not say is what the check compares against today, which is the whole
max_message_size. It also did not say that up-front allocation does not depend on the check.What changes
protocol/mod.rs,check_container_size: the TODO says thatmin_bytes_neededis held to the wholemax_message_sizerather than to what is left of the current message, and why. It also notes that generated code reserves list capacity throughprealloc_size, which caps it; sets and maps areBTreeSet/BTreeMapand reserve nothing.protocol/binary.rsandprotocol/compact.rs,read_message_begin: the matching "call the message size tracking here" TODOs now say what would start there, and point tocheck_container_size.No behaviour changes, so there is no test to add.
Verification
Rust 1.85.1, as in CI, in
lib/rs:cargo fmt --all -- --check,cargo clippy --all -- -D warningsandcargo clippy --all --all-features -- -D warningsare clean.cargo check --no-default-features --features rustlspasses.cargo testandcargo test --all-features: 177 of 178 pass.transport::socket::tests::split_halves_must_not_clobber_each_others_timeout. It fails the same way on unmodified master on this machine:Some(252ms)vsSome(250ms).CONFIG_HZ=250, and Linux stores socket timeouts in jiffies, so 250 ms comes back as 252 ms. The test passes in CI, so the runners' kernels keep 250 ms exact. The failure is unrelated to this change.The change was written with AI assistance (Claude Opus 5), then reviewed and checked as described above.
🤖 Generated with Claude Code