Repository navigation
Description
I was excited to see the introduction of the GitHub Actions cache backend. However, when I tried it on a test branch, the results were surprisingly slow.
See the initial run at https://github.com/indygreg/apple-platform-rs/actions/runs/3723171428/jobs/6314513850. Here, a build job took ~1 hour. (It normally takes ~10m.) The Stop sccache step displays sccache server stats. This particular job shows 44 cache errors. Unsure if that is possibly the cause of problems?
I did another CI run where I cranked up logging to debug and printed the log file after the build. See e.g. https://github.com/indygreg/apple-platform-rs/actions/runs/3723354206/jobs/6314814370 for a slow build. Interestingly, some of the jobs in this run were fast! See https://github.com/indygreg/apple-platform-rs/actions/runs/3723354206/jobs/6314814955 for a fast one. Spot checking the logs, I think there is a positive correlation between the cache errors count and job time.
Poking around the logs, I see occurrences of DEBUG sccache::compiler::compiler] [aws_http]: Cache write error: Cache service responded with 429 Too Many Requests: {"$id":"1","innerException":null,"message":"Request was blocked due to exceeding usage of resource 'Count' in namespace ''.","typeName":"Microsoft.TeamFoundation.Framework.Server.RequestBlockedException, Microsoft.TeamFoundation.Framework.Server","typeKey":"RequestBlockedException","errorCode":0,"eventId":3000}. So I guess my project is too big to use GitHub Actions cache???
More worrisome though is that some of the cache writes take 10+s. e.g.
2022-12-18T05:13:25.3938134Z [2022-12-18T05:08:46Z DEBUG hyper::client::pool] reuse idle connection for ("https", artifactcache.actions.githubusercontent.com)
2022-12-18T05:13:25.3938390Z [2022-12-18T05:08:46Z DEBUG hyper::proto::h1::io] flushed 2318 bytes
2022-12-18T05:13:25.3938682Z [2022-12-18T05:08:46Z DEBUG hyper::proto::h1::io] parsed 18 headers
2022-12-18T05:13:25.3939035Z [2022-12-18T05:08:46Z DEBUG hyper::proto::h1::conn] incoming body is chunked encoding
2022-12-18T05:13:25.3939330Z [2022-12-18T05:08:46Z DEBUG hyper::proto::h1::decode] incoming chunked header: 0x3 (3 bytes)
2022-12-18T05:13:25.3939686Z [2022-12-18T05:08:46Z WARN reqwest_retry::middleware] Retry attempt #1. Sleeping 53.097849ms before the next attempt
2022-12-18T05:13:25.3940103Z [2022-12-18T05:08:46Z DEBUG hyper::client::pool] reuse idle connection for ("https", artifactcache.actions.githubusercontent.com)
2022-12-18T05:13:25.3940353Z [2022-12-18T05:08:46Z DEBUG hyper::proto::h1::io] flushed 2318 bytes
2022-12-18T05:13:25.3940598Z [2022-12-18T05:08:46Z DEBUG hyper::proto::h1::io] parsed 18 headers
2022-12-18T05:13:25.3940878Z [2022-12-18T05:08:46Z DEBUG hyper::proto::h1::conn] incoming body is chunked encoding
2022-12-18T05:13:25.3941175Z [2022-12-18T05:08:46Z DEBUG hyper::proto::h1::decode] incoming chunked header: 0x3 (3 bytes)
2022-12-18T05:13:25.3941508Z [2022-12-18T05:08:46Z INFO reqwest_tracing::reqwest_otel_span_builder] HTTP request; otel.status_code="ERROR"
2022-12-18T05:13:25.3941845Z [2022-12-18T05:08:46Z INFO reqwest_tracing::reqwest_otel_span_builder] HTTP request; http.status_code=429
2022-12-18T05:13:25.3942174Z [2022-12-18T05:08:46Z INFO reqwest_tracing::reqwest_otel_span_builder] HTTP request; http.user_agent=""
2022-12-18T05:13:25.3942478Z [2022-12-18T05:08:46Z DEBUG hyper::proto::h1::decode] incoming chunked header: 0x138 (312 bytes)
2022-12-18T05:13:25.3942793Z [2022-12-18T05:08:46Z DEBUG hyper::proto::h1::conn] incoming body completed
2022-12-18T05:13:25.3943218Z [2022-12-18T05:08:46Z DEBUG hyper::client::pool] pooling idle connection for ("https", artifactcache.actions.githubusercontent.com)
2022-12-18T05:13:25.3944403Z [2022-12-18T05:08:46Z DEBUG sccache::compiler::compiler] [aws_sdk_s3]: Cache write error: Cache service responded with 429 Too Many Requests: {"$id":"1","innerException":null,"message":"Request was blocked due to exceeding usage of resource 'Count' in namespace ''.","typeName":"Microsoft.TeamFoundation.Framework.Server.RequestBlockedException, Microsoft.TeamFoundation.Framework.Server","typeKey":"RequestBlockedException","errorCode":0,"eventId":3000}
2022-12-18T05:13:25.3944708Z [2022-12-18T05:08:46Z DEBUG sccache::server] [aws_sdk_s3]: Cache write finished in 21.388 s
2022-12-18T05:13:25.3945012Z [2022-12-18T05:08:46Z DEBUG hyper::proto::h1::decode] incoming chunked header: 0x138 (312 bytes)
2022-12-18T05:13:25.3945338Z [2022-12-18T05:08:46Z DEBUG hyper::proto::h1::decode] incoming chunked header: 0x138 (312 bytes)
And
2022-12-18T05:13:25.3908847Z [2022-12-18T05:08:38Z DEBUG hyper::client::pool] pooling idle connection for ("https", artifactcache.actions.githubusercontent.com)
2022-12-18T05:13:25.3909181Z [2022-12-18T05:08:38Z INFO reqwest_tracing::reqwest_otel_span_builder] HTTP request; http.status_code=204
2022-12-18T05:13:25.3909491Z [2022-12-18T05:08:38Z INFO reqwest_tracing::reqwest_otel_span_builder] HTTP request; http.user_agent=""
2022-12-18T05:13:25.3909910Z [2022-12-18T05:08:38Z DEBUG sccache::compiler::compiler] [aws_config]: Stored in cache successfully!
2022-12-18T05:13:25.3910204Z [2022-12-18T05:08:38Z DEBUG sccache::server] [aws_config]: Cache write finished in 13.018 s
2022-12-18T05:13:25.3910535Z [2022-12-18T05:08:45Z DEBUG sccache::compiler::compiler] [aws_sdk_s3]: Compiled in 21.388 s, storing in cache
2022-12-18T05:13:25.3910931Z [2022-12-18T05:08:46Z INFO gha_toolkit::cache] put; version="5c35548282b30b97a2314eadc6fc42b9b7585a12c4f9efa527ac2e48739babe0"
2022-12-18T05:13:25.3911660Z [2022-12-18T05:08:46Z INFO gha_toolkit::cache] reserve; key="sccache-ubuntu-22.04-x86_64-unknown-linux-gnu-1.62.1-0300a5abb7bd36eb7e4aa0b971d5e94866c6e140" version="7c4ed3dc414c5c2d030ec00d8394e733c5dfeff8cdbae21becc2144de0bb9570" cache_size=21844888
2022-12-18T05:13:25.3912483Z [2022-12-18T05:08:46Z INFO reqwest_tracing::reqwest_otel_span_builder] HTTP request; http.method=POST http.scheme=https http.host=artifactcache.actions.githubusercontent.com net.host.port=0 otel.kind="client" otel.name=POST /LNWNXsg1z0Qt0Mn41fuRdbA1YzcaL5Z2Wf2AYmEQiLGLuQCklb/_apis/artifactcache/caches
I'm not sure how to interpret these logs. But multi-second values for Cache write finished in seem wrong: I would expect a cache write to effectively be an HTTP request and for inserts to take dozens to hundreds of milliseconds. But maybe the GitHub Actions cache latency is just really high?
I'm unsure what actions are needed for this issue. I'm unsure if there's any code-level bugs. Maybe GitHub Actions cache is just prohibitively slow? Maybe this slowness/behavior should be documented?
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
sylvestre commentedon Dec 19, 2022
Salut @indygreg nice to see you here :)
@jakelee8 does it ring a bell?
sylvestre commentedon Dec 19, 2022
I might be wrong but I think it also includes the compilation time.
Side note: maybe we should have compilation time + cache time displayed in the logs
jakelee8 commentedon Dec 20, 2022
The
429 Too Many Requestserror is a legitimate issue. Do y'all think it would help to implement a cache write queue to limit parallelism?From what I've seen, it looks like compile time is included in the write time. Cache reads are fast at
0.000 s. Here's an example of one of our internal builds:jakelee8 commentedon Dec 20, 2022
Also, did you set the environmental variable
CARGO_INCREMENTAL=false?From the README:
https://github.com/mozilla/sccache#rust
glandium commentedon Dec 20, 2022
FWIW, these logs are wrong. PR #1495 will hopefully fix that.
indygreg commentedon Dec 21, 2022
I do not set
CARGO_INCREMENTAL=falsein these CI jobs. Maybe that explains some regressions in caching in recent months?!(Also, I'm not receiving emails for updates in this repository for some reason. I suspect they may be getting routed to my defunct mozilla.com email. But I don't see any references to that email in my GitHub account. So unsure what's going on. Apologies if I'm tardy to reply - I probably didn't see the activity!)
rajivshah3 commentedon Dec 30, 2022
I'm seeing similar issues with HTTP error 429, and can confirm that we're setting
CARGO_INCREMENTAL=0:I'm surprised that it still reports that the cache write is finished though 🤔
sylvestre commentedon Jan 2, 2023
@rajivshah3 in the future, please strip the color string, it makes the log harder to read ;)
For cache write, we don't need to be super fast. Maybe a queue would do.
@Xuanwo do you think you could do that once you added the opendal support for GHA? (or as part of the change?)
Xuanwo commentedon Jan 2, 2023
Sure! I will add rate limit handling after implement apache/opendal#1111
Xuanwo commentedon Jan 3, 2023
apache/opendal#1111 has passed all opendal's tests now! It will come into sccache soon.
sylvestre commentedon Jan 3, 2023
@Xuanwo you are auto approving your patches in opendal ?
Xuanwo commentedon Jan 3, 2023
Yep, most PRs are merged by me after all check passed.
sylvestre commentedon Jan 3, 2023
ok :(
this is a bit surprising ...
Xuanwo commentedon Jan 3, 2023
I expect to improve this part while we have more maintainers~
sylvestre commentedon Jan 3, 2023
yes, please do, this should not be done on important project
Xuanwo commentedon Jan 9, 2023
Hi, @indygreg, I re-produced you problem with the v0.4.0-pre.5 release at https://github.com/Xuanwo/apple-platform-rs/actions/runs/3871176193/jobs/6598713731
The real problem here is ghac will return a very long
Retry-Afterwhich could up to 60s. So if we follow this limit strictly, we will observe the surprisingly slow.The full error message here:
Returns a cache miss or give up this cache write maybe a better choice.
Xuanwo commentedon Jan 12, 2023
Hi, @indygreg. Here are our updates on addressing this issue.
I have a test with my two patches: #1557 & #1550 on apple-platform-rs.
The biggest lesson I have learned from this is that sccache is a cache service, and we don't need to ensure every write/read succeeds. So instead of waiting to retry limited requests, we will skip this step and keep going.
Here are the differences:
Before
After
No failed build anymore
The action is here Xuanwo/apple-platform-rs#1
indygreg commentedon Jan 14, 2023
(I'm still not receiving email notifications from Mozilla orgs due to a GitHub bug involving an orphaned email forwarding rule leftover from when I worked at Mozilla.)
The updates here look great and I hope to test out the GHA backend again soon. The new times from the previous comment appear no worse than what I'm getting with 0.3.3 on S3 today. Considering GHA enables me to enable sccache on PRs without leaking my cloud provider credentials, this looks like a very compelling feature now! Thanks for all your work!
Xuanwo commentedon Jan 16, 2023
@indygreg Please take v0.4.0-pre.6 a try~
rajivshah3 commentedon Jan 27, 2023
Hi @Xuanwo , is there anything that can be done to improve this? On v0.4.0-pre.6 we're still seeing a lot of 429 errors in the logs (on both reads and writes) and there isn't much of a difference in compilation time (33 min uncached vs 29 min cached). The logs from
sccacheare uploaded as build artifacts if that would help. I wonder if it would be worth having an opt-in feature to try the failed writes again in the background once the compilation is done?Xuanwo commentedon Jan 27, 2023
This is the github's limit and I don't how to overcome them so far.
Sadly, sccache can't cache the heaviest dep
rocksdbin your project. Based on my own experience, a full release build of rocksdb will always take from 20 min to 30 min. Maybe you can try run tests in debug build instead of release build.The time could be very long(
onbjerg commentedon Feb 14, 2023
Hi! Did the caching behavior change a lot from 0.3.3 to 0.4.0-pre.7? Locally, running
Yields these stats:
But on CI (see paradigmxyz/reth#1355) these numbers are vastly different:
The cache seems to be populated, writes and reads are reported as pretty fast, but the build is a lot slower than using rust-cache - some of our jobs went from 5 mins build time to 12-13 mins (see main CI).
I based the workflow changes off of Xuanwo/apple-platform-rs#1
Xuanwo commentedon Feb 15, 2023
I have tried this command over
sccache v0.3.3but get:The compile requests is the same. Are you running the same command? By the way, maybe it's better to build tests with sccache, upload to artifacts, and than running in different hash part.
onbjerg commentedon Feb 16, 2023
@Xuanwo Unfortunately using artifacts is a lot slower since the artifact upload speed is abysmal :( The artifact upload takes as long (or longer) as the build does.
I am running the same command locally, I'll try a fresh clone, maybe something is messed with my local copy of the repository I am building
Do you know/have any pointers on what could make sccache slower than rust-cache for the linked PR?
Xuanwo commentedon Feb 16, 2023
No ideas so far. Maybe we are hitting the github action cache's rate limit.
onbjerg commentedon Feb 17, 2023
I thought so too, but
sccace --show-statsdoes not show any read or write errors. Maybe they are not reported for GHAC?ci: sccache local-disk backend + single packed actions/cache (drop GH…
ci: Drop the unusable cache, keep the free wins