Skip to content

Long log lines slow down the runner #1031

Open

Description

@hamishforbes

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

  1. added
    bug
    on Mar 30, 2021
  2. TingluoHuang commented on Mar 30, 2021

    @TingluoHuang
    Member

    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.

  3. hamishforbes commented on Mar 30, 2021

    @hamishforbes
    Author

    The runner needs to scan the entire output in order to mask any potential secret string which will slow down the process for sure.

    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?

    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?

    No, its essentially instant

    I think in the real world, the outputs for most of the tooling are not that verbose.

    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

  4. TingluoHuang commented on Mar 30, 2021

    @TingluoHuang
    Member

    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?

    If you echo something to stdout, I would assume you want to see it (not truncated) in the log. 😄

  5. TingluoHuang commented on Mar 30, 2021

    @TingluoHuang
    Member

    Leaking any secrets to log is a security incident for customers, we need to make sure we scan it.

  6. TingluoHuang commented on Mar 30, 2021

    @TingluoHuang
    Member

    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.

  7. hamishforbes commented on Mar 30, 2021

    @hamishforbes
    Author

    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?

    If you echo something to stdout, I would assume you want to see it (not truncated) in the log. 😄

    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

    Leaking any secrets to log is a security incident for customers, we need to make sure we scan it.

    If they're truncated they can't leak :D

    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.

    Perhaps disabling these on lines over a threshold would give back enough performance for usability then?

  8. hross commented on Mar 30, 2021

    @hross
    Contributor

    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).

  9. added
    Runner Bug
    on Mar 31, 2022
  10. shinebayar-g commented on Oct 23, 2023

    @shinebayar-g

    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 0 vs echo "huge string" | base64 has very different performance.

  11. zied-elouaer commented on Nov 14, 2023

    @zied-elouaer

    We just hit this issue in the real world, running terraform show on the google_api_gateway_api_config resource. 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 show command takes less than 1 second locally, and 23 minutes on GitHub Actions!

  12. megamanics commented on Jan 22, 2024

    @megamanics

    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

  13. hamishforbes commented on Jan 22, 2024

    @hamishforbes
    Author

    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

    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

  14. megamanics commented on Jan 22, 2024

    @megamanics

    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

    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

    @hamishforbes
    Assuming your earlier tests were showing a higher difference than the latest run?

    Runner timestamp Python timestamp Difference
    Mon, 22 Jan 2024 20:26:19 GMT 2024-01-22 20:26:04.013847 - Message length: 102400 - 15
    Mon, 22 Jan 2024 20:26:48 GMT 2024-01-22 20:26:04.014303 - Message length: 102400 - 44
  15. hamishforbes commented on Jan 22, 2024

    @hamishforbes
    Author

    @hamishforbes Assuming your earlier tests were showing a higher difference than the latest run?

    Runner timestamp Python timestamp Difference
    Mon, 22 Jan 2024 20:26:19 GMT 2024-01-22 20:26:04.013847 - Message length: 102400 - 15
    Mon, 22 Jan 2024 20:26:48 GMT 2024-01-22 20:26:04.014303 - Message length: 102400 - 44

    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

  16. danmanners commented on Jan 22, 2024

    @danmanners

    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.

    # First Log - https://github.com/hamishforbes/actions-test/actions/runs/7616942423/job/20744847194#step:5:5
    2024-01-22 20:26:04.013781 - Message length: 10 - aaaaaaaaaa
    # Last Log - https://github.com/hamishforbes/actions-test/actions/runs/7616942423/job/20744847194#step:5:14
    2024-01-22 20:26:04.014969 - Message length: 10 - aaaaaaaaaa
    

    image

    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

    0 seconds, 10 and 100 characters - 20:26:04 GMT

    image

    0 seconds, 6144 characters - 20:26:04 GMT

    image

    0 seconds, 8192 characters - 20:26:04 GMT

    image

    15 seconds, 102400 characters - 20:26:19 GMT

    image

    29 seconds, 102400 characters - 20:26:48 GMT

    image

    15 seconds, 8192 characters - 20:27:03 GMT

    image

    0 seconds, 6144 characters - 20:27:03 GMT

    image

    0 seconds, 100 characters - 20:27:03 GMT

    END

    @megamanics LMK if that makes sense

  17. megamanics commented on Jan 23, 2024

    @megamanics

    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

  18. freben commented on Oct 20, 2026

    @freben

    For anyone following along: I made #4798 with more detail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Runner Bugbugpapercut

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions