Skip to content

Eliminate ~226 redundant source compilations; use ccache and nproc for local builds#2501

Closed
Copilot wants to merge 4 commits intoros2from
copilot/improve-build-time-efficiency
Closed

Eliminate ~226 redundant source compilations; use ccache and nproc for local builds#2501
Copilot wants to merge 4 commits intoros2from
copilot/improve-build-time-efficiency

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 23, 2026

Description

Build times were unnecessarily long because executables recompiled all library source files instead of linking against the already-built shared library. Across 7 packages, this caused ~226 extra .cpp compilations per clean build on top of ~194 unique source files.

Source duplication fixes — executables now target_link_libraries against their package library:

  • rj_strategy: 27 src × 5 executables = 135 compilations eliminated
  • rj_ui: 18 src × 2 executables = 36 eliminated
  • rj_planning: 27 src × 1 executable = 27 eliminated
  • rj_vision_filter: 18 src × 1 executable = 18 eliminated
  • rj_referee: 3 src × 2 executables = 6 eliminated
  • rj_control: 2 src × 1 executable = 2 eliminated
  • rj_radio: extracted rj_radio_base shared lib for radio.cpp = 1 eliminated

Before:

add_executable(planner_node
  ${RJ_PLANNING_SRC}   # recompiles all 27 files
  src/main.cpp
)

After:

add_executable(planner_node
  src/main.cpp
)
target_link_libraries(planner_node PRIVATE ${PROJECT_NAME})

CI workflow (ci.yml) — from previous commits on this branch:

  • Switched to pre-built robojackets/robocup-software:humble image (skips ubuntu-setup)
  • Added actions/cache-backed ccache with -g1 debug symbols
  • Shallow clone (fetch-depth: 1)

Makefile:

  • Auto-detect ccache and inject --cmake-args for compiler launcher
  • Use nproc for local parallel workers instead of hardcoded 4
  • docker_ci.yml now rebuilds image on util/ubuntu-setup, ubuntu-packages.txt, requirements3.txt changes

Associated Issue

Build times from scratch are too long, especially in resource-constrained Docker containers.

Steps to test

  1. make clean && make all — verify clean build completes with fewer total compilations
  2. Check that all executables link and run (e.g. ./install/lib/rj_strategy/kicker_picker_node --help)
  3. On a machine with ccache: ccache -s before and after build to confirm cache hits on rebuild

Expected result: Clean build compiles ~194 source files instead of ~420. Rebuild with ccache is near-instant.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 23, 2026 01:55
…g info

- ci.yml: Use robojackets/robocup-software:humble (pre-built deps) instead
  of osrf/ros:humble-desktop-full + ubuntu-setup on every run
- ci.yml: Add ccache with actions/cache for persistent build caching
- ci.yml: Add cmake optimization flags (ccache launcher, -g1 debug info)
- ci.yml: Shallow clone (fetch-depth: 1) for build-and-test
- docker_ci.yml: Trigger CI image rebuild on dependency file changes
- Dockerfile.ci: Add ccache configuration and git safe.directory
- makefile: Auto-detect and use ccache in all colcon build targets

Co-authored-by: sanatd33 <53443682+sanatd33@users.noreply.github.com>
Co-authored-by: sanatd33 <53443682+sanatd33@users.noreply.github.com>
Copilot AI changed the title [WIP] Optimize build times for faster execution under two minutes Optimize build times: pre-built CI image, ccache, reduced debug info Feb 23, 2026
Copilot AI requested a review from sanatd33 February 23, 2026 02:00
…les against libraries

Fix source file duplication across 7 packages where executables recompiled
all library sources instead of linking against the already-built library:

- rj_strategy: 27 files × 5 executables = 135 extra compilations eliminated
- rj_ui: 18 files × 2 executables = 36 extra compilations eliminated
- rj_planning: 27 files × 1 executable = 27 extra compilations eliminated
- rj_vision_filter: 18 files × 1 executable = 18 extra compilations eliminated
- rj_referee: 3 files × 2 executables = 6 extra compilations eliminated
- rj_control: 2 files × 1 executable = 2 extra compilations eliminated
- rj_radio: 1 file × 1 executable = 1 extra compilation eliminated

Also use nproc for local build parallelism instead of hardcoded 4.

Co-authored-by: sanatd33 <53443682+sanatd33@users.noreply.github.com>
Copilot AI changed the title Optimize build times: pre-built CI image, ccache, reduced debug info Eliminate ~226 redundant source compilations; use ccache and nproc for local builds Feb 23, 2026
@Squid5678 Squid5678 closed this Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants