compare-gradle-builds
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCompare Gradle Builds
对比Gradle构建
Quick Start
快速开始
You'll typically receive two build identifiers (IDs, dashboard URLs, or branch names). Follow these steps using the Tuist MCP tools:
- Use to find builds on each branch.
list_gradle_builds - Use for both base and head builds.
get_gradle_build - Use to fetch task-level details for both builds.
list_gradle_build_tasks - Compare duration, status, cache hit rates, and task outcomes.
- Summarize regressions, improvements, and recommendations.
If only one identifier is provided, use the project's default branch as the baseline.
你通常会收到两个构建标识符(ID、仪表板URL或分支名称)。使用Tuist MCP工具按照以下步骤操作:
- 使用查找各分支上的构建。
list_gradle_builds - 对基准构建(base)和目标构建(head)分别使用。
get_gradle_build - 使用获取两个构建的任务级详细信息。
list_gradle_build_tasks - 对比时长、状态、缓存命中率和任务结果。
- 总结退化点、改进点及建议。
如果仅提供一个标识符,则使用项目的默认分支作为基准。
Step 1: Resolve Builds
步骤1:解析构建
If base/head are build IDs or dashboard URLs
若基准/目标为构建ID或仪表板URL
Fetch each directly with .
get_gradle_build(build_run_id: "<id>")直接使用获取每个构建。
get_gradle_build(build_run_id: "<id>")If base/head are branch names
若基准/目标为分支名称
List recent builds on each branch and pick the latest:
list_gradle_builds(account_handle: "...", project_handle: "...", git_branch: "<branch>", page_size: 1)Then fetch full details with .
get_gradle_build(build_run_id: "<id>")列出各分支上的近期构建并选择最新的一个:
list_gradle_builds(account_handle: "...", project_handle: "...", git_branch: "<branch>", page_size: 1)然后使用获取完整详情。
get_gradle_build(build_run_id: "<id>")Defaults
默认规则
- If no base is provided, use the project's default branch (usually ).
main - If no head is provided, detect the current git branch with .
git rev-parse --abbrev-ref HEAD
- 若未提供基准构建,则使用项目的默认分支(通常为)。
main - 若未提供目标构建,则使用检测当前git分支。
git rev-parse --abbrev-ref HEAD
Step 2: Compare Top-Level Metrics
步骤2:对比顶层指标
After fetching both builds, compare:
| Metric | What to check |
|---|---|
| Flag if head is >10% slower than base |
| Flag if base succeeded but head failed |
| Compare local cache hit counts |
| Compare remote cache hit counts |
| Compare how many tasks ran (higher means more cache misses) |
| Note if the cacheable task count changed |
| |
| Ensure both builds ran the same tasks for a fair comparison |
| Note environment differences that affect comparability |
Compute the cache miss delta: . Positive means head has fewer executions (improvement). Negative means regression.
base_executed - head_executed获取两个构建后,对比以下内容:
| 指标 | 检查要点 |
|---|---|
| 若目标构建比基准构建慢10%以上则标记 |
| 若基准构建成功但目标构建失败则标记 |
| 对比本地缓存命中次数 |
| 对比远程缓存命中次数 |
| 对比运行的任务数量(数值越高表示缓存未命中越多) |
| 记录可缓存任务数量是否有变化 |
| 计算公式: |
| 确保两个构建运行相同的任务以保证对比公平 |
| 记录影响可比性的环境差异 |
计算缓存未命中差值:。正数表示目标构建执行任务更少(有改进),负数表示出现退化。
基准执行数 - 目标执行数Step 3: Drill Into Tasks
步骤3:深入分析任务
Use for both builds. Compare and per task path.
list_gradle_build_tasksduration_msoutcomeLook for:
- Tasks that changed from or
local_hittoremote_hit(cache invalidation).executed - Tasks that changed from to
executedorlocal_hit(cache improvement).remote_hit - Tasks that changed to (new failures).
failed - New tasks that appeared in the head build.
- Tasks with significant duration increases.
Sort by absolute time difference to find the biggest regressions.
对两个构建使用。按任务路径对比和。
list_gradle_build_tasksduration_msoutcome重点关注:
- 从或
local_hit变为remote_hit的任务(缓存失效)。executed - 从变为
executed或local_hit的任务(缓存优化)。remote_hit - 变为的任务(新失败项)。
failed - 目标构建中新增的任务。
- 时长显著增加的任务。
按绝对时间差排序,找出最严重的退化项。
Filtering tasks
任务过滤
Use the filter to focus on specific task states:
outcome- to see only executed tasks.
list_gradle_build_tasks(build_run_id: "<id>", outcome: "executed") - to see failures.
list_gradle_build_tasks(build_run_id: "<id>", outcome: "failed") - to see only cacheable tasks.
list_gradle_build_tasks(build_run_id: "<id>", cacheable: true)
使用过滤器聚焦特定任务状态:
outcome- 查看仅执行的任务。
list_gradle_build_tasks(build_run_id: "<id>", outcome: "executed") - 查看失败任务。
list_gradle_build_tasks(build_run_id: "<id>", outcome: "failed") - 查看仅可缓存任务。
list_gradle_build_tasks(build_run_id: "<id>", cacheable: true)
Step 4: Investigate Duration Regressions
步骤4:调查时长退化
If the head build is significantly slower:
- Check if differ (different task sets are not directly comparable).
requested_tasks - Check if cache hit rate dropped, which would explain longer builds.
- Look for tasks that changed from cache hits to .
executed - Check if or
gradle_versionchanged, which can affect performance.java_version - Compare individual task durations to find the biggest contributors.
若目标构建明显变慢:
- 检查是否不同(不同任务集无法直接对比)。
requested_tasks - 检查缓存命中率是否下降,这可能是构建时长增加的原因。
- 查找从缓存命中变为的任务。
executed - 检查或
gradle_version是否变更,这会影响性能。java_version - 对比单个任务的时长,找出最大影响因素。
Step 5: Investigate Cache Changes
步骤5:调查缓存变化
Compare task-level cache behavior:
- Hit rate dropped: Possible causes include dependency changes, build configuration changes, or Gradle version updates that alter cache keys.
- Hit rate improved: Likely due to better cache warming or fewer source changes.
- Task count changed: New modules or tasks added/removed.
- Outcome changes: Tasks moving between ,
up_to_date,local_hit, andremote_hitreveal cache effectiveness.executed
对比任务级缓存行为:
- 命中率下降:可能原因包括依赖变更、构建配置变更或Gradle版本更新导致缓存键改变。
- 命中率提升:可能是由于缓存预热更充分或源代码变更更少。
- 任务数量变化:新增或移除了模块或任务。
- 结果变化:任务在、
up_to_date、local_hit和remote_hit之间的转换反映了缓存的有效性。executed
Step 6: Check Build Context
步骤6:检查构建上下文
Compare environment details:
- and
gradle_version: Different versions can affect build times and cache validity.java_version - : CI vs local builds may have different performance characteristics.
is_ci - and
git_branch: Verify the builds are from the expected commits.git_commit_sha - : Ensure both builds are from the same project structure.
root_project_name
对比环境详情:
- 和
gradle_version:不同版本会影响构建时长和缓存有效性。java_version - :CI构建与本地构建的性能特征可能不同。
is_ci - 和
git_branch:验证构建是否来自预期的提交。git_commit_sha - :确保两个构建来自相同的项目结构。
root_project_name
Summary Format
总结格式
Produce a summary with:
- Overall verdict: Better, worse, or neutral compared to base.
- Duration: Absolute and percentage change in .
duration_ms - Cache hit rate: Change in hit rate with explanation.
- Task outcomes: Notable outcome changes (hit to executed, new failures).
- Status: Any status changes (success to failure or vice versa).
- Environment: Note any environment differences that affect comparability.
- Recommendations: Actionable next steps based on findings.
Example:
Build Comparison: base (abc123 on main) vs head (def456 on feature-x)
Duration: 45200ms -> 62800ms (+39%) -- REGRESSION
Cache hit rate: 85% -> 72% (-13%) -- 8 tasks went from cache hit to executed
Status: success -> success
Root cause: Cache hit rate dropped because 8 tasks had invalidated caches.
The :app:compileKotlin task changed from remote_hit to executed,
cascading to 7 downstream tasks.
Recommendations:
- Investigate which source changes invalidated :app:compileKotlin cache
- Consider splitting large modules to reduce cache invalidation cascading生成包含以下内容的总结:
- 整体结论:与基准构建相比更好、更差或无变化。
- 时长:的绝对变化和百分比变化。
duration_ms - 缓存命中率:命中率变化及原因说明。
- 任务结果:值得注意的结果变化(从命中变为执行、新失败项等)。
- 状态:任何状态变化(从成功到失败或反之)。
- 环境:记录影响可比性的环境差异。
- 建议:基于发现的可操作后续步骤。
示例:
Build Comparison: base (abc123 on main) vs head (def456 on feature-x)
Duration: 45200ms -> 62800ms (+39%) -- REGRESSION
Cache hit rate: 85% -> 72% (-13%) -- 8 tasks went from cache hit to executed
Status: success -> success
Root cause: Cache hit rate dropped because 8 tasks had invalidated caches.
The :app:compileKotlin task changed from remote_hit to executed,
cascading to 7 downstream tasks.
Recommendations:
- Investigate which source changes invalidated :app:compileKotlin cache
- Consider splitting large modules to reduce cache invalidation cascadingDone Checklist
完成检查清单
- Resolved both base and head builds
- Compared duration, cache, and status metrics
- Drilled into task-level outcomes for both builds
- Identified root causes for any regressions
- Provided actionable recommendations
- 已解析基准和目标构建
- 已对比时长、缓存和状态指标
- 已深入分析两个构建的任务级结果
- 已识别任何退化的根本原因
- 已提供可操作的建议