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

fix: add max_job_memory_usage for worker #1136

Merged
merged 5 commits into from
Nov 27, 2024
Merged

Conversation

longcw
Copy link
Collaborator

@longcw longcw commented Nov 26, 2024

No description provided.

Copy link

changeset-bot bot commented Nov 26, 2024

🦋 Changeset detected

Latest commit: 37e3ed1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
livekit-agents Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -158,6 +158,11 @@ class WorkerOptions:

Defaults to 0.75 on "production" mode, and is disabled in "development" mode.
"""
max_job_memory_usage: float = 0
Copy link
Member

Choose a reason for hiding this comment

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

Let's put something like 300MB by default?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would prefer to leave it empty and let the users to decide.

This might be a breaking change if there is a default limit. I have tested that the minimal assistant agent the RAM usage is around 150M, but it could be higher if users load some other data or publishing/receiving videos. Those agents will be killed unexpectedly after upgrading.

Copy link
Member

Choose a reason for hiding this comment

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

it makes sense to not break existing apps. Is it possible to have a "warn" mode where we initially let folks know about the high memory usage without killing the requests? Since most users don't pay attention to memory, making memory issues clearly visible would be beneficial.

maybe we should have two separate options?

  • job_memory_warn
  • job_memory_limit

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

job_memory_warn_mb (defaults to 300) and job_memory_limit_mb are added.

Comment on lines 242 to 250
if (
opts.max_job_memory_usage > 0
and opts.job_executor_type != JobExecutorType.PROCESS
):
logger.warning(
"max_job_memory_usage is only supported for process-based job executors, "
"ignoring max_job_memory_usage"
)

Copy link
Member

Choose a reason for hiding this comment

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

Make sure to remove this comment if we put a max memory usage by default (Windows is using JobExecutorType.PROCESS by default)

@theomonnom
Copy link
Member

Lgtm just a few nits!

@longcw longcw merged commit 57834ec into main Nov 27, 2024
16 checks passed
@longcw longcw deleted the fix/max-job-memory-usage branch November 27, 2024 11:47
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.

3 participants