Repository navigation
feat: rwir delegation on kvspace 0.3 - #390
Merged
Merged
Conversation
8 月的实现钉在未合入的 Notify/Take/Incr/Expire。按现行 ABI 重做: 任务写在 cmd 子键上,完成用 Watch,任务号不用 Incr,成功后的 done 锚点留下。 同一 opcode 只允许 rwir 声明或 rwfunc 体其中一种。
carsontung666
force-pushed
the
feat/rwir-delegation-03
branch
from
October 17, 2026 19:20
ecf6626 to
62bf01f
Compare
miaobyte
added a commit
that referenced
this pull request
Oct 19, 2026
Strbuf 可增长、可清空、可复用——它把「字符串怎么拼」变成了一个带生命周期和容量策略
的对象。但 runtime 里每一处用法都是「拼一次 → 用 → 扔」,没有任何调用点需要复用;
这个缓冲只是在每个调用处引入三字段状态和一条 malloc 失败路径。
删掉它,换成三个一次性函数(新增 runtime/src/strutil.c):
- kvlangKeyFmt(buf, cap, fmt, ...):有界写入调用方栈缓冲;超长或格式化错误**直接
abort,绝不截断**——截断会静默产出一个错的 key,比崩更糟
- kvlangAstr(fmt, ...) / kvlangAstrN(s, n):一次性堆字符串,调用方 free;OOM abort
- kvlangDie(fmt, ...):统一 panic 出口,noreturn
所有 keytree 函数的 out 参数从 `kvlangStrbuf_t *` 改成 `(char *out, size_t cap)`——
签名直接表达「调用方给的缓冲有多大」,不再有隐藏扩容。
- runtime/src/strbuf.c 删除;新增 strutil.c(CMake 走 `src/*.c` GLOB,构建文件无需改)
- keytree.c / kvcpu.c / runtime.c / vthread.c / xvalue.c / rwir*.c / rwirext.c /
myrwircaps.c / runtime_internal.h / const.h 全量改签名与调用点(-650/+479)
- spec/05-runtime语义/09-cruntime与后端abi.kv:内部模块清单 strbuf.c → strutil.c
- runtime/tests/test_crash_resume.c 跟改
验证:
- `make runtime` 构建通过
- `ctest`:7/9 通过。param_address_{shm,fs} 失败,但用临时 clone 在**重构前的 HEAD
(9dbe650)** 上复跑同样失败——既有问题,非本次引入(CI 只 `make runtime` 不跑
ctest,所以一直没暴露)
- tutorial fs 后端:PASS:222 FAIL:0 SKIP:1,无回归
Co-Authored-By: Claude Code <noreply@anthropic.com>
rebase 到 #390 后:dispatch.c 的 JSON/错误拼接与 keytree 的 delegation 路径
同步改为 parts_t 精确拼接 + kvlangAstr,未保留任何 strbuf 调用。
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.
按 kvspace 0.3 ABI 落地 runtime 的
rwir外部后端委托。调度顺序排在 native 之后、外部扩展 handoff 和用户call之前;backend 需满足ready|busy且 15s 内有心跳,按最低load选路,未命中走 250ms 否定缓存。任务以 JSON 写入
/sys/rwir-backend/<b>/cmd/<task_id>(区分物化字面量value、变量槽key与同槽读写value),通过Watch等待/sys/task/<id>/‥status变为done并校验输出槽非空,成功后保留done锚点。同一 opcode 在layout和 runtime 均只允许rwir或rwfunc一种定义;写槽拒绝/lib、/sys、/dev、/done、跨vthread及‥保留键。