Skip to content

[0054] 优化 inlet 性能#801

Open
da-liii wants to merge 4 commits into
mainfrom
da/0054/inlet
Open

[0054] 优化 inlet 性能#801
da-liii wants to merge 4 commits into
mainfrom
da/0054/inlet

Conversation

@da-liii
Copy link
Copy Markdown
Contributor

@da-liii da-liii commented May 19, 2026

Summary

优化 inlet 函数在大 let 复制和合并场景下的性能。

Changes

  • src/s7.c:
    • sublet_1T_LET 分支中,添加 if (is_pair(cdr(entries))) 判断,避免 append_let 后对最后一个 let 进行不必要的二次遍历
    • 优化 s7_inlet 的空参数路径:当 args == sc->nil 时直接 make_let 返回,跳过 sublet_1 调用
  • bench/inlet-bench.scm: 添加 inlet 性能 benchmark
  • devel/0054.md: 添加开发文档

Benchmark 结果(6000 slot 大 let,100 次迭代平均)

测试项 优化前 优化后 变化
copy big inlet via (inlet big-inlet) ~0.0140s ~0.0127s -9%
merge big inlet + small inlet ~0.0119s ~0.0105s -12%
empty inlet ~0.0189s ~0.0190s 持平
simple inlet 2 args ~0.0313s ~0.0315s 持平

Test plan

  • xmake b goldfish 构建通过
  • bin/gf bench/inlet-bench.scm 性能测试运行正常

🤖 Generated with Claude Code

da-liii and others added 4 commits May 19, 2026 15:41
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- sublet_1 的 T_LET 分支中,仅在后面还有 entries 时才遍历找尾
- s7_inlet 添加空参数快速路径,直接返回 make_let

性能变化(6000 slot 大 inlet,100 次迭代):
- copy big inlet: 0.0140s -> 0.0127s (-9%)
- merge big inlet: 0.0119s -> 0.0105s (-12%)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
将各测试项运行时间控制在 0.01s ~ 1s 之间,减少测量噪声。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
在 inlet benchmark 中增加不同字段数量(2/4/16)的 record
创建、字段访问、类型判断及与直接 inlet 的对比测试。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant