[Perf][CLI] Improve overall startup time (#19941)
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
|
||||
# yapf: disable
|
||||
import argparse
|
||||
import copy
|
||||
import dataclasses
|
||||
import functools
|
||||
import json
|
||||
import sys
|
||||
import threading
|
||||
@@ -168,7 +170,8 @@ def get_type_hints(type_hint: TypeHint) -> set[TypeHint]:
|
||||
return type_hints
|
||||
|
||||
|
||||
def get_kwargs(cls: ConfigType) -> dict[str, Any]:
|
||||
@functools.lru_cache(maxsize=30)
|
||||
def _compute_kwargs(cls: ConfigType) -> dict[str, Any]:
|
||||
cls_docs = get_attr_docs(cls)
|
||||
kwargs = {}
|
||||
for field in fields(cls):
|
||||
@@ -269,6 +272,16 @@ def get_kwargs(cls: ConfigType) -> dict[str, Any]:
|
||||
return kwargs
|
||||
|
||||
|
||||
def get_kwargs(cls: ConfigType) -> dict[str, Any]:
|
||||
"""Return argparse kwargs for the given Config dataclass.
|
||||
|
||||
The heavy computation is cached via functools.lru_cache, and a deep copy
|
||||
is returned so callers can mutate the dictionary without affecting the
|
||||
cached version.
|
||||
"""
|
||||
return copy.deepcopy(_compute_kwargs(cls))
|
||||
|
||||
|
||||
@dataclass
|
||||
class EngineArgs:
|
||||
"""Arguments for vLLM engine."""
|
||||
|
||||
Reference in New Issue
Block a user