LONGCODEU: Benchmarking Long-Context Language Models on Long Code Understanding

Jia Li, Xuyuan Guo, Lei Li, Kechi Zhang, Ge Li, Zhengwei Tao, Fang Liu, Chongyang Tao, Yuqi Zhu, Zhi JinarXiv 2025 · DOI

Abstract

As Large Language Models (LLMs) evolve to support context windows exceeding 128K tokens, their ability to process and reason over massive codebases has become a critical frontier. However, existing benchmarks often rely on synthetic data or simple retrieval tasks that do not reflect the complexity of real-world software engineering. This paper introduces LONGCODEU, a comprehensive benchmark designed to evaluate Long-Context Language Models (LCLMs) across four hierarchical levels of code understanding. Utilizing 116 real-world Python repositories created after June 2024 to ensure data freshness, our evaluation of nine state-of-the-art models reveals a significant "32K Wall"—a performance plateau where model efficacy drops precipitously as context length increases beyond 32,000 tokens.

Introduction

The advent of Long-Context Language Models (LCLMs) like Gemini 1.5 and GPT-4o has promised a paradigm shift in software development, potentially allowing AI to "read" entire repositories in a single prompt. Despite these claims, evaluating these models on code remains a significant challenge. Current benchmarks typically suffer from three primary issues: a lack of realism due to synthetic data construction, data contamination from training sets, and a focus on simple "needle-in-a-haystack" retrieval rather than deep structural reasoning.

To address these gaps, researchers from Peking University developed LONGCODEU. This benchmark moves beyond simple retrieval to test how models handle the complex web of dependencies and semantic relationships found in professional software projects.

The LONGCODEU Framework

Dataset Construction

The researchers curated a dataset of 116 real-world Python repositories from GitHub, specifically selecting projects created after June 2024 to minimize the risk of the models having seen the code during their initial training. This resulted in a benchmark of 3,983 tasks with context lengths distributed from 0 to 128K tokens.

Hierarchical Evaluation Aspects

LONGCODEU evaluates models across four distinct levels of complexity:

  1. Code Unit Perception: Identifying all functions or definitions within a long file.
  2. Intra-Code Unit Understanding: Tracing data flow or explaining logic within a specific function.
  3. Inter-Code Unit Relation Understanding: Identifying call graphs and finding semantically similar code across the repository.
  4. Long Documentation Understanding: Interpreting specific API documentation buried within massive technical texts.

Performance is measured using a variety of metrics, including Exact Match (EM) for line-level tasks, Longest Common Subsequence (LCS) for function names, and CodeBLEU/BLEU for semantic and documentation tasks.

Key Findings

The "32K Wall"

One of the most significant insights from the study is the disparity between advertised context windows and actual performance. While many models claim to support 128K or even 1M tokens, their performance on complex code tasks drops dramatically once the input exceeds 32K tokens. For tasks involving dependency relation analysis in the 64K–128K range, many models' scores plummeted to near zero, suggesting that current architectures still struggle with long-range structural dependencies.

Relations vs. Retrieval

The benchmark highlights that models are relatively proficient at "perception" (finding a specific function), but struggle significantly with Inter-Code Unit Relation Understanding. Tracing how different parts of a codebase interact is identified as the most challenging aspect for current AI, requiring a level of reasoning that simple retrieval-augmented generation (RAG) or long-context windows have yet to master.

Model Comparisons

  • Proprietary Leaders: GPT-4o and Gemini 1.5 Flash emerged as the strongest overall performers, particularly in documentation tasks and complex reasoning.
  • Open-Source Performance: DeepSeek-V2.5 was the most capable open-source model, though it still trailed proprietary models at the highest context lengths.
  • Specialized Efficiency: Small, specialized models like Qwen2.5-Coder (7.6B) demonstrated high efficiency, often outperforming much larger general-purpose models on shorter code tasks (under 16K tokens).

Conclusion and Future Work

LONGCODEU serves as a necessary reality check for the industry, demonstrating that a large context window does not inherently equate to deep understanding. While models are improving, the "32K Wall" remains a formidable barrier for real-world repository-level reasoning.

Future iterations of the benchmark aim to expand beyond Python to include languages like Java and C++, and to stress-test models claiming context windows in the millions of tokens. As AI continues to integrate into the developer workflow, benchmarks like LONGCODEU will be essential for distinguishing true reasoning capabilities from simple pattern matching.

Summary updated

BibTeX
@misc{li2025longcodeu,
  author = {Jia Li and Xuyuan Guo and Lei Li and Kechi Zhang and Ge Li and Jia Li and Zhengwei Tao and Fang Liu and Chongyang Tao and Yuqi Zhu and Zhi Jin},
  title = {{LONGCODEU: Benchmarking Long-Context Language Models on Long Code Understanding}},
  year = {2025},
  eprint = {2503.04359},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2503.04359},
}
Figure