Skip to content

Increase available PIDs to 5#112

Merged
MarkKoz merged 4 commits into
mainfrom
jb3/increase-available-pids
Jul 17, 2021
Merged

Increase available PIDs to 5#112
MarkKoz merged 4 commits into
mainfrom
jb3/increase-available-pids

Conversation

@jb3
Copy link
Copy Markdown
Member

@jb3 jb3 commented Jul 17, 2021

This PR increases the PIDs cgroup limit to 5. Processes spawned in snekbox will have up to 5 PIDs available, each sharing the same memory limits and environment as the parent python process. As far as I could see in testing this does appear safe and processes behave as expected, even when detatching from the parent and so on.

I'd appreciate if anyone with a local setup could give this a shot and play with things like multiprocessing, subprocess and any other low level proc interfaces.

@jb3 jb3 requested review from Akarys42, Den4200 and MarkKoz as code owners July 17, 2021 13:53
@coveralls
Copy link
Copy Markdown

coveralls commented Jul 17, 2021

Coverage Status

Coverage remained the same at 91.463% when pulling 096a8d2 on jb3/increase-available-pids into 5d7e735 on main.

jb3 added 3 commits July 17, 2021 15:13
Processes spawned in snekbox now have up to 5 PIDs available, each sharing the same memory limits and environment as the parent python process. As far as I could see in testing this does appear safe and processes behave as expected even when detatching from the parent or exceeding memory limits.
We define a few environment variables to stop third party libraries trying to default to spawning more processes, with the PID limit modification we can increase these values.
@jb3 jb3 force-pushed the jb3/increase-available-pids branch from b48d938 to 43e9523 Compare July 17, 2021 14:15
Copy link
Copy Markdown
Contributor

@jchristgit jchristgit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as this goes into the same cgroup, this is good, Joe, very good

@MarkKoz
Copy link
Copy Markdown
Contributor

MarkKoz commented Jul 17, 2021

Thank @jb3. Can you think of any way to write a test for the resource limits being shared?

This test ensures that spawned child processes inherit the same resource group as the parent by spawning 2 child processes which each allocate a 40MB object, it then verifies that one of the child processes was killed with SIGKILL for violating the resource quota.
@jb3 jb3 force-pushed the jb3/increase-available-pids branch from 5318d03 to 096a8d2 Compare July 17, 2021 15:26
Copy link
Copy Markdown
Contributor

@MarkKoz MarkKoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are passing, so I'm gonna go off that and say this works.

@MarkKoz MarkKoz merged commit 980ff08 into main Jul 17, 2021
@MarkKoz MarkKoz deleted the jb3/increase-available-pids branch July 17, 2021 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants