Skip to content

mem: the compact rules read call directly, not a renamed copy of it - #72

Merged
vic merged 1 commit into
mainfrom
mem-no-scall
Nov 12, 2026
Merged

vic merged 1 commit into
mainfrom
mem-no-scall

Conversation

@vic

@vic vic commented Nov 12, 2026

Copy link
Copy Markdown
Owner

The compact rules of --mem read a relation scall, which Mem.sFacts filled with a renamed copy of every call fact: 10,402 extra input facts on s2c. The rules now read call itself, and Mem.SCallR is gone.

Measured on s2c compiling itself, both compilers on the same input (perf stat -e instructions:u, twice each):

run before after
normal compile 523,737,296 523,737,243
--mem 1,399,031,005 1,389,276,884 (-0.70%)

Checks:

  • --mem on s2c is byte-identical, and the C, stderr and exit code of 830 outputs (prog, cok, cneg, neg, self) are identical.
  • s2c reaches its fixpoint and the seed is updated.

Mutants (call args swapped in one rule; each builds):

rule killed by
need(F) :- call(F, G), unb(G) mem/compact, mem/many, mem/reuse
runSink(F) :- call(F, G), runSink(G) mem/compact
unb(F) :- call(F, G), unb(G) mem/compact (new case C.deep at line 52)

The third mutant survived the old tests (the gap was there with scall too): no test had a def that is unbounded only through a callee two calls down. C.deep calls C.count, which calls the unbounded CL.build; it is a compact candidate only when unbounded goes up the call chain.

Also measured and not landed: grouping the Mem facts by relation (an SMap group-by) before the solve, so that D.load gets long runs, made --mem 1.2% slower: the group-by costs more than the runs save.

@vic
vic merged commit 7f1bcc2 into main Nov 12, 2026
3 checks passed
@vic
vic deleted the mem-no-scall branch November 17, 2026 16:48
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