@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 14bcf93a6a
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 14, 05:30 UTC

Optimize logger init performance by using module-level constants (#22373)

Signed-off-by: zitian.zhao <zitian.zhao@tencentmusic.com>

ZiTian.Zhao committed Aug 7, 2025 at 11:32 UTC 14bcf93a6a59072fd5bc542d0ad73c54546cef5c
1 file changed +9 -7
vllm/logger.py
+9 -7
@@ -102,6 +102,14 @@ class _VllmLogger(Logger):
102 _print_warning_once(self, msg, *args)
103
104
105 +# Pre-defined methods mapping to avoid repeated dictionary creation
106 +_METHODS_TO_PATCH = {
107 + "debug_once": _print_debug_once,
108 + "info_once": _print_info_once,
109 + "warning_once": _print_warning_once,
110 +}
111 +
112 +
113 def _configure_vllm_root_logger() -> None:
114 logging_config = dict[str, Any]()
115
@@ -144,13 +152,7 @@ def init_logger(name: str) -> _VllmLogger:
152
153 logger = logging.getLogger(name)
154
147 - methods_to_patch = {
148 - "debug_once": _print_debug_once,
149 - "info_once": _print_info_once,
150 - "warning_once": _print_warning_once,
151 - }
152 -
153 - for method_name, method in methods_to_patch.items():
155 + for method_name, method in _METHODS_TO_PATCH.items():
156 setattr(logger, method_name, MethodType(method, logger))
157
158 return cast(_VllmLogger, logger)