rustls / rustls/rustls

Lazily parse TLS vector contents to eliminate intermedaite `Vec` construction

Open
#907 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
7.6k
Forks
896
Avg merge
1d 6h
Merged PRs (30d)
39

Description

When we parse a TLS handshake message, we eagerly parse the contents of each TLS vector, constructing a Vec<_> containing the parsed and validated contents, using code equivalent to this:

    let a = vector_contents.iter().try_map(T::decode).collect<Vec<_>>?;

My suggestion is that we avoid the collect step in as many cases as practical so that we instead operate on the iterators that lazily do the parsing/conversion as each entry is looked at. This should become practical to do if we implement #906.

This would divorce the order in which we validate the contents of the vectors from the order they appear in the structures.

This would also reduce the amount of validation we do, limiting it to the contents of the vectors we actually look at. IMO this is a good thing because it's good for performance, though it's different than what we do today. This works especially well if we avoid trying to detect duplicates in the vectors.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the TLS handshake vector parsing code that performs iter().try_map(T::decode).collect<Vec<_>>(), then review the proposed iterator support in #906. Identify which vectors can remain lazy without duplicate detection, and compare validation behavior with the current eager parsing. Done means practical cases avoid intermediate Vec construction while preserving the intended parsing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking, security
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.