Skip to content

Ctrl-C leaving sccache compilations running #2759

Closed

Description

@nyh

We (https://github.com/scylladb/scylladb/) are using a ninja-based build system for C++ and Rust code, and using sccache for caching the compilations. Most developers do not use a remote compilation or caching setup - the cache is local and compilations are run on the same machine.

Our developers working interactively are facing an annoying problem: When we interrupt "ninja" with control-C, ninja is killed immediately, but all the ongoing compilations continue to run to completion, in the background. These compilations sometimes linger for several minutes (!), continuing to hog the machine's CPU and memory long after the user interrupted them.

The reason for this problem is sscache's server architecture: An sscache invoked by ninja may connect to some sscache server started earlier and run the build there. A control-C will never reach that other process group, and won't kill the build. Even no server exists, a new one will be started but by default will be run in a separate process group (SCCACHE_NO_DAEMON=1 can be used to avoid that).

It is hard for me to believe that we're the only people who are having this problem, and I wonder if anyone solved it somehow.

I wanted to suggest a command-line option (or environment variable) that simply doesn't use a build server at all - each "sccache" invocation would just work separately (just sharing the cache directory), just as the old "ccache" did. Compilations are run in the foreground, and control-C kills them all.

Or do you have a better suggestion? In scylladb/scylladb#30552 I came up with a rather ugly workaround using SCCACHE_NO_DAEMON=1 (to ensure that the server that does start, is in this process group) and SCCACHE_SERVER_UDS (to avoid using some other build's server), but it's not pretty - both in how it's used, and how it behaves, and I was hoping for something better.

Activity

  1. sylvestre commented on Jul 1, 2026

    @sylvestre
    Collaborator

    this should be fixed by #2735

  2. nyh commented on Jul 1, 2026

    @nyh
    Author

    this should be fixed by #2735

    Thanks. Is there any documentation what this "client side mode" does, and how to use it? I didn't understand from that pull request what it is about.

  3. trxcllnt commented on Jul 1, 2026

    @trxcllnt
    Contributor

    I fixed this in our NVIDIA fork by aborting the tokio task and killing the associated subprocesses if a client disconnects. I isolated the fix to a single commit here. @sylvestre is it worth submitting a PR so users don't have to opt-in to this by default?

  4. sylvestre commented on Jul 1, 2026

    @sylvestre
    Collaborator

    Thanks. Is there any documentation what this "client side mode" does, and how to use it? I didn't understand from that pull request what it is about.

    see: https://github.com/sylvestre/sccache/blob/7f98f1ed9a64a36f13840e9bdcea2ef8fe515e4c/docs/Architecture.md
    tldr: the client manages the compilation instead of the server

    I fixed this in our NVIDIA fork by aborting the tokio task and killing the associated subprocesses if a client disconnects. I isolated the fix to a single commit here. @sylvestre is it worth submitting a PR so users don't have to opt-in to this by default?

    Sounds good :) don't hesitate to submit more PR ;)

  5. trxcllnt commented on Jul 1, 2026

    @trxcllnt
    Contributor

    Ok, PR is here #2761

  6. nyh commented on Oct 7, 2026

    @nyh
    Author

    Thanks! Just writing back that the new code is working beautifully (I tested on sccache 0.17.0) - when I interrupt my build with control-C, sccache kills all the compilation processes immediately, and they don't linger on for minutes as they did in the past. Very nice.

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

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions