Repository navigation
fix(model): reduce stack usage during provider request encoding - #6873
Merged
M4n5ter merged 2 commits intoNov 13, 2026
Merged
Conversation
Generated-by: OpenAI Codex
Generated-by: OpenAI Codex
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.
Summary
The request encoder's async state can make the surrounding futures large enough to overflow a worker stack. The encoder now owns its pinned heap allocation: emit returns a concrete, statically dispatched future, and the counting, in-memory build and backed encoding paths await it directly. All paths continue to use the existing codec.
Verification
AI use
Tool(s) and scope: OpenAI Codex assisted with investigation, implementation, verification, and drafting, including centralizing the heap allocation in emit.
Checklist
Does this PR entail a change in behavior?
简体中文
编码器的 async state 会增大外层 future,导致工作线程栈溢出。现在由 emit 自己统一在堆上分配 pinned future,计数、内存构建和 backed 编码三个入口直接 await,保留原编码逻辑和静态分发。
macOS arm64 上通过 29 项模型单元测试、8 项集成测试、目标 crate 的 Clippy、格式和 diff 检查。独立 dev probe 在 512 KiB 和 2 MiB 线程栈上完成文本及 tool/media 请求准备和完整 wire replay,输出字节、identity、SHA-256 与原 PR 一致,分配次数不变。此前 invalid-image 和 compaction 的整机联调场景未在这次封装调整中独立重跑。
OpenAI Codex 协助排查、实现、验证和正文起草。