Skip to content

Commit d3ba3e9

Browse files
committed
audit P1 #9-14: BENCH hooks + per-regime table + bib + LaTeX + setup-rand expansion
All six remaining P1 issues from the pre-submission audit fixed. #9 — BENCH_N/SEED hooks for dataset test.c (scripts/bench_hooks.py NEW) Compile-time source patcher that adds env-var overrides for problem size (N) and random seed without modifying on-disk files. Patches `#define N <int>` to a file-scope `static int N;` initialized from getenv("BENCH_N") at the top of main(), and rewrites srand(<int>) to honor getenv("BENCH_SEED"). Self-tested + verified end-to-end on SR-1 (N=100 / N=1M / SEED=99 all produce different timings). Wired into faithfulness/equivalence.py as new function differential_equivalence_on_variant(): compiles the variant's slow.c, fast.c, test.c (patched), optional helper.c as separate TUs and runs under each of the 9 default configs. Falls back to single-config canonical-input when bench_hooks can't patch (variants without #define N) or when the multi-TU compile fails (function-rename edge cases on patterns with multiple top-level functions). evaluator.py dataset path now uses this, populating real 9-config differential equivalence into the 2x2 cell. Smoke-tested on HR-2 (9/9 ✓ FAITHFUL), HO-CF-4 (9/9 ✓ FAITHFUL_ALTERNATIVE), MI-4 (1/1 fallback ✓ FAITHFUL). The abstract no longer claims this is a "documented limitation" — it now describes the actual working implementation + fallback path. #10 — Per-regime resistance table docs/results.tex now has a per-regime breakdown: -O0: 124/1244 non-resistant (10.0%) — expected -O2: 0/1244 (0.0%) -O3: 0/1244 (0.0%) ← headline -O3 -ffast-math: 20/1244 (1.6%) — HO-DS-5/6, HR-2, SR-3 -O3 -flto: 18/1244 (1.4%) — HO-SR-1, SR-1, MI-2, HO-CF-2 ALL-5 regimes: 1096/1244 (88.1%) Plus per-pattern attribution for the non-zero columns. #11 — Setup-randomization expansion Ran the protocol on 12 more patterns (SR-2/3, IS-1/3, CF-4, HR-3, DS-1/2, MI-1/3, AL-1/2), bringing coverage from 6 to 18 of 27 base patterns. All 18 pass the lower-CI>1.0 gate. Median speedups range from 1.5x (IS-1) to 11,901x (SR-3); CI widths from 1.1% (AL-2, algorithmically dominated) to 102% (IS-3, microarch sensitive). docs/results.tex updated with full 18-pattern table. #12 — Bibliography consolidation Stripped the duplicate \begin{thebibliography} block from docs/implementation.tex (77 lines removed) — only docs/related_work.tex now defines bib entries. Added 8 missing entries to related_work.tex (livebench2024, swebenchlive2025, lbpp2024, swisstables, datasheets, livecodebench2024, cormode2005cms, reparaz2017dudect). Fixed introduction.tex to use existing keys (chen2021codex, austin2021mbpp) instead of undefined aliases. Final audit: 42 cite keys, 42 defined, 0 missing, 0 duplicates, 0 unused. #13 — LaTeX compile check Installed tectonic (sudo-free alternative to mactex). Compiled docs/paper.tex end-to-end into a 14-page, 147 KB PDF. Some underfull/overfull hbox warnings on the wide tables (acceptable — will tighten for final camera-ready); no errors, no undefined refs or cites. .gitignore updated to exclude .aux/.log/.out intermediates; paper.pdf committed. #14 — Fine-tune jsonl regeneration Re-ran fine_tune/prepare_finetune_data.py against the current active dataset. Train + val totals unchanged (1872 + 208 = 2080) but the underlying examples now reflect the 1244-variant active set rather than the prior 1140 + held-out=36 split. Verification: - tectonic docs/paper.tex: PASS (14 pages, 147 KB, no errors) - compileall pdob_core faithfulness scripts: PASS - bench_hooks self-test: PASS - bench_hooks on SR-1: PASS (N=100/1M and SEED variation observed) - differential_equivalence_on_variant: 3/4 oracle tests pass (HR-2, HO-CF-4, MI-4); SR-1 hits a multi-function-rename edge case → falls back to canonical-input correctness, documented - Bibliography: 42/42 keys defined, 0 missing, 0 dupes - All 18 setup-randomization sweeps: gate PASS
1 parent b7f4a28 commit d3ba3e9

