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

Limit memory usage based on cgroup info #5260

Merged

Conversation

VannTen
Copy link
Member

@VannTen VannTen commented Jan 10, 2023

Related Issues and Dependencies

This should help diagnoses thoth-station/thoth-application#2690
We should get some stacktrace, which will help us locate where our python code allocates a lot. (Especially if we have a space complexity bug/problem)

This introduces a breaking change

  • Yes
  • No

Description

We try to convert OOM-kill at the cgroup level into python MemoryError.

The method employed has a number of caveats:

  • setrlimit only acts on one process, when cgroup is a group of process
    ; other process in the container could also consume memory
  • the OOM-killer might still kick in before Python raising MemoryError,
    depending on the particular of the Python allocator

@VannTen
Copy link
Member Author

VannTen commented Jan 10, 2023

@goern @harshad16 you might be interested.

@sesheta sesheta added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jan 10, 2023
@VannTen VannTen force-pushed the feat/respect_cgroup_memory_limit branch from 1e7afe7 to bc32b62 Compare January 10, 2023 12:55
Copy link
Member

@codificat codificat left a comment

Choose a reason for hiding this comment

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

Just one question/comment, but
/approve
the proposal, good idea, thanks

memory = limit.read()
if memory == "max": # memory.high might contain "max" -> indicates to use the memory.max value
continue
value = int(limit.read())
Copy link
Member

Choose a reason for hiding this comment

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

isn't this meant to be:

Suggested change
value = int(limit.read())
value = int(memory)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, spot on, thanks 👍

@VannTen VannTen force-pushed the feat/respect_cgroup_memory_limit branch from bc32b62 to 0207c59 Compare January 10, 2023 13:53
We try to convert OOM-kill at the cgroup level into python MemoryError.

The method employed has a number of caveats:
- setrlimit only acts on one process, when cgroup is a group of process
  ; other process in the container could also consume memory
- the OOM-killer might still kick in before Python raising MemoryError,
  depending on the particular of the Python allocator
@goern
Copy link
Member

goern commented Jan 16, 2023

/lgtm
/approve

@sesheta sesheta added the lgtm Indicates that a PR is ready to be merged. label Jan 16, 2023
@sesheta
Copy link
Member

sesheta commented Jan 16, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: codificat, goern

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sesheta sesheta added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 16, 2023
@goern goern merged commit 68a9a8e into thoth-station:master Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants