Skip to content

Reproducible and faster generation - #403

Open
gergondet-woven wants to merge 2 commits into
RobotLocomotion:mainfrom
gergondet-woven:feat/reproducible-faster-generation
Open

Reproducible and faster generation#403
gergondet-woven wants to merge 2 commits into
RobotLocomotion:mainfrom
gergondet-woven:feat/reproducible-faster-generation

Conversation

@gergondet-woven

@gergondet-woven gergondet-woven commented Nov 25, 2025

Copy link
Copy Markdown
Contributor

Hi there, thanks for merging our changes earlier this year and for the significant overhaul in #396. We have rebased our own patches on top of that and found some that we hope can be useful to everyone 🙏

This PR proposes changes to bazel_ros2_rules that make the initial BUILD.bazel generation:

  1. More deterministic
  2. Faster

The first patch replaces set usage (which is non deterministic) with an ordered_set and sorting (when the order shouldn't matter).

Before this patch, we would get confusingly bad cache hits as the inputs and outputs of the actions would be the same but the linker script would have the libraries in different order (leading to unnecessary extra builds and tests actions being run).

The second one fixes an issue with the scrapping code that can make it revisit the same packages many times and add some caching to the system lookups which also happen many times during scrapping. Overall this made the repository generation twice as fast in our CI environment.


This change is Reviewable

This patch tries to improve reproducibility.

The original code uses set in a couple of places but the output of set
is not guaranteed to stay the same even if the inputs are the same.

We work around this in two ways:
- where possible, replace set with an ordered_set version
- in some places, sort the deps/data list given to Bazel
- in build_dependency_graph don't visit the same packages multiple times
- make some changes to avoid a lot of duplication in the output
  dependencies
- add an unbounded lru_cache for most library information extraction
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.

1 participant