arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2601.01215cs.SEcs.AI
收藏

正确性不等于效率:LLM生成代码的运行时内存分歧

Correctness isnt Efficiency: Runtime Memory Divergence in LLM-Generated Code

University of Luxembourg(卢森堡大学)

Prateek Rajput, Yewei Song, Abdoul Aziz Bonkoungou, Iyiola E. Olatunji, Abdoul Kader Kabore, Jacques Klein, Tegawendé F. Bissyandé

AI总结:

研究发现LLM生成代码在运行时存在内存稳定性差异,提出DMPD方法评估不同解的稳定性,实验显示正确解间存在显著运行时分歧,且稳定性与软件工程指标相关,支持在CI/CD中选择稳定解以降低风险。

摘要:

大型语言模型(LLMs)可以生成通过单元测试的程序,但通过测试并不保证可靠的运行时行为。我们发现,解决同一任务的不同正确解可以表现出非常不同的内存和性能模式,这可能导致隐藏的操作风险。我们提出一个框架,用于在多个正确生成之间测量执行时间的内存稳定性。在解决方案层面,我们引入了动态均值成对距离(DMPD),它使用动态时间规整来比较将内存使用轨迹转换为单调峰值轮廓(MPPs)后的形状,以减少瞬态噪声。在任务层面,将DMPD聚合得到模型不稳定度评分(MIS)。在BigOBench和CodeContests上的实验显示,正确解之间存在显著的运行时分歧。不稳定性往往随着采样温度的增加而增加,即使pass@1有所改善。我们还观察到我们的稳定性指标与软件工程指标如认知复杂度和循环复杂度之间的相关性,这表明操作行为与可维护性之间存在联系。我们的结果支持在CI/CD中选择具有稳定性的通过候选者,以在不牺牲正确性的情况下减少操作风险。相关成果可供查阅。

英文摘要:

Large language models (LLMs) can generate programs that pass unit tests, but passing tests does not guarantee reliable runtime behavior. We find that different correct solutions to the same task can show very different memory and performance patterns, which can lead to hidden operational risks. We present a framework to measure execution-time memory stability across multiple correct generations. At the solution level, we introduce Dynamic Mean Pairwise Distance (DMPD), which uses Dynamic Time Warping to compare the shapes of memory-usage traces after converting them into Monotonic Peak Profiles (MPPs) to reduce transient noise. Aggregating DMPD across tasks yields a model-level Model Instability Score (MIS). Experiments on BigOBench and CodeContests show substantial runtime divergence among correct solutions. Instability often increases with higher sampling temperature even when pass@1 improves. We also observe correlations between our stability measures and software engineering indicators such as cognitive and cyclomatic complexity, suggesting links between operational behavior and maintainability. Our results support stability-aware selection among passing candidates in CI/CD to reduce operational risk without sacrificing correctness. Artifacts are available.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