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

Connecting to long running Dev Container takes extremely long time #951

Open
ryxli opened this issue Jan 16, 2025 · 4 comments
Open

Connecting to long running Dev Container takes extremely long time #951

ryxli opened this issue Jan 16, 2025 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@ryxli
Copy link

ryxli commented Jan 16, 2025

This is connecting to a persistent docker container I manually started, and then attaching to the container via the remote explorer. I am working inside this container for a lengthy period of time, which is started with CMD like:

            "Cmd": [
                "/bin/bash",
                "-c",
                "tail -f /dev/null"
            ],

Over time, the number of defunct processes grows within the container. When I attempt to reconnect to the container, there is a significant bottleneck in the following steps:

[23089 ms] Start: Run in container: for pid in `cd /proc && ls -d [0-9]*`; do { echo $pid ; readlink /proc/$pid/cwd || echo ; readlink /proc/$pid/ns/mnt || echo ; cat /proc/$pid/stat | tr "
[23864 ms] 
[23864 ms] 
[26440 ms] userEnvProbe PATHs:
...
...

[279891 ms] Start: Run in container: for pid in `cd /proc && ls -d [0-9]*`; do { echo $pid ; readlink /proc/$pid/cwd || echo ; readlink /proc/$pid/ns/mnt || echo ; cat /proc/$pid/stat | tr "
...
...
[532731 ms] Start: Run in container: mkdir -p '/tmp/devcontainers-xxxxxx' && cat > '/tmp/devcontainers-devcontainers-xxxxxx/env-loginInteractiveShell.json' << 'envJSON'
...

Only workaround I have found is to restart the container, which cleans up all of the zombie processes. Then connecting to the container is fast again.

@bamurtaugh
Copy link
Member

Thanks for opening. @chrmarti I wonder if you have thoughts here?

@chrmarti
Copy link
Contributor

chrmarti commented Feb 3, 2025

Reading process information from the proc filesystem will slow down with a large number of process. We could look into optimizing that.

Are the zombie processes caused by a bug in VS Code or by something else?

@chrmarti chrmarti self-assigned this Feb 3, 2025
@chrmarti chrmarti transferred this issue from devcontainers/features Feb 3, 2025
@chrmarti chrmarti added the info-needed Issue requires more information from poster label Feb 3, 2025
@ryxli
Copy link
Author

ryxli commented Feb 3, 2025

No, zombie processes are just a side effect of the docker init process not automatically cleaning up processes when they terminate.

For example, when manually starting container, one might use a simple sleep command or:

            "Cmd": [
                "/bin/bash",
                "-c",
                "tail -f /dev/null"
            ],

Then all processes started within the container would be child processes of the main process, and don't get cleaned up until the docker container is stopped.

@chrmarti chrmarti added bug Something isn't working and removed info-needed Issue requires more information from poster labels Feb 4, 2025
@ryxli
Copy link
Author

ryxli commented Feb 7, 2025

One solution I think is probably just pass --init flag to docker run so that zombie processes can get cleaned up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants