Repository navigation
Description
Describe the bug
Outputting very long log lines seems to cause the runner to slow down significantly.
A step that takes less than a second to actually execute can easily take 10s of minutes or even hours to be considered complete, often hitting timeouts.
https://github.com/hamishforbes/actions-test
This repo has a super simple python script that outputs the current timestamp and "a" repeated for various lengths.
Turn on timestamps and you can see a discrepancy.
Once a log message gets up to about 6k characters it looks like the runner starts to take a few seconds to process.
At 100k characters this can be 10 minutes or so
Running the script locally on a macbook pro, even with 100k characters, completes within a couple hundred ms.
Runner timestamp | Python timestamp
Tue, 30 Mar 2021 01:34:19 GMT | 2021-03-30 01:34:16.831361 - Message length: 10240 - aaaaa{snip}
Tue, 30 Mar 2021 01:34:30 GMT | 2021-03-30 01:34:16.831413 - Message length: 20480 - aaaaa{snip}
To Reproduce
Copy script and workflow from above repo :)
Expected behavior
I would expect the runner to be able to handle long log lines even if truncating them.
At the very least it shouldn't delay how long the step takes to run, the real world workflow that caused this was completing its test suite in < 10 mins but the step would never finish in actions because it would hit timeouts
Runner Version and Platform
Github hosted but tested with the latest self-hosted runner as well
Seems to affect both steps executed in docker and those directly on ubuntu-latest, although slightly less severe.
https://github.com/hamishforbes/actions-test/tree/no_docker
Activity
TingluoHuang commentedon Mar 30, 2021
The runner needs to scan the entire output in order to mask any potential secret string which will slow down the process for sure.
Also, what will happen if you run the python script in the terminal, will the terminal also take some time to printout all the outputs?
I think in the real world, the outputs for most of the tooling are not that verbose.
hamishforbes commentedon Mar 30, 2021
I figured it would be something like that, would it be reasonable to set a max log length at some performant level (e.g. 10 or 20K chars) and truncate to that length before scanning?
No, its essentially instant
I'm here because it happened in the real world! :D
We have some tests around maximum message lengths in our application, this involves sending very large messages.
You could argue that it's our fault for logging the full message and we should truncate in the application, and disabling that log message is the workaround i've put in place.
But I only discovered what was causing the problem was by downloading the full log archive where i eventually noticed the timestamp discrepancy, after several days of tinkering, tuning, deploying our own runners with more resources etc
This test suite is currently being run on CircleCI with no issues and it would've been very easy to just give up and say github actions is broken for us.
A warning that log lines have been truncated or even that long lines were detected and could cause slowdowns would've made troubleshooting much easier and make the whole experience of switching to actions far smoother
TingluoHuang commentedon Mar 30, 2021
If you echo something to stdout, I would assume you want to see it (not truncated) in the log. 😄
TingluoHuang commentedon Mar 30, 2021
Leaking any secrets to log is a security incident for customers, we need to make sure we scan it.
TingluoHuang commentedon Mar 30, 2021
In addition to the raw secret string, we also scan different encoding versions of it, ex URL encoding, base64 encoding, XML encoding, which will slow things down.
hamishforbes commentedon Mar 30, 2021
Sure, but I also want to see it this week and not mysteriously have my steps run for hours after their actual command has exited
If they're truncated they can't leak :D
Perhaps disabling these on lines over a threshold would give back enough performance for usability then?
hross commentedon Mar 30, 2021
It would be nice to do a performance test to see if we can do anything or provide guidance but outside of that we would start with recommending reducing the number of characters you output.
We will have to stack this priority against other features/bugs (right now it seems lower priority than other work we can do).
shinebayar-g commentedon Oct 23, 2023
Log output performance is not ideal. For 500KB output we're waiting for 20 minutes. And somehow output size is reported as 2x, so around 600KB we're getting error of 1MB log output limit is reached.
Update: It looks like performance considerably slows down if the output or log contains a very long line. For example
echo "huge string" | base64 -w 0vsecho "huge string" | base64has very different performance.zied-elouaer commentedon Nov 14, 2023
We just hit this issue in the real world, running
terraform showon thegoogle_api_gateway_api_configresource. This resource requires base64 encoding the OpenAPI spec file. In our case, this file has 8K+ lines. The encoded string is of course one line with 327K+ characters.Running this
terraform showcommand takes less than 1 second locally, and 23 minutes on GitHub Actions!megamanics commentedon Jan 22, 2024
Just tested with 538 KB, please check the workflow and suggest how to reproduce this issue?
https://github.com/devops-testbed/actions-test/actions/runs/7616544885
hamishforbes commentedon Jan 22, 2024
I just re-ran the workflow from the reproduction steps in the OP, still exhibits exactly the same behaviour
https://github.com/hamishforbes/actions-test/actions/runs/7616942423/job/20744847194
enable timestamps in the log view and see the discrepancy between the timestamp in the actions UI and the timestamp printed in the actual log when the line is very long
megamanics commentedon Jan 22, 2024
@hamishforbes
Assuming your earlier tests were showing a higher difference than the latest run?
hamishforbes commentedon Jan 22, 2024
It was 3 years ago so I don't remember exactly, but it does appear there have been some performance improvements
Fundamentally still an issue, just the goalposts have been moved
danmanners commentedon Jan 22, 2024
Similarly, we had a workflow with a ~1,053,000 character log line. That one command takes approximately 17 minutes on average to complete using self-hosted runners, and 26 minutes using GitHub Hosted Runners.
I'll second @hamishforbes with what he's seeing. The logs spell it out well.
While the code executed in 0.001188 seconds (or 1.188ms), the actual runtime of the action was a full minute, seemingly due to the scanning of exceptionally long strings for secrets, and looking at when the logs actually came in shows a completely different story. Between each of the screenshots below, you can see the time deltas easily enough.
START
END
@megamanics LMK if that makes sense
megamanics commentedon Jan 23, 2024
Thanks @danmanners & @hamishforbes for helping me reproduce this 👍. I am going to dig through this and figure out if there are any additional optimizations that can be done.
Meanwhile I am proposing using an updated workflow (you may already be using it) that can get the logs as well as performs better than the current workflow. This is for anyone who is blocked by this issue.
Same workflow takes < 10 secsI have added an additional step for base64 encoding.
https://github.com/devops-testbed/actions-test/actions/runs/7616544885/job/20743553026
fix(ci): truncate debug log that stalls GitHub Actions runner
fix(ci): truncate debug log that stalls GitHub Actions runner (#661)
freben commentedon Oct 20, 2026
For anyone following along: I made #4798 with more detail