From ff56e4f049ae2e993813162b03068d401715b93d Mon Sep 17 00:00:00 2001 From: baishihao Date: Tue, 10 Nov 2026 23:47:27 +0800 Subject: [PATCH 1/2] Raise the Decode open-file soft limit before spawning workers --- lightllm/server/api_start.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lightllm/server/api_start.py b/lightllm/server/api_start.py index a42acef884..88a1774f2f 100644 --- a/lightllm/server/api_start.py +++ b/lightllm/server/api_start.py @@ -3,6 +3,7 @@ import uuid import subprocess import math +import resource from lightllm.utils.start_utils import process_manager from .metrics.manager import start_metric_manager from .httpserver.req_id_generator_server import start_req_id_generator_server @@ -43,8 +44,28 @@ def _set_envs_and_config(args: StartArgs): mp.set_start_method("spawn", force=True) +def _configure_decode_open_file_limit(args: StartArgs): + if args.run_mode != "decode": + return + + # Each admitted request keeps several shared memory mappings open. + soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE) + preferred = 65536 + target = preferred if hard == resource.RLIM_INFINITY else min(preferred, hard) + if soft != resource.RLIM_INFINITY and soft < target: + try: + resource.setrlimit(resource.RLIMIT_NOFILE, (target, hard)) + except (OSError, ValueError): + logger.warning("Could not raise Decode open-file soft limit from %d to %d", soft, target, exc_info=True) + else: + logger.info("Raised the Decode open-file soft limit from %d to %d", soft, target) + if hard != resource.RLIM_INFINITY and hard < preferred: + logger.warning("Decode open-file hard limit is %d; a burst of requests may exhaust it", hard) + + def _launch_subprocesses(args: StartArgs): _validate_pd_features(args) + _configure_decode_open_file_limit(args) _set_envs_and_config(args) if args.target_vocab_topk_sampling is not None: From b2d88619e50a4e739abde343ff4072d1d5903c3c Mon Sep 17 00:00:00 2001 From: shihaobai <42648726+shihaobai@users.noreply.github.com> Date: Thu, 12 Nov 2026 18:02:42 +0800 Subject: [PATCH 2/2] Refactor Decode open-file limit setup into startup utilities --- lightllm/server/api_start.py | 24 ++---------------------- lightllm/utils/start_utils.py | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lightllm/server/api_start.py b/lightllm/server/api_start.py index 88a1774f2f..b5aadc981f 100644 --- a/lightllm/server/api_start.py +++ b/lightllm/server/api_start.py @@ -3,8 +3,7 @@ import uuid import subprocess import math -import resource -from lightllm.utils.start_utils import process_manager +from lightllm.utils.start_utils import configure_decode_open_file_limit, process_manager from .metrics.manager import start_metric_manager from .httpserver.req_id_generator_server import start_req_id_generator_server from .embed_cache.manager import start_cache_manager @@ -44,28 +43,9 @@ def _set_envs_and_config(args: StartArgs): mp.set_start_method("spawn", force=True) -def _configure_decode_open_file_limit(args: StartArgs): - if args.run_mode != "decode": - return - - # Each admitted request keeps several shared memory mappings open. - soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE) - preferred = 65536 - target = preferred if hard == resource.RLIM_INFINITY else min(preferred, hard) - if soft != resource.RLIM_INFINITY and soft < target: - try: - resource.setrlimit(resource.RLIMIT_NOFILE, (target, hard)) - except (OSError, ValueError): - logger.warning("Could not raise Decode open-file soft limit from %d to %d", soft, target, exc_info=True) - else: - logger.info("Raised the Decode open-file soft limit from %d to %d", soft, target) - if hard != resource.RLIM_INFINITY and hard < preferred: - logger.warning("Decode open-file hard limit is %d; a burst of requests may exhaust it", hard) - - def _launch_subprocesses(args: StartArgs): _validate_pd_features(args) - _configure_decode_open_file_limit(args) + configure_decode_open_file_limit(args) _set_envs_and_config(args) if args.target_vocab_topk_sampling is not None: diff --git a/lightllm/utils/start_utils.py b/lightllm/utils/start_utils.py index 93bc95a436..28a0e5566e 100644 --- a/lightllm/utils/start_utils.py +++ b/lightllm/utils/start_utils.py @@ -1,5 +1,6 @@ import os import ctypes +import resource import signal import subprocess import sys @@ -253,4 +254,23 @@ def kill_recursive(proc): logger.warning(f"Process {process.pid} does not exist.") +def configure_decode_open_file_limit(args): + if args.run_mode != "decode": + return + + # Each admitted request keeps several shared memory mappings open. + soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE) + preferred = 65536 + target = preferred if hard == resource.RLIM_INFINITY else min(preferred, hard) + if soft != resource.RLIM_INFINITY and soft < target: + try: + resource.setrlimit(resource.RLIMIT_NOFILE, (target, hard)) + except (OSError, ValueError): + logger.warning("Could not raise Decode open-file soft limit from %d to %d", soft, target, exc_info=True) + else: + logger.info("Raised the Decode open-file soft limit from %d to %d", soft, target) + if hard != resource.RLIM_INFINITY and hard < preferred: + logger.warning("Decode open-file hard limit is %d; a burst of requests may exhaust it", hard) + + process_manager = SubmoduleManager()