mirror of
https://github.com/mostlygeek/llama-swap.git
synced 2026-09-07 16:37:22 +02:00
Compile matrix DSL expressions into an immutable AST/DAG and evaluate only the requested and running models when choosing evictions. This removes eager Cartesian expansion and the maxDSLExpansions limit. - move DSL parsing and symbolic evaluation into internal/matrix - resolve aliases and link named references during compilation - project each runtime query onto target and running-model bitsets - memoize AST nodes and prune duplicate or dominated mask states - preserve ordered tie-breaking and reconstruct full witness sets - use symbolic containment for spillover selector validation - compile programmatic matrix configurations on router creation - document the design, complexity, and concurrency guarantees - test one million theoretical combinations and over 64 models - benchmark 100, 1K, 10K, and 100K theoretical combinations Benchmarks ran on QEMU Virtual CPU 2.5+ with three 500 ms samples. At 10K theoretical combinations: - validation: 9.71 ms, 6.53 MB, and 81,401 allocs before; 12.38 us, 14.3 KB, and 122 allocs after - solver setup: 1.31 ms and 1.37 MB before; 22.4 ns and 16 B after - eviction solve: 809 us and 16 B before; 9.04 us and 7.97 KB after At 100K theoretical combinations with the symbolic implementation: - validation: 15.10 us, 16.1 KB, and 149 allocs - solver setup: 23.6 ns, 16 B, and one allocation - eviction solve: 16.17 us, 13.7 KB, and 193 allocs At 100 combinations, solve time increases from 3.07 us to 4.72 us, and allocation rises from 16 B to 3.82 KB. At 1K combinations, solve time drops from 50.8 us to 7.23 us. Written to GPT 5.6-Sol (high). Verified and reviewed with Opus 5 and Kimi K3. I don't understand what's going because these models know more than me on writing a DSL compiler. fixes #951