mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-10 03:54:56 +08:00
Optimize logger init performance by using module-level constants (#22373)
Signed-off-by: zitian.zhao <zitian.zhao@tencentmusic.com>
This commit is contained in:
parent
ecbea55ca2
commit
14bcf93a6a
@ -102,6 +102,14 @@ class _VllmLogger(Logger):
|
||||
_print_warning_once(self, msg, *args)
|
||||
|
||||
|
||||
# Pre-defined methods mapping to avoid repeated dictionary creation
|
||||
_METHODS_TO_PATCH = {
|
||||
"debug_once": _print_debug_once,
|
||||
"info_once": _print_info_once,
|
||||
"warning_once": _print_warning_once,
|
||||
}
|
||||
|
||||
|
||||
def _configure_vllm_root_logger() -> None:
|
||||
logging_config = dict[str, Any]()
|
||||
|
||||
@ -144,13 +152,7 @@ def init_logger(name: str) -> _VllmLogger:
|
||||
|
||||
logger = logging.getLogger(name)
|
||||
|
||||
methods_to_patch = {
|
||||
"debug_once": _print_debug_once,
|
||||
"info_once": _print_info_once,
|
||||
"warning_once": _print_warning_once,
|
||||
}
|
||||
|
||||
for method_name, method in methods_to_patch.items():
|
||||
for method_name, method in _METHODS_TO_PATCH.items():
|
||||
setattr(logger, method_name, MethodType(method, logger))
|
||||
|
||||
return cast(_VllmLogger, logger)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user