synth: measure whether the address-aware metric can shrink a real program
It cannot. The calculator assembles to 73624 characters in the default flat metric and 73940 with --synth-chars (identity layout), 316 more. Three reasons, now written down in SPEC section 3.7: * the travel term 2*(hi-lo) is translation invariant, so moving a group of cells farther or nearer changes nothing; only a permutation or a spread can, and the contiguous identity layout is already the tightest of those; * the library blocks are expanded at dozens of call sites with different addresses, so a single layout line is a guess that the real sites rarely match; * the model still ignores the hop between blocks, and the exact metric tends to pick programs with more blocks (six blocks for the adder table against five, 82 emitted characters against 87 -- five characters, which the other tables give back and more). Cell placement is the lever that works, and it is already spent: the terminal front end first put its borrowed classifier cells at 52..57 (77164 characters) and moving them into 20..29 gave 73624, minus 3540. Five single-cell moves on the current map were measured too (T and DEPTH to 17, HAVE and CNT to 52, S2 back to 52) and every one is longer: +182, +2900, +92, +134, +3810. So the map is a local optimum and the only way down from 73.6k is to drop features. The experiment left three metric-0 cache entries behind; they were deleted, so the committed cache still holds only what the flat metric needs.
This commit is contained in:
1 parent
5c414292d2
commit
1513111689
2 files changed
+27
-1
No files matched your search
@@ -196,6 +196,22 @@ R8Forge 唯一的语言扩展:在汇编期现场搜出一段最短的块序列
|
||||
缓存复用;对整条纸带来说它通常只长几个百分点(full_add:flat 95 字符、chars 90 字符)。
|
||||
两个口径的缓存分开存(键里带 metric),所以第一次跑 `--synth-chars` 会真的去搜。
|
||||
|
||||
**实测过"地址有关到底能不能省"——省不了**:拿计算器(`examples/calc.r8asm`,整条 73624 字符、
|
||||
几十个块展开)比,flat **73624**、`--synth-chars`(没有 `layout` 行,按 0..N-1 相邻)
|
||||
**73940**,反而多 316(0.4%)。三条原因:
|
||||
|
||||
1. 代价里的 `2*(hi-lo)` **平移不变**:把整组 cell 一起挪远挪近不改变任何价格,能变的只有
|
||||
排列和散布。相邻布局(0,1,2,…)已经是"最紧"那一种,所以这个口径下没有免费的空间。
|
||||
2. 库里的块被几十个地址各异的调用点共用,`layout` 行只能猜一份;为它搜出来的序列在真实
|
||||
调用点上未必更短(4 参数切片的调用点地址在 20~29 之间来回换)。
|
||||
3. 模型**不算块与块之间那一跳**,所以块数多的解在纸带上吃亏 —— 而精确口径经常选块数多
|
||||
的解(6 参数全加器:chars 选 6 块 / 模型说 75 字符,flat 选 5 块;实际发射 82 vs 87,
|
||||
只差 5 字符,其它表就把这 5 字符吃回去还倒贴)。
|
||||
|
||||
结论:`chars` 是"**给某个特定布局校一次**"的工具(比如你要为一份布局锁死最优块序列,
|
||||
再拿结果当常量表),不是省纸带的旋钮。真正能省纸带的是**程序自己的 cell 摆放**:
|
||||
计算器接终端时把借来的判据格从 52..57 挤到 20..29,纸带 77164 → 73624(−3.5k,−4.6%)。
|
||||
|
||||
**`blocks` 删掉了**:块数不是纸带长度的好代理(层数最少 ≠ 纸带最短,块数最少也不是),
|
||||
而且它只是 `mode layers` 的一个变体。
|
||||
|
||||
|
||||
+11
-1
@@ -169,7 +169,17 @@ t = C - 0x2A ; 命令: 0..5 数字: 6..15
|
||||
|
||||
代价:**64983 → 73624 字符**(+8.6k:退格的三次 `copy` 约 4.4k、判两次减法约 3k、
|
||||
回显和提示符几百)。**这条纸带因此超过了 ROT-8-viz 的旧 INS_SIZE(65536)**;
|
||||
现在的虚拟机按纸带长度分配缓冲(16 位版 96052、32 位版 284720 都在那边跑过),
|
||||
现在的虚拟机按纸带长度分配缓冲(16 位版 112802、32 位版 336304 都在那边跑过),
|
||||
所以只是历史口径作废。想压回去只能砍行编辑:只留回显 + 回车提示符约 +2.5k,
|
||||
仍然在 65536 之上。
|
||||
|
||||
**还能不能再压?试过三条路,都不行**(数字都是实测):
|
||||
|
||||
* **地址有关口径**(`r8forge --synth-chars`):**73940**,比 flat 多 316。理由见 SPEC §3.7
|
||||
—— 那个代价平移不变、库里的块又被几十个调用点共用,一份 `layout` 猜不准。
|
||||
* **单格搬家**:把 `T` 挪到 17、`DEPTH` 挪到 17、`HAVE`/`CNT` 挪到 52、`S2` 回 52,
|
||||
五种都更长(+182 / +2900 / +92 / +134 / +3810)。现在这张地图对"单格搬家"是局部最优。
|
||||
* **把借来的判据格挤进 20..29**(这一步做过,是唯一有效的一次):77164 → **73624**,
|
||||
−3.5k。教训是**热格必须挨着**(`clb_sub_nc` / `clb_nonzero` / `copy` 内部每一位都在走)。
|
||||
|
||||
|
||||
Reference in new issue
Block a user