mirror of
https://github.com/luxfi/lattice.git
synced 2026-09-24 00:25:44 +00:00
Fans N independent (*Evaluator).Evaluate calls across a goroutine pool of GOMAXPROCS workers. Each worker owns a fresh NewEvaluator clone because the receiver carries mutable scratch buffers (poolMod2N, accumulator) and the package exposes no ShallowCopy. The BRK key set is shared read-only. Per-iteration output is byte-equal to a serial Evaluate call. Measured 4.61x at N=16 on M1 Max P-cores with blindrot test params (LogN=10/9, Q=0x7fff801). Geometry matches the 5.84x ceiling documented in fhe/policy/PERFORMANCE.md section 4 at full bootstrap params; the gap is the relative weight of per-worker NewEvaluator allocation against the cheaper test bootstrap. Tests: - TestBatchEvaluate_ByteEqualSerial: N=16 byte-equal vs serial - TestBatchEvaluate_Empty: nil in -> nil out - TestBatchEvaluate_Single: N=1 equivalent to direct Evaluate - TestBatchEvaluate_LengthMismatch: rejects mismatched len(testPolys) - TestBatchEvaluate_RaceClean: passes -race