Asked whether the cache survives a change of CELL_SIZE, and looking at the key
turned up a real problem.
The key used to be params | mode | metric | the stat line's values | layout.
Every block in asm/ uses a stat line, which is why nothing had gone wrong yet,
but a block written with map leaves stat empty -- so two map blocks with the
same params/mode/metric hashed to the same entry, and the second one would have
been served the first one's program.
The key is now the resolved target table itself (every entry, per plane), which
is exactly what the search is given:
* params / CELL_SIZE is part of it, and the table covers all 2^params entries,
so blocks of different sizes cannot collide, and changing params in a block
simply misses and recomputes
* two blocks that describe the same table (map or stat, either spelling) now
share one entry
Also added kModelVersion to the key. Without it, changing the instruction
model later (say adding conjunctions) would keep serving programs that were
optimal for the old model. Bump it whenever the block set changes.
Cache files now start with a readable header, e.g.
# params 3 mode 0 metric 1
0 2 0
1 4 0
Re-warmed after the change: 7 entries, 885s (bit_raw_add again, 990M states).
asm/test.r8asm still 1666 characters, all seven derived tables still match the
old implementations bit for bit, and a second assembly hits the cache for all
seven and produces an identical tape.
6 lines
52 B
Plaintext
6 lines
52 B
Plaintext
# params 4 mode 0 metric 1
|
|
1 12 0
|
|
0 6 1
|
|
1 5 0
|
|
3 6 0
|