Rust: query evaluation ~15× slower on 2.26.4 vs 2.26.3 (4 min → 45–60 min, type-inference/data-flow stage)

未关闭
#22,463 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
rust

调研方向

使用报告的 Rust workspace 比较 CodeQL bundle 2.26.3 和 2.26.4,并检查提交 52cbb679、e9bd6988、ce360c4f、5f76c946 和 1d6ac57d。如有需要,收集建议的 evaluator-log 或 tuple-counting 输出,然后确定 callback、rust-analyzer 或 macro 的更改是否能够解释该 regression。完成标准是确定原因以及受支持的 fix 或 tuning 选项。

由索引模型根据 Issue 内容生成。

描述

Description of the issue

After the CodeQL bundle moved from 2.26.3 to 2.26.4, Rust analysis of our workspace went from ~4 minutes to ~45–60 minutes per run, with no change on our side. The extra time is almost entirely in query evaluation — the type-inference / data-flow stage — not extraction.

Setup

  • GitHub code scanning default setup (so the bundle version is whatever the action ships; codeql-action v4.37.9 bumped the default bundle to 2.26.4 on 2026-08-26).
  • build-mode: none, ubuntu-latest hosted runner (2 vCPU, CODEQL_THREADS=2, CODEQL_RAM=6914).
  • Private Rust workspace: 15 crates, ~470k lines of Rust (roughly a third of that under tests/), ~720 packages in Cargo.lock, edition 2021. Standard async web-service stack — nothing exotic in the code.
  • The default query suite (36 queries).

What changed / what didn't

We compared the last run on 2.26.3 and the first run on 2.26.4:

  • Same github/codeql-action commit, same runner image.
  • Same commit of our code (identical merge base; no diff at all in Cargo.toml / Cargo.lock).
  • ~150 consecutive runs on 2.26.3 over the preceding four weeks: all 2–4 min. 50+ consecutive runs on 2.26.4 since: all 41–59 min. No overlap.

Timings from the job logs

Stage 2.26.3 2.26.4
total duration (Extract) 12.8 s 59 s
diagnostics/DataFlowConsistencyCounts 2m01s (slowest query) ~30 min
diagnostics/TypeInferenceConsistencyCounts 58 s ~17 min
diagnostics/SsaConsistencyCounts 50 s ~13 min
summary/NodesWithTypeAtLengthLimit < 1 s ~22 min
diagnostics/UnresolvedMacroCalls 6m11s
whole security/* data-flow batch (CWE-089/SqlInjection, CWE-312/CleartextLogging, CWE-319/UseOfHttp, CWE-327/BrokenCryptoAlgorithm, …) well under a minute each ~30 min each (shared batch)

So extraction got ~5× slower but is still small; evaluation of everything downstream of type inference got roughly 15–30× slower.

Suspected cause

Looking at the Rust changes between codeql-cli/v2.26.3 and codeql-cli/v2.26.4, the ones that touch the stage that regressed are:

  • 52cbb679 "Rust: Evaluate mayInvokeCallback in type inference stage"
  • e9bd6988 "Rust: Assume callbacks will be invoked in library functions"
  • the rust-analyzer upgrade to 0.0.328 (ce360c4f, 5f76c946) and the derive-macro expansion restore (1d6ac57d).

The first two look like they widen the call graph feeding type inference, which is consistent with every data-flow query slowing down together. Happy to be corrected — that's inferred from the commit list, not from profiling.

One other difference we noticed in the extractor output on 2.26.4: a handful of new macro expansion failed for '$crate::count' warnings on the metrics crate's counter!-style macros that did not appear on 2.26.3. Possibly unrelated, mentioning it in case it points at the rust-analyzer upgrade.

What would help

  • Is this a known regression in 2.26.4, and is there a tuning knob (e.g. an extractor option, or a way to cap the callback assumption) short of pinning the bundle?
  • If profiling output from a run would help, tell me what to collect (--evaluator-log / --tuple-counting etc.) and I'll attach it.

We can pin codeql-bundle-v2.26.3 via advanced setup in the meantime.

主要语言
CodeQL
星标
10.1k
派生
2.1k
平均合并
2 天 11 小时
30 天内合并 PR
129

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

github/codeql 的其他 Issue

查看 github/codeql 的全部 Issue

相似的 Issue

更多 Compilers Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。