Chunk 16.0

This chunk serves as a comprehensive technical post-mortem and status report for Phase 4 of the `cuzk` project, a pipelined SNARK proving engine for Filecoin. The primary tasks were optimizing synthesis hot paths and GPU wrapper overhead for 32 GiB PoRep C2 proofs on a specific AMD Zen4 CPU and RTX 5070 Ti GPU. A defining theme of this phase was its rigorous, empirical methodology: every optimization was subjected to detailed microbenchmarking and `perf stat` analysis (tracking IPC, cache misses, and branch mispredicts) before being accepted or rejected, with several promising ideas being cancelled or reverted after real hardware disproved them. Phase 4 yielded two major validated wins. The `Boolean::add_to_lc` optimization eliminated temporary allocations in circuit gadgets, reducing synthesis time by 8.3% (55.4s → 50.9s). The critical discovery of synchronous destructor overhead—where freeing ~167 GB of C++ and Rust vectors caused a 10-second GPU wrapper delay—was fixed via async deallocation on detached threads, dropping GPU wrapper time from 36s to 26.2s. Equally important were the empirically disproven hypotheses: `SmallVec` was rejected due to an 8.5% IPC regression on Zen4, `cudaHostRegister` was reverted for adding 5.7s of `mlock` overhead, and Vec pre-allocation (capacity hints) showed zero measurable impact, confirming that allocation costs are already amortized during parallel computation. The net result of Phase 4 was a 13.4% improvement in total proof time (88.9s → 77.0s), falling short of the projected 2-3x target. A detailed `perf` profile confirmed the synthesis bottleneck (~50.8s) is now purely computational (field arithmetic and LC construction), not memory-bound. This data-driven conclusion explicitly paves the way for Phase 5 (Pre-Compiled Constraint Evaluator), which aims to replace circuit synthesis with a sparse matrix-vector multiply to achieve the desired throughput gains. The chunk meticulously documents all technical debts, cancelled experiments, and the precise performance landscape, acting as a definitive handoff for the next phase of development.

From Micro-Optimization to Architectural Change: How Phase 4 of cuzk Forged the Path to Phase 5 2611 words

Message Articles