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

Optimize memory usage when using --processes #2564

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions locust/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import atexit
import errno
import gc
import inspect
import json
import logging
Expand Down Expand Up @@ -204,6 +205,9 @@ def is_valid_percentile(parameter):
"--master cannot be combined with --processes. Remove --master, as it is implicit as long as --worker is not set.\n"
)
sys.exit(1)
# Optimize copy-on-write-behavior to save some memory (aprx 26MB -> 15MB rss) in child processes
gc.collect() # avoid freezing garbage
gc.freeze() # move all objects to perm gen so ref counts dont get updated
for _ in range(options.processes):
child_pid = gevent.fork()
if child_pid:
Expand Down
Loading