Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixed has target check taking ages for large projects #138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jmachowinski
Copy link

The old implementation took up to 30 seconds for packages, were a lot of targets existed. This is a common case for interface packages containing a lot of messages.

Copy link

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After reading https://stackoverflow.com/questions/23849953/how-to-check-existence-of-the-target-in-a-makefile, I'm wondering if we shouldn't also use --dry-run and maybe use the strategy suggested there where we check the output of the data base with --print-data-base? I'm not certain it provides more benefits, but maybe it would help to avoid unintended (and in some cases expensive time-wise) side effects.

With that suggestion aside, there's just a few small technical questions and requests before this is lgtm.

colcon_cmake/task/cmake/__init__.py Show resolved Hide resolved
colcon_cmake/task/cmake/__init__.py Show resolved Hide resolved
@wjwwood
Copy link

wjwwood commented Mar 30, 2024

I tested this on macos and I didn't notice or see any issues building the ros2.repos up to rclcpp and a little past that.

@jmachowinski jmachowinski marked this pull request as draft April 13, 2024 10:43
@jmachowinski
Copy link
Author

I had some issues with this patch, it does not seem to work in special situations.
I currently don't have time to look into it, therefore I will convert this PR into a draft.

@cottsay
Copy link
Member

cottsay commented Apr 16, 2024

What sort of behavior does this exhibit if the CMake generator is Visual Studio? Also, what if the system's language is not set to English - is make's output localized?

@jmachowinski
Copy link
Author

What sort of behavior does this exhibit if the CMake generator is Visual Studio?

Unchanged

Also, what if the system's language is not set to English - is make's output localized?

AFAIK make is not localized, at least it is not on my german localized ubuntu

@jmachowinski jmachowinski force-pushed the has_target_improvement branch 2 times, most recently from 65b9d43 to fb4368a Compare June 12, 2024 17:45
@jmachowinski
Copy link
Author

After reading https://stackoverflow.com/questions/23849953/how-to-check-existence-of-the-target-in-a-makefile, I'm wondering if we shouldn't also use --dry-run and maybe use the strategy suggested there where we check the output of the data base with --print-data-base? I'm not certain it provides more benefits, but maybe it would help to avoid unintended (and in some cases expensive time-wise) side effects.

--dry-run generated a lot of not needed output, which is not done by the question mode. As I don't check on the return code, but parse the std_err instead, we should be fine

@jmachowinski jmachowinski marked this pull request as ready for review June 12, 2024 17:48
@jmachowinski
Copy link
Author

This version is working, and tested. Additional tests would be appreciated though, as I only have a linux machine.

@cottsay
Copy link
Member

cottsay commented Jun 13, 2024

Beyond the linting errors that CI identified, I am also concerned that this change is coupled to GNU Make. The -q flag has a different (and incompatible) meaning on BSD: https://man.freebsd.org/cgi/man.cgi?make(1)

That said, BSD isn't an explicitly supported platform, but it still doesn't feel good to break it just for an optimization. I'll do a little more poking around to see if I can see another solution.

@jmachowinski
Copy link
Author

@cottsay ping

@cottsay
Copy link
Member

cottsay commented Nov 6, 2024

It looks like the -n flag is available on all of the platforms I tested. It prints the command that WOULD be executed for a target, but importantly returns non-zero if the target doesn't exist.

It appears to be a lot faster than help in my tests. Would that work for you?

@jmachowinski
Copy link
Author

I just testet -n vs -q , on our system -n seems to be slower but its still a major improvement over the current state :
With -q

Starting >>> cm_interfaces
Finished <<< cm_interfaces [2.87s]                     

Summary: 1 package finished [3.59s]

Starting >>> cm_interfaces
Finished <<< cm_interfaces [2.93s]                     

Summary: 1 package finished [3.67s]

with -q

Starting >>> cm_interfaces
Finished <<< cm_interfaces [4.61s]                     

Summary: 1 package finished [5.34s]

Starting >>> cm_interfaces
Finished <<< cm_interfaces [5.41s]                     

Summary: 1 package finished [6.14s]

Starting >>> cm_interfaces
Finished <<< cm_interfaces [4.56s]                     

Summary: 1 package finished [5.29s]

I still wonder, about the impact of the text output in colcon though...

time make -q install

real    0m0,343s
user    0m0,330s
sys     0m0,011s
time make -n install
real    0m0,960s
user    0m0,812s
sys     0m0,142s

The time spend in make increases only about 600ms, vs 1.6 seconds in colcon.

The old implementation took up to 30 seconds for packages,
were a lot of targets existed. This is a common case for
interface packages containing a lot of messages.

Signed-off-by: Janosch Machowinski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants