Repository navigation
quest: hard-fork UniFFI, plus payload, async, and BoltFFI spikes - #5498
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 14 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
f0060d1 to
6361232
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f0060d1263
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| `memcpy` in [moq-dev/uniffi](/quest/m1/uniffi-fork.md). The serialized | ||
| format is unchanged, so no generator or binding API changes. |
There was a problem hiding this comment.
Do not count the memcpy as a one-copy path
For record fields and returned values such as MoqFrame.payload, retaining UniFFI's serialized format still requires the wrapper to copy between its native byte container and RustBuffer, followed by the core copy between RustBuffer and Vec<u8>. Replacing the element loop with memcpy only accelerates one of those copies; it cannot satisfy the stated one-copy goal without the ownership/ABI work deferred to ffi-bytes-return. Either narrow this quest's acceptance criterion to eliminating per-byte overhead or include the second-copy elimination here.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. The goal now requires no per-byte copies and has the report count the bulk copies. It also notes that records and returns keep two copies until zero-copy returns lands.
(Written by Claude Opus 5.5)
| cancel bugs (#2932, the swallowed-event fix) came from that machinery. | ||
| - **Shape A, poll-native exports**: an async export is a `kio::wait` over the | ||
| underlying `poll_*`, and UniFFI's `RustFuture` polls it directly. No | ||
| per-handle mutex and no spawned task. Cancelling the foreign future drops |
There was a problem hiding this comment.
Model UniFFI cancellation before dropping Task machinery
With the UniFFI behavior this fork starts from, foreign cancellation only stops polling and the Rust future is retained until rust_future_free; rs/moq-ffi/src/ffi.rs:324-326 and its cancellation regressions explicitly depend on that behavior, which is also the subject of upstream issue #2771. Therefore Shape A does not automatically drop the waiter or release a held handle mutex when the host cancels. Make the fork-level cancel/drop change a required part of Shape A rather than assuming it in the baseline comparison.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. Shape A now states that UniFFI keeps the future until rust_future_free (#2771). It includes the core change that drops the future on cancel, prototyped on a branch if the fork doesn't exist yet, and measures with and without it.
(Written by Claude Opus 5.5)
| sync-only, and async constructors and static async methods are dropped | ||
| (boltffi/boltffi#95, which `connect` hits). One maintainer wrote about 80% | ||
| of the code. Same-name types in one target probably collide (RFC #700). |
There was a problem hiding this comment.
Do not classify connect as an unsupported async static
MoqClient::connect is an async instance method taking &self at rs/moq-ffi/src/session.rs:575, while BoltFFI #95 says instance async methods work and only methods without a receiver are omitted. Claiming that connect hits this gap can cause the spike to skip or misreport a required part of its comparison slice; remove that example or identify an actual static async entry point.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, connect takes &self. The example is now MoqMediaCatalogConsumer::subscribe, an async #[uniffi::constructor] (rs/moq-ffi/src/media.rs:1212).
(Written by Claude Opus 5.5)
…I spikes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…I statics Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
39e3d32 to
c83c59d
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merge summary. These are quest files only, with no API or wire impact.
All decisions are in the PR body. (Written by Claude Opus 5.5) |
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 63fd576
One P3 baseline correction below. Overall direction is coherent: benchmark the candidate bases before choosing the fork, retain explicit ownership/cancellation checks, and gate further copy-elimination work on measured cost. The dependency graph is acyclic.
The independent findings are substantively addressed: copy-count goal is narrowed to bulk-copy overhead; cancel/drop semantics are now an explicit Shape A experiment; connect classification now uses an actual async constructor example. Small remaining consistency fix: quest/m1/README.md:129 still says “one bulk copy”; align it with the revised payload goal.
Limits: static GitHub review of the ten changed plans and relevant checked-in wrappers, FFI/runtime and kio paths. No tests or benchmarks run. External generator/version claims were not independently verified outside moq-dev/moq.
|
|
||
| Decided with the maintainer on 2026-10-13: | ||
|
|
||
| - **Why**: moq-net is poll-based through kio, but moq-ffi does not use kio. |
There was a problem hiding this comment.
[P3] Describe the existing hot path accurately
moq-ffi already uses kio::wait in the chosen track-consumer hot path (rs/moq-ffi/src/consumer.rs:369–387), and Task::run already polls in place rather than spawning that call (ffi.rs:319–348). Describing the baseline as not using kio/detached work obscures what Shape A actually removes. Update this paragraph to distinguish run from detached and frame the comparison around the remaining synchronization, cancellation and shutdown costs, preserving the existing read-lane semantics.
Problem
UniFFI drives every non-Rust binding, and it costs us in three ways.
Vec<u8>one byte at a time in both directions.Separately, moq-ffi's async layer (
ffi::Task: a tokio Mutex, watch, select, and spawned work) sits on top of a poll-based moq-net without using kio.Approach
Six new quests plus edits to existing ones. No code.
m1
quest/m1/boltffi.md[M]: a parallel spike, BoltFFI vs UniFFI on a slice of moq-ffi in Python, Kotlin, and Swift, with its own benchmarks, a size table, and the cost of carrying each one. It picks which one the fork starts from.quest/m1/uniffi-fork.md[L]: requires the spike. A hard fork in a fresh moq-dev repo (written for UniFFI, re-planned if BoltFFI wins).kixelated/uniffi-*forks are archived.quest/m1/ffi-bytes.md[L]: a payload benchmark in all six wrappers, run nightly, which becomes the shared harness.Vec<u8>with one memcpy. The serialized format is unchanged.&[u8]arguments only if the numbers justify fixing the Go and C++ forks and Dart's leak.quest/m1/ffi-poll.md[M]: a spike comparing kio poll-native exports and a foreignpoll(waker)againstffi::Task, in Python and Go.m2
quest/m2/ffi-bytes-return.md[M]: zero-copy byte returns in the fork, gated on the payload numbers.quest/m2/uniffi-namespaces.md[L]: fixes Library mode: a type cannot reference an external type with the same name mozilla/uniffi-rs#3026 in the fork.Edits
quest/m1/ffi-shape/README.md: its revisit condition now points at the namespaces quest.quest/m2/ffi-size-profile.md: now requires the payload harness.Decisions
Generator spike scope
kio goal
u8 scope
Milestones
Spike candidates
Relationship to #5478
kio split
u8 benchmarks
u8 reshape (after finding that
&[u8]is sync-arguments-only and that the forks break on it)&[u8]only if justified&[u8]plus reshaping the recordsBoltFFI slice
Where the #5478 edit goes
Until upstream ships the bulk copy
Fork repo shape
Fork rank
Repo base
Divergence
Publishing
[patch]and stay compatibleZero-copy returns
Namespaces
BoltFFI as the base (maintainer, after the PR opened)
Impact
Quest files only. Public API: none. Wire: none.
quest checkpasses.(Written by Claude Opus 5.5)
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.