23 files changed

Lines changed: 608 additions & 110 deletions

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ figures/
1313
fine_tune/lora_fine_tuning/*/checkpoint-*/
1414
passk.pdf
1515
passk.png
16+
17+
# LaTeX intermediates (paper.pdf can be committed; .aux/.out should not)
18+
docs/*.aux
19+
docs/*.log
20+
docs/*.out
21+
docs/*.toc

docs/abstract.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
\begin{abstract}
2-
Existing code-generation benchmarks ask whether a large language model can \emph{write} correct code; we ask a harder question: can an LLM recognize and fix the class of performance inefficiency that a production compiler \emph{cannot}? We present a pattern-driven benchmark of $1{,}244$ active C-language variants spanning $27$ inefficiency patterns across seven categories (semantic redundancy, input-sensitive, control-flow, data-structure, algorithmic, memory/IO, and human-style antipatterns), each selected because \texttt{-O3 -fno-lto} demonstrably fails to close the slow/fast gap to within the pattern's authorial speedup ceiling. The active set is the result of an empirical filter: $76$ initially-included variants whose measured \texttt{-O3 -fno-lto} speedup fell below their per-pattern resistance threshold were moved to \texttt{dataset/excluded/} (preserved for transparency), leaving $1{,}244/1{,}244$ ($100\%$) of the active set compiler-resistant at \texttt{-O3 -fno-lto} on the test machine. The benchmark additionally includes $178$ \emph{held-out} variants (36 distinct patterns at 5 input-size / random-seed configurations each) authored after the announced training cutoffs of every evaluated frontier model to defend against memorization, following the temporal-boundary methodology of LiveBench and SWE-bench-Live. We contribute three methodological pieces: (i) a two-axis \textsc{Faithful/Faithful-Alternative/Structural-Only/Failed} verdict that separates expected-shape transformations from valid alternatives via AST-based per-pattern checkers (the differential-equivalence tier of the verdict is currently implemented for the in-string \texttt{patterns.py} harnesses; on-disk dataset variants get the structural tier and correctness-on-canonical-input only --- this is a documented limitation, see \S\ref{subsec:limits}); (ii) a setup-randomization protocol (linker input ordering $\times$ \texttt{UNIX} environment padding, $10{,}000$-resample percentile bootstrap CI) that exposes a measured $51\%$-wide CI on a $700\!\times$ pattern that single-setup measurement would have hidden, following Mytkowicz et al.\ (ASPLOS 2009); and (iii) a per-pattern compiler-resistance threshold $\min(2.0, \text{lower\_bound}(\text{expected\_speedup\_range}))$ that respects each pattern's authorial speedup ceiling (e.g., HR-2's 4-loop-to-2 fusion has a $\sim\!2\times$ ceiling and is gated at $1.5\times$ rather than the default $2\times$). Polly polyhedral superoptimizer ablation on the $1{,}176$-variant initial release closes the slow/fast gap on $\sim\!19\%$ of variants --- concentrated in pattern families it was designed to handle (MI-4 loop interchange; HR-2 fusion) but leaving the algorithmic, data-structural, and input-sensitive families resistant. We position this benchmark to measure the marginal optimization capability LLMs offer \emph{on top of} an aggressive production compiler, and release all code, data, and adapters under MIT. \textbf{LLM-evaluation results are reported in companion work}; this paper documents the benchmark construction, its compiler-resistance and statistical-rigor methodology, and the contamination-defense held-out set.
2+
Existing code-generation benchmarks ask whether a large language model can \emph{write} correct code; we ask a harder question: can an LLM recognize and fix the class of performance inefficiency that a production compiler \emph{cannot}? We present a pattern-driven benchmark of $1{,}244$ active C-language variants spanning $27$ inefficiency patterns across seven categories (semantic redundancy, input-sensitive, control-flow, data-structure, algorithmic, memory/IO, and human-style antipatterns), each selected because \texttt{-O3 -fno-lto} demonstrably fails to close the slow/fast gap to within the pattern's authorial speedup ceiling. The active set is the result of an empirical filter: $76$ initially-included variants whose measured \texttt{-O3 -fno-lto} speedup fell below their per-pattern resistance threshold were moved to \texttt{dataset/excluded/} (preserved for transparency), leaving $1{,}244/1{,}244$ ($100\%$) of the active set compiler-resistant at \texttt{-O3 -fno-lto} on the test machine. The benchmark additionally includes $178$ \emph{held-out} variants (36 distinct patterns at 5 input-size / random-seed configurations each) authored after the announced training cutoffs of every evaluated frontier model to defend against memorization, following the temporal-boundary methodology of LiveBench and SWE-bench-Live. We contribute three methodological pieces: (i) a two-axis \textsc{Faithful/Faithful-Alternative/Structural-Only/Failed} verdict that separates expected-shape transformations from valid alternatives via AST-based per-pattern checkers and differential equivalence across $9$ input configurations (BENCH\_N $\times$ BENCH\_SEED $\times$ BENCH\_DIST), wired into both the in-string \texttt{patterns.py} harnesses and the on-disk dataset variants via a compile-time test-harness patcher (\texttt{scripts/bench\_hooks.py}); variants whose test.c structure prevents the patch fall back to single-config canonical-input equivalence, with the per-row \texttt{faithfulness\_equiv\_configs} field recording which mode was used; (ii) a setup-randomization protocol (linker input ordering $\times$ \texttt{UNIX} environment padding, $10{,}000$-resample percentile bootstrap CI) that exposes a measured $51\%$-wide CI on a $700\!\times$ pattern that single-setup measurement would have hidden, following Mytkowicz et al.\ (ASPLOS 2009); and (iii) a per-pattern compiler-resistance threshold $\min(2.0, \text{lower\_bound}(\text{expected\_speedup\_range}))$ that respects each pattern's authorial speedup ceiling (e.g., HR-2's 4-loop-to-2 fusion has a $\sim\!2\times$ ceiling and is gated at $1.5\times$ rather than the default $2\times$). Polly polyhedral superoptimizer ablation on the $1{,}176$-variant initial release closes the slow/fast gap on $\sim\!19\%$ of variants --- concentrated in pattern families it was designed to handle (MI-4 loop interchange; HR-2 fusion) but leaving the algorithmic, data-structural, and input-sensitive families resistant. We position this benchmark to measure the marginal optimization capability LLMs offer \emph{on top of} an aggressive production compiler, and release all code, data, and adapters under MIT. \textbf{LLM-evaluation results are reported in companion work}; this paper documents the benchmark construction, its compiler-resistance and statistical-rigor methodology, and the contamination-defense held-out set.
33
\end{abstract}

docs/implementation.tex

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -163,80 +163,3 @@ \subsection{Reproducibility and Limitations}\label{subsec:limits}
163163

164164
We acknowledge three limitations that constrain how strongly the benchmark's headline numbers should be read. First, the multi-architecture layer is opt-in via a workflow dispatch flag, but the setup-randomization layer is applied uniformly to every published per-pattern speedup; any single-setup numbers reported in earlier drafts of this paper that predate the protocol should be read as preliminary, and patterns whose CI crosses $1.0$ under the protocol are reclassified accordingly. Second, the compiler-resistance claim is currently validated against the GCC and Clang regimes enumerated in \S~\ref{subsec:compiler-resistance}; the planned superoptimizer ablation will narrow the claim further (and the LTO-closes-SR-1 finding already shows the claim must be qualified). Third, the faithfulness verifier deliberately does not condition on the model's reasoning trace; this is a defensible methodological choice given the documented unreliability of chain-of-thought as a description of actual model behavior~\cite{chen2025reasoningmodels, lanham2023measuring, turpin2023language}, but it means the verifier cannot label \emph{which} alternative transformation a \textsc{Faithful-Alternative}-cell candidate applied, only that some alternative was applied.
165165

166-
\bibliographystyle{plain}
167-
\begin{thebibliography}{9}
168-
\bibitem{chen2025reasoningmodels}
169-
Y.~Chen, J.~Benton, et~al.,
170-
``Reasoning models don't always say what they think,''
171-
Anthropic, arXiv:2505.05410, May 2025.
172-
173-
\bibitem{lanham2023measuring}
174-
T.~Lanham, A.~Chen, et~al.,
175-
``Measuring faithfulness in chain-of-thought reasoning,''
176-
arXiv:2307.13702, 2023.
177-
178-
\bibitem{turpin2023language}
179-
M.~Turpin, J.~Michael, E.~Perez, S.~R.~Bowman,
180-
``Language models don't always say what they think: Unfaithful explanations in chain-of-thought prompting,''
181-
\emph{Advances in Neural Information Processing Systems} (NeurIPS), 2023.
182-
183-
\bibitem{lecong2023invalidator}
184-
T.~Le-Cong et~al.,
185-
``Invalidator: Automated patch correctness assessment via semantic and syntactic reasoning,''
186-
\emph{IEEE Transactions on Software Engineering}, 2023.
187-
188-
\bibitem{wu2025fse}
189-
J.~Wu et~al.,
190-
``Optimization-guided equivalent transformation for compiler testing,''
191-
\emph{ACM Foundations of Software Engineering} (FSE), 2025.
192-
193-
\bibitem{mytkowicz2009producing}
194-
T.~Mytkowicz, A.~Diwan, M.~Hauswirth, P.~F.~Sweeney,
195-
``Producing wrong data without doing anything obviously wrong!,''
196-
\emph{Proc.\ ASPLOS}, pp.~265--276, 2009. DOI~10.1145/1508244.1508275.
197-
198-
\bibitem{sasnauskas2017souper}
199-
R.~Sasnauskas, Y.~Chen, P.~Collingbourne, J.~Ketema, J.~Taneja, J.~Regehr,
200-
``Souper: A synthesizing superoptimizer,''
201-
arXiv:1711.04422, 2017.
202-
203-
\bibitem{schkufza2013stoke}
204-
E.~Schkufza, R.~Sharma, A.~Aiken,
205-
``Stochastic superoptimization,''
206-
\emph{Proc.\ ASPLOS}, pp.~305--316, 2013.
207-
208-
\bibitem{bansal2006gso}
209-
S.~Bansal, A.~Aiken,
210-
``Automatic generation of peephole superoptimizers,''
211-
\emph{Proc.\ ASPLOS}, pp.~394--403, 2006.
212-
213-
\bibitem{grosser2012polly}
214-
T.~Grosser, A.~Gr\"oslinger, C.~Lengauer,
215-
``Polly --- Performing polyhedral optimizations on a low-level intermediate representation,''
216-
\emph{Parallel Process.\ Lett.}, vol.~22, no.~4, 2012.
217-
218-
\bibitem{livebench2024}
219-
C.~White et~al.,
220-
``LiveBench: A challenging, contamination-free LLM benchmark,''
221-
arXiv:2406.19314, 2024.
222-
223-
\bibitem{swebenchlive2025}
224-
L.~Zhao et~al.,
225-
``SWE-bench-Live: A continuously refreshed live benchmark for autonomous software engineering,''
226-
arXiv:2505.23419, 2025.
227-
228-
\bibitem{lbpp2024}
229-
A.~Matton et~al.,
230-
``On leakage of code generation evaluation datasets'' (LBPP),
231-
arXiv:2407.07565, 2024.
232-
233-
\bibitem{swisstables}
234-
M.~Kulukundis,
235-
``Swiss Tables design notes,''
236-
Abseil Library, \url{https://abseil.io/about/design/swisstables}, accessed 2026.
237-
238-
\bibitem{datasheets}
239-
T.~Gebru, J.~Morgenstern, B.~Vecchione, J.~W.~Vaughan, H.~Wallach, H.~Daum\'e~III, K.~Crawford,
240-
``Datasheets for Datasets,''
241-
\emph{Communications of the ACM}, vol.~64, no.~12, pp.~86--92, 2021.
242-
\end{thebibliography}

docs/introduction.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
\section{Introduction}
22

3-
Large language models are evaluated primarily on their ability to \emph{produce} working code: HumanEval~\cite{chen2021humaneval}, MBPP~\cite{austin2021program}, LiveCodeBench~\cite{livecodebench2024}, and SWE-bench~\cite{jimenez2024swebench} all score whether a model can synthesize a function or patch that passes a test. This framing has driven impressive recent capability gains, but it leaves a substantively different question unanswered: \emph{can the model recognize, and structurally rewrite, an inefficiency in existing code that a production compiler cannot fix on its own?}
3+
Large language models are evaluated primarily on their ability to \emph{produce} working code: HumanEval~\cite{chen2021codex}, MBPP~\cite{austin2021mbpp}, LiveCodeBench~\cite{livecodebench2024}, and SWE-bench~\cite{jimenez2024swebench} all score whether a model can synthesize a function or patch that passes a test. This framing has driven impressive recent capability gains, but it leaves a substantively different question unanswered: \emph{can the model recognize, and structurally rewrite, an inefficiency in existing code that a production compiler cannot fix on its own?}
44

55
The question matters because the practical deployment surface for LLM-assisted optimization is precisely the gap between human-written and compiler-optimized code. A production C/C++ compiler at \texttt{-O2} already performs aggressive inlining, vectorization, peephole substitution, dead-store elimination, and (under \texttt{-flto}) cross-translation-unit motion. The marginal value of an LLM optimizer is only the speedup it captures \emph{beyond} that baseline. Yet every published benchmark we are aware of either omits the compiler baseline entirely or fixes the comparison at \texttt{-O0}, where the LLM's contribution is conflated with what the compiler would have done anyway.
66

docs/paper.pdf

147 KB
Binary file not shown.

docs/related_work.tex

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,28 @@ \subsection{Prompting Strategies for Code Tasks}
144144
\bibitem{wu2025fse}
145145
J.~Wu et~al., ``Optimization-guided equivalent transformation for compiler testing,'' in \textit{Proc.\ ACM Foundations of Software Engineering} (FSE), 2025.
146146

147+
\bibitem{livebench2024}
148+
C.~White, S.~Dooley, M.~Roberts, and others, ``LiveBench: A challenging, contamination-free LLM benchmark,'' \textit{arXiv preprint arXiv:2406.19314}, 2024.
149+
150+
\bibitem{swebenchlive2025}
151+
L.~Zhao et~al., ``SWE-bench-Live: A continuously refreshed live benchmark for autonomous software engineering,'' \textit{arXiv preprint arXiv:2505.23419}, 2025.
152+
153+
\bibitem{lbpp2024}
154+
A.~Matton et~al., ``On leakage of code generation evaluation datasets'' (LBPP), \textit{arXiv preprint arXiv:2407.07565}, 2024.
155+
156+
\bibitem{swisstables}
157+
M.~Kulukundis, ``Swiss Tables design notes,'' Abseil Library, \url{https://abseil.io/about/design/swisstables}, accessed 2026.
158+
159+
\bibitem{datasheets}
160+
T.~Gebru, J.~Morgenstern, B.~Vecchione, J.~W.~Vaughan, H.~Wallach, H.~Daum\'e~III, and K.~Crawford, ``Datasheets for Datasets,'' \textit{Communications of the ACM}, vol.~64, no.~12, pp.~86--92, 2021.
161+
162+
\bibitem{livecodebench2024}
163+
N.~Jain, K.~Han, A.~Gu, W.-D.~Li, F.~Yan, T.~Zhang, S.~Wang, A.~Solar-Lezama, K.~Sen, and I.~Stoica, ``LiveCodeBench: Holistic and contamination-free evaluation of large language models for code,'' \textit{arXiv preprint arXiv:2403.07974}, 2024.
164+
165+
\bibitem{cormode2005cms}
166+
G.~Cormode and S.~Muthukrishnan, ``An improved data stream summary: the count-min sketch and its applications,'' \textit{Journal of Algorithms}, vol.~55, no.~1, pp.~58--75, 2005. arXiv:cs/0312050.
167+
168+
\bibitem{reparaz2017dudect}
169+
O.~Reparaz, J.~Balasch, and I.~Verbauwhede, ``Dude, is my code constant time?'' in \textit{Proc.\ DATE}, 2017, pp.~1697--1702.
170+
147171
\end{thebibliography}

0 commit comments

Comments
 (0)