-
Notifications
You must be signed in to change notification settings - Fork 129
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
simplify ccache integration #182
Conversation
I have run some tests with #169 Without cache: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice feature!
I pushed a commit for more documentation. Please review if everything I've written is correct.
LGTM. Only have minor questions as follows and an inline comment.
Beginner question; the feature in this PR is different from what Travis CI offers and is not dependent on it, correct? Just making sure because I think we don't want to Travis-specific.
Just looking at how long/short CI took,
- A build with larger number of jobs seems fantastic simplify ccache integration #182 (comment)
- For smaller number of jobs, e.g. ros_canopen, any idea why the total amount of time actually increased?:
- without this PR, https://travis-ci.org/ipa-mdl/ros_canopen/builds/236271434 took 33 mins.
- with this PR, https://travis-ci.org/ipa-mdl/ros_canopen/builds/244209632 took 37 mins.
Do we want to use this feature for an existing job or add a new job?
if [ "$CCACHE_DIR" ]; then | ||
ici_time_start setup_ccache | ||
sudo apt-get install -qq -y ccache || error "Could not install ccache. Exiting." | ||
export PATH="/usr/lib/ccache:$PATH" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this line looks cumbersome, but we may just need it https://askubuntu.com/questions/470545/how-do-i-set-up-ccache (I found @VictorLamoine there :))?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using symlink is the recommended way to enable ccache.
On debian/ubuntu these symlinks get set-up automatically in /usr/lib/ccache
by update-ccache-symlinks
It depends on the CI system to provide caching between the jobs.
The handling of the cache takes time.
Travis supports only global caching (?), so the handling is done for all jobs, even if the cache is not used in the job. |
Any comment on the document I updated?
I see. This means that my document update was based on my misunderstanding, so definitely needs review.
Dumb question but do you mean caching may not work for the purpose for builds with a) smaller number of jobs b) jobs that take shorter c) else?
So...do we want to test this feature in our own build (i.e. do we want to enable this feature |
Not yet, I will have a look as soon as I have some time.
The cache feature (of travis) downloads and unzips an archive before every build. In https://travis-ci.org/ipa-mdl/ros_canopen/builds/244209632 only job 4 uses
I did not plan to add it in this PR, but perhaps in #169 |
@@ -249,6 +250,24 @@ Reference: | |||
* `Discussion about install space <https://github.com/ros-industrial/industrial_ci/issues/54>`_ | |||
* `Detail for catkin config <http://catkin-tools.readthedocs.io/en/latest/verbs/catkin_config.html>`_ for more info about `catkin-tools`. | |||
|
|||
Cache build artifacts to speed up the subsequent builds (if any) | |||
---------------------------------------------------------------- | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instructions for setting up the CI cache are missing
doc/index.rst
Outdated
|
||
env: | ||
global: | ||
- CCACHE_DIR="$HOME/.ccache" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the quotes must be removed in order to allow variable substitution.
This is basically true, but all jobs get individual caches, so the cache should be empty if it wasn't used. So the overhead is more or less neglectable.
I have run some tests, and for the current tests we dont gain any speed-up with |
|
Thank you for clarification. Doc updated. |
@ipa-mdl please review the updated doc. |
Docs look good now 👍 |
I have modified two existing tests to check that |
- ROS_DISTRO=indigo UPSTREAM_WORKSPACE=file # Using default file name for ROSINSTALL_FILENAME | ||
- ROS_DISTRO=indigo UPSTREAM_WORKSPACE=debian AFTER_SCRIPT='ccache 2> /dev/null && exit 1; [ "$?" = "127" ]' | ||
# Using default file name for ROSINSTALL_FILENAME, test CCACHE, verify cache was filled | ||
- ROS_DISTRO=indigo UPSTREAM_WORKSPACE=file CCACHE_DIR=$HOME/.ccache AFTER_SCRIPT='num=($(ccache -s | grep "files in cache")) && (( num[-1] > 0 ))' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to understand what the commands in AFTER_SCRIPT
are doing.
Locally I get this, which seems not good..:
$ num=($(ccache -s | grep "files in cache")) && (( num[-1] > 0 ))
$ echo $num
files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Locally I get this, which seems not good..:
actually, that's correct behaviour ;)
$(ccache -s | grep "files in cache")
-> select line from ccache stats
num=($(ccache -s | grep "files in cache"))
-> define an array with the data (separated by whitespace), e.g. ["files", "in", "cache", 42] (python-syntax)
num[-1]
-> selects the last entry of this array
(( num[-1] > 0 ))
evaluates an arithmetic expression, the exit code is used as the actual test result
echo $num
just prints the first item of the array. To print all you have to use echo "${num[@]}"
.
echo $?
will print the exit code:
$ num=($(ccache -s | grep "files in cache")) && (( num[-1] > 0 ))
$ echo $?
0 # okay
$ num=($(CCACHE_DIR=/tmp ccache -s | grep "files in cache")) && (( num[-1] > 0 ))
$ echo $?
1 # error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My very bad...man (ba)sh
is/will never be my friend...
Sounds good.
I think having job(s) that uses |
If the cache got filled, ccache should have been run :) |
This PR simplifies the use of
ccache
as reported in #181It is not enabled by default because it needs set-up in the CI config.
Example config for travis:
A test-case can be added on top of #169