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

[core] Implement cgroup utils #48788

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dentiny
Copy link
Contributor

@dentiny dentiny commented Nov 18, 2024

This PR implement IO operations to manipulate memory cgroup.

Signed-off-by: dentiny <[email protected]>
@rynewang
Copy link
Contributor

so for this cgroup functionality we are not going to wrap it as a RuntimeEnvPlugin, instead we make a whole new set of abstractions? Do you have rationales for this?

@dentiny
Copy link
Contributor Author

dentiny commented Nov 18, 2024

so for this cgroup functionality we are not going to wrap it as a RuntimeEnvPlugin, instead we make a whole new set of abstractions?

Yes. The process execution should have a few interception points which we could inject custom logic.
For example,

  • before process starts (i.e. to prepare for runtime env);
  • right after process starts, that should be where we get PID for the process, and place into the cgroup
  • after process completes (i.e. to cleanup runtime env)

We only have (1) and (3), which are initialized at C++ side worker_pool.
At execution, we directly execute the binary inline with execve instead of a subprocess like subprocess.Popen, so we have another abstraction layer.

My planned way to implement cgroup related:

@rynewang
Copy link
Contributor

for (2)

why don't we let setup_worker.py put itself into cgroup them exec?

@dentiny
Copy link
Contributor Author

dentiny commented Nov 19, 2024

why don't we let setup_worker.py put itself into cgroup them exec?

Pseudocode looks like

runtime_env_context = RuntimeEnvContext.deserialize(args.serialized_runtime_env_context or "{}")

# My logic inserted before execution.
physical_context = GetPhysicalContext(runtime_env_context)
# Add current worker process into cgroup based on request.
SetCgroup(physical_context)

runtime_env_context.exec_worker(remaining_args, Language.Value(args.language))

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.

2 participants