Practical Code RAG at Scale: Task-Aware Retrieval Design Choices under Compute Budgets
Not on the map. Why?
Abstract (arXiv)
We study retrieval design for code-focused generation tasks under realistic compute budgets. Using two complementary tasks from Long Code Arena -- code completion and bug localization -- we systematically compare retrieval configurations across various context window sizes along three axes: (i) chunking strategy, (ii) similarity scoring, and (iii) splitting granularity. (1) For PL-PL, sparse BM25 with word-level splitting is the most effective and practical, significantly outperforming dense alternatives while being an order of magnitude faster. (2) For NL-PL, proprietary dense encoders (Voyager-3 family) consistently beat sparse retrievers, however requiring 100x larger latency. (3) Optimal chunk size scales with available context: 32-64 line chunks work best at small budgets, and whole-file retrieval becomes competitive at 16000 tokens. (4) Simple line-based chunking matches syntax-aware splitting across budgets. (5) Retrieval latency varies by up to 200x across configurations; BPE-based splitting is needlessly slow, and BM25 + word splitting offers the best quality-latency trade-off. Thus, we provide evidence-based recommendations for implementing effective code-oriented RAG systems based on task requirements, model constraints, and computational efficiency.
Key facts. Cited by 3 papers in the map (data through 7 Oct 2026). Builds on 28 of its 38 references that are in the map. First posted on arXiv 23 Oct 2025.
Builds on
28 of 38 references.
References · 28
- 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,160
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,286
- 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 600
- 2022Large Language Models Struggle to Learn Long-Tail Knowledgecited by 452
- 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 357
- 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 355
- 2022DocPrompting: Generating Code by Retrieving the Docscited by 151
- 2021SPLADE v2: Sparse Lexical and Expansion Model for Information Retrievalcited by 126
- 2022ReACC: A Retrieval-Augmented Code Completion Frameworkcited by 117
- 2023Dense X Retrieval: What Retrieval Granularity Should We Use?cited by 88
- 2024Repoformer: Selective Retrieval for Repository-Level Code Completioncited by 55
- 2024Long Code Arena: a Set of Benchmarks for Long-Context Code Modelscited by 48
16 more
- 2023RAP-Gen: Retrieval-Augmented Patch Generation with CodeT5 for Automatic Program Repaircited by 43
- 2024Is Semantic Chunking Worth the Computational Cost?cited by 43
- 2024Dataflow-Guided Retrieval Augmentation for Repository-Level Code Completioncited by 40
- 2025A Systematic Review of Key Retrieval-Augmented Generation (RAG) Systems: Progress, Gaps, and Future Directionscited by 30
- 2021A Proposed Conceptual Framework for a Representational Approach to Information Retrievalcited by 24
- 2024ChunkRAG: Novel LLM-Chunk Filtering Method for RAG Systemscited by 22
- 2024Rewriting the Code: A Simple Method for Large Language Model Augmented Code Searchcited by 17
- 2025GraphCodeAgent: Dual Graph-Guided LLM Agent for Retrieval-Augmented Repo-Level Code Generationcited by 17
- 2025cAST: Enhancing Code Retrieval-Augmented Generation with Structural Chunking via Abstract Syntax Treecited by 17
- 2024Prompt-based Code Completion via Multi-Retrieval Augmented Generationcited by 16
- 2024METIS: Fast Quality-Aware RAG Systems with Configuration Adaptationcited by 16
- 2024Towards Understanding Systems Trade-offs in Retrieval-Augmented Generation Model Inferencecited by 15
- 2023The Devil is in the Tails: How Long-Tailed Code Distributions Impact Large Language Modelscited by 8
- 2025Enhancing Retrieval Augmented Generation with Hierarchical Text Segmentation Chunkingcited by 7
- 2022Better Than Whitespace: Information Retrieval for Languages without Custom Tokenizerscited by 3
- 2024Multi-View Adaptive Contrastive Learning for Information Retrieval Based Fault Localizationcited by 1
Built on by
Citing papers per year: 2026: 3.
3 papers.
- 2026A Systematic Investigation of Document Chunking Strategies and Embedding Sensitivitycited by 3
- 2026How Does Chunking Affect Retrieval-Augmented Code Completion? A Controlled Empirical Studycited by 0
- 2026The Recall Trap: A Recall-Maximizing Retriever Configuration Reduces Issue Resolution in Fixed-Budget Code Contextcited by 0
- 2026The Recall Trap: A Recall-Maximizing Retriever Configuration Reduces Issue Resolution in Fixed-Budget Code Context14 Aug 2026
- 2026How Does Chunking Affect Retrieval-Augmented Code Completion? A Controlled Empirical Study6 May 2026
- 2026A Systematic Investigation of Document Chunking Strategies and Embedding Sensitivity7 Mar 2026
Similar, not cited
Close in wording, no citation either way
- 2026Do Not Treat Code as Natural Language: Implications for Repository-Level Code Generation and Beyond
- 2025Impact-driven Context Filtering For Cross-file Code Completion
- 2024A Lightweight Framework for Adaptive Retrieval In Code Completion With Critique Model
- 2024Evaluating the Effectiveness and Efficiency of Demonstration Retrievers in RAG for Coding Tasks
- 2024Retrieval-augmented code completion for local projects using large language models
- 2026Better Call Grep: Evaluating and Improving Grep-Like Lexical Retrieval for Repository-Level Code Completion
- 2026Not All RAGs Are Created Equal: A Component-Wise Empirical Study for Software Engineering Tasks
- 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?