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

Update drone caching strategy #715

Merged
merged 1 commit into from Mar 21, 2023
Merged

Conversation

sdarwin
Copy link
Collaborator

@sdarwin sdarwin commented Mar 16, 2023

A proposed change to the caching methodology.

The cache key has been the boostorg/boost commit SHA, which changes around every 4 hours and thus invalidates the cache most of the times you attempt to use it. If a few hours have passed and there is a pull request or a commit, those will be cache misses.

The new strategy is to basically always use the cache.

common_install.sh runs every time. "git pull" or "submodule update" only take a few seconds because they don't need to download a full git repository. b2 recompilation will be skipped.

@codecov
Copy link

codecov bot commented Mar 16, 2023

Codecov Report

Merging #715 (b42ccac) into develop (565de15) will increase coverage by 0.10%.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #715      +/-   ##
===========================================
+ Coverage    97.11%   97.21%   +0.10%     
===========================================
  Files          155      155              
  Lines         8461     8486      +25     
===========================================
+ Hits          8217     8250      +33     
+ Misses         244      236       -8     

see 7 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 565de15...b42ccac. Read the comment docs.

@cppalliance-bot
Copy link

@alandefreitas
Copy link
Member

Running "git pull" or "submodule update" every time is a good idea. Then we can recache the newer versions.

@@ -410,7 +410,7 @@ def generate(compiler_ranges, cxx_range, max_cxx=2, coverage=True, docs=True, as

if cache_dir != None and image_supports_caching(image, compiler):
environment['drone_cache_mount'] = cache_dir
if image in images_used:
if image in images_used or buildtype != "boost":
Copy link
Member

Choose a reason for hiding this comment

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

Who's expected to build the original cache on which we "git pull" or "submodule update" for the first time?

Don't we still need drone_cache_rebuild in one job to upload the new libs with "git pull" or "submodule update" work?

We "git pull" or "submodule update" do not do anything, can we set drone_cache_rebuild from true to false to skip the upload step?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@alandefreitas
notice in this modification,

if image in images_used or buildtype != "boost":

"!=" instead of a "=". The effect is excluding "docs" from being the rebuilder instance. "boost" will rebuild.

Who's expected to build the original cache on which we "git pull" or "submodule update" for the first time?

common_install.sh runs every time, regardless, and creates the original boost-root folder.

Don't we still need drone_cache_rebuild

drone_cache_rebuild is still present. Hasn't been removed from the procedure.

When "git pull" or "submodule update" do not do anything, can we set drone_cache_rebuild from true to false to skip the upload step?

this is the same issue that has been present for a while. It only affects the rebuilder instances, and only takes 5 seconds. Not so bad. I will open an issue with meltwater but probably we can live with that delay.

Copy link
Member

Choose a reason for hiding this comment

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

"!=" instead of a "=". The effect is excluding "docs" from being the rebuilder instance. "boost" will rebuild.

Oh... sorry. So this is just fixing something else in passing. Great.

only takes 5 seconds

👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

issue with meltwater

actually, I will delay asking them, because it's likely beyond their ability to fix right now, I have already opened an issue to be able to cache absolute paths instead of relative paths which would allow boost-root to be immediately cached instead of copying it back and forth.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good

.drone/drone.sh Outdated
BOOST_ROOT="$(pwd)"
export BOOST_ROOT
ls "$cache_dir/boost"
export BOOST_ROOT="$(pwd)"
Copy link
Member

Choose a reason for hiding this comment

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

This is effectively just removing the ls "$cache_dir/boost" line above.

I've been splitting commands such as export BOOST_ROOT="$(pwd)" into

BOOST_ROOT="$(pwd)"
    export BOOST_ROOT

because shellcheck gives me the error SC2155. Not a huge problem but still annoying because it hides more serious problems.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

shellcheck. Ok switched it back. The commits should be squashed.


if [ "$drone_cache_rebuild" == true ]; then
if command -v apt-get &>/dev/null; then
apt-get install -y rsync
Copy link
Member

Choose a reason for hiding this comment

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

Should the images include rsync? I couldn't replicate the command with cp but this conditional looks like a workaround.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The images should include rsync but they don't at the moment. This workaround isn't too bad.

$python_executable tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools "$SELF"
cd $DRONE_WORKSPACE
fi
. ./ci/common_install.sh
Copy link
Member

Choose a reason for hiding this comment

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

That's quite nice. It does the whole thing properly in both paths.

@alandefreitas
Copy link
Member

This strategy is quite smart :)

The cache baseline only needs to change when there's a new tag, depinst.py ensures everything is up to date, and anything updated is reached. Perfect.

@sdarwin
Copy link
Collaborator Author

sdarwin commented Mar 16, 2023

only needs to change when there's a new tag

By the way, that's not strictly required. It seems to be a nice idea to refresh on a git tag, every three or four months. But conceivably you could remove the check and never recreate the cache so it would be a perpetual eternal cache because "git pull" is being run every time.

@cppalliance-bot
Copy link

@alandefreitas
Copy link
Member

@cppalliance-bot
Copy link

@sdarwin
Copy link
Collaborator Author

sdarwin commented Mar 20, 2023

caching is currently implemented as a container 'meltwater/drone-cache' which means the function image_supports_caching should check image_str != None

@cppalliance-bot
Copy link

@alandefreitas
Copy link
Member

image_supports_caching should check image_str != None

Definitely. This is a plain error.

Is this PR good to go in your opinion?

@sdarwin
Copy link
Collaborator Author

sdarwin commented Mar 20, 2023

Each time we find something new, but yes it should be good-to-go.

@alandefreitas alandefreitas merged commit eb052de into boostorg:develop Mar 21, 2023
15 checks passed
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.

None yet

3 participants