Breakwater

Codeflash / patterns#9

⚡️ Speed up function validate_regex by 9,172%

fabriziosalmi/patterns#9 · merged 2025-02-09 · base 1a98411808 → head 1a4a2d4e42 · ran on Sandboxes

PASS

No behaviour divergence found by any probe.

Performance · validate_regex

No realistic input family measured slower.

head slowerhead faster0.21×0.25×0.3×0.35×0.42×0.5×0.59×0.71×0.84×1×101001,000input size (characters)F2F2: 0.23× at ~9 charsF2: 0.23× at ~11 charsF2: 0.23× at ~23 charsF2: 0.23× at ~71 charsF2: 0.23× at ~263 charsF2: 0.25× at ~1,031 charsF2: 0.31× at ~4,103 chars
  • F2
Head/base cachegrind instructions per call, by input size (log-log). Each line is one input family Nemotron proposed; points above 1× are where the "faster" code does more work.
FamilyInputsRatio range Slope base → headVerdict
F2Repeated identical regex patterns (duplicates). The cache returns the compiled‑result on the 2nd…Nth call, so total time grows only with the first compilation.claimed speedup · plan0.23× – 0.31×0.01 → 0.05faster

Receipt

TargetBackendImageRun AuditAdjudication
json2haproxy:validate_regexToken Factory Sandboxesbcc79688-d7fb-4ce5-921c-c5f853d78731bt-patterns#9-728c64$0.031$0.000

Nemotron cost on Nebius Token Factory. Backend: where the untrusted code ran. Token Factory Sandboxes (a microVM branched from a kept image, cited by its UUID). Every image is content-addressed (repo at each commit + harness), so every card re-runs from the image and seed 0. Raw data: audit.