Skip to content

fix(proto): coalesce contiguous chunks during defragment - #866

Merged
flub merged 2 commits into
n0-computer:mainfrom
thtbee:fix-coalesce-chunks
Oct 27, 2026
Merged

flub merged 2 commits into
n0-computer:mainfrom
thtbee:fix-coalesce-chunks

Conversation

@thtbee

@thtbee thtbee commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Description

Replaces #828, as discussed there. The first two commits of that PR landed in #823, so this is the remaining one: the port of quinn-rs/quinn#2814, adapted to the sorted VecDeque from #823.

Without it, 1.4.0 can close a connection with "too many gaps in stream buffer" when a reader falls about 2,048 packets behind, even with no gaps. Packet-sized chunks get marked defragmented and are never merged again, so compaction can't get back under MAX_CHUNKS. defragment now also merges contiguous chunks smaller than buffered / MAX_CHUNKS (at least 128 bytes), like quinn.

Brings over quinn's two tests. ordered_lossless_stream_is_not_rejected fails on main and passes here.

API Changes

None.

Notes & open questions

quinn-rs/quinn#2955 (contiguous data behind a single gap under sustained loss) is still open upstream and isn't covered here. This touches defragment like #867 (the fix for #865), so whichever lands second needs a small rebase.

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • All API changes documented.
  • cargo make passes locally.

Port of quinn-rs/quinn@c3f8b098 (quinn-rs/quinn#2814), which 1.4.0 shipped
without. Packet-sized chunks are marked defragmented and were never merged,
so a slow in-order reader with no gaps in the stream could still reach
TooManyChunks after 2048 packets. defragment now combines contiguous chunks
smaller than buffered / MAX_CHUNKS. Larger chunks are left alone so they are
not copied on every compaction.

Replaces n0-computer#828, adapted to the sorted VecDeque from n0-computer#823.

Co-authored-by: Eanna Lyons <[email protected]>
Co-authored-by: Luke Curley <[email protected]>
@thtbee

thtbee commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! The cargo deny failure is the tokio advisory published today (RUSTSEC-2026-0386), not this change.

@n0bot n0bot Bot added this to iroh Oct 27, 2026
@github-project-automation github-project-automation Bot moved this to 🚑 Needs Triage in iroh Oct 27, 2026
@flub

flub commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

#868 will fix cargo-deny, nothing to worry about here.

@flub
flub enabled auto-merge October 27, 2026 11:41
@flub
flub added this pull request to the merge queue Oct 27, 2026
Merged via the queue into n0-computer:main with commit 3ff2822 Oct 27, 2026
34 checks passed
@github-project-automation github-project-automation Bot moved this from 🚑 Needs Triage to ✅ Done in iroh Oct 27, 2026
danielpetri1 pushed a commit to danielpetri1/noq that referenced this pull request Oct 27, 2026
…computer#867)

## Description

Fixes n0-computer#865.

`defragment` dropped everything below `bytes_read`, which in unordered
mode is a count of delivered bytes, not an offset, so compaction could
throw away data that was never read. `defragment` now takes the offset
to discard below: `insert` passes 0, and only the switch to unordered
mode passes `bytes_read`, where it's still an offset. That matches
quinn.

Adds `unordered_compaction_keeps_unread_data`, the repro from the issue.

## API Changes

None.

## Notes & open questions

This touches `defragment` like n0-computer#866, so whichever lands second needs a
small rebase.

## Change checklist

- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All API changes documented.
- [x] `cargo make` passes locally.
thiras added a commit to decdn/decdn that referenced this pull request Oct 29, 2026
iroh-blobs 0.104 ends an export_bao stream after the leaf that completes
the requested ranges and no longer sends Done (n0-computer/iroh-blobs#298).
The serve path refused every such stream as truncated, so the node aborted
every serve. The end of the stream is now a complete export; an export the
store stops sending early arrives as an UnexpectedEof error from
iroh-blobs, which fails the serve but does not quarantine the blob.

bao-tree 0.17 deprecates BaoTree::root; three tests take the root from
pre_order_nodes_iter instead.

iroh and noq stay at 1.3.0: the gap-cap fix (n0-computer/noq#866) is
merged but not released. The hold guard now links #866.

Co-authored-by: Claude Opus 5.5 <[email protected]>
emrul added a commit to GetAster/noq that referenced this pull request Nov 24, 2026
* upstream/main: (24 commits)
  refactor(proto): call the std-only float math through crate-root helpers (n0-computer#848)
  refactor(proto): Avoid PathId allocation when building PATH_ACKS (n0-computer#901)
  chore: Release
  chore(deps): fix unused crates warnings of rust 1.100 (n0-computer#899)
  chore: Update issue template checkboxes (n0-computer#897)
  chore: humantime is unmaintained (n0-computer#900)
  chore(ci): fix workflows for test binaries locations (n0-computer#896)
  fix(perf): don't enable qlog feature in perf binary (n0-computer#850)
  fix(proto): track the key update boundary per path (n0-computer#869)
  tests: additional stream affinity tests (n0-computer#890)
  feat: allow streams to set an affinity for a path, simple version (n0-computer#881)
  fix(udp): handle receive errors before truncation flags in recv_single (n0-computer#884)
  chore: Upgrade async-executor and allow warnings in patchbay build (n0-computer#888)
  chore: Use shared minimal-crates worksflow (n0-computer#862)
  tests: Increase local slow-tests timeout (n0-computer#860)
  fix(proto): keep unread data when compacting an unordered stream (n0-computer#867)
  fix(proto): coalesce contiguous chunks during defragment (n0-computer#866)
  deps: Bump tokio for RUSTSEC-2026-0386 (n0-computer#868)
  feat(proto): Implement `noq_proto::SendStream::set_affinity` (n0-computer#836)
  fix(ci): bump deps for illumos (n0-computer#856)
  ...
emrul added a commit to GetAster/noq that referenced this pull request Nov 24, 2026
Current release, bridges (irpc 1.0.0, netwatch/portmapper 0.20.2), pin blocks, the upgrade/noq-v1.5.0 stack, stream-buffer-spans moved to upstreamed (n0-computer#866, n0-computer#867; tests kept), row 31 conflict note, history, and the registry/pin drift fixes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants