Synthesizing Performance Constraints for Evaluating and Improving Code Efficiency
Jun Yang, Cheng-Chi Wang, Bogdan Alexandru Stoica, Kexin Pei
TL;DR
This work tackles the challenge of evaluating and improving code efficiency in the era of LLM-driven code optimization by introducing WEDGE, a framework that couples contrastive performance constraint reasoning with coverage-guided fuzzing to synthesize and instrument performance-stressing tests. By extracting local, performance-characterizing constraints from contrastive execution traces and guiding fuzzing through constraint-aware mutators and checkers, WEDGE generates inputs that reveal nuanced bottlenecks beyond simple length-stressing. The resulting PerfForge benchmark demonstrates that these tests drive significantly stronger performance stress, improve the reliability of subsequent optimization workflows, and enable fairer comparisons across baseline approaches. The framework is validated on CodeContests problems, with extensive ablations and sensitivity analyses, and released publicly to foster future research in robust, performance-oriented code evaluation and optimization.
Abstract
Large Language Models (LLMs) have been increasingly used to optimize code efficiency. Evaluating their effectiveness and further suggesting optimization opportunities often rely on high-quality tests to demonstrate the performance bottlenecks presented in the program. However, existing approaches rely on a limited set of hand-curated inputs or LLM-generated uninteresting length-stressing tests, failing to reveal more nuanced optimization opportunities. We present WEDGE, a framework for generating performance-stressing input given the program under test. WEDGE synthesizes explicit performance-characterizing constraints in the form of branch conditions to partition the programs' execution space into performance-specific regions. When integrated with the coverage-guided fuzzer, reaching different regions introduces explicit rewards for test generation to explore inefficient implementations. Our evaluation shows that WEDGE introduces a significant slowdown compared to the tests in CodeContests and those claimed to be optimized by existing approaches. From the utility perspective, integrating our tests substantially improves the existing code optimization approaches that rely on test-driven execution feedback. We release PERFFORGE, the performance tests generated by WEDGE, to benchmark future approaches for efficient code generation at https://github.com/UChiSeclab/perfforge.
