|
2 | 2 | import math |
3 | 3 | import ctypes |
4 | 4 | import numpy as np |
| 5 | +import time |
5 | 6 | from .sampling_params import SamplingParams |
6 | 7 | from .out_token_circlequeue import CircularQueue |
7 | 8 | from .shm_array import ShmArray |
|
11 | 12 | from lightllm.utils.envs_utils import get_env_start_args |
12 | 13 | from lightllm.utils.kv_cache_utils import compute_token_list_hash |
13 | 14 | from typing import List, Any, Union |
| 15 | +from lightllm.utils.log_utils import init_logger |
| 16 | + |
| 17 | +logger = init_logger(__name__) |
14 | 18 |
|
15 | 19 |
|
16 | 20 | class FinishStatus(ctypes.Structure): |
@@ -68,6 +72,7 @@ class Req(ctypes.Structure): |
68 | 72 | _fields_ = [ |
69 | 73 | ("index_in_shm_mem", ctypes.c_int), |
70 | 74 | ("ref_count", ctypes.c_int), # 个人不要操作这个计数 # 个人不要操作这个引用计数 |
| 75 | + ("recv_time", ctypes.c_double), # 用于记录请求到达服务的时间,主要用于调试 |
71 | 76 | ("request_id", ctypes.c_int64), # 引用计数 |
72 | 77 | ("group_req_id", ctypes.c_int64), |
73 | 78 | ("input_len", ctypes.c_int), |
@@ -137,6 +142,7 @@ def init( |
137 | 142 | # 只是为了有更好的编码辅助类型提示 |
138 | 143 | self.index_in_shm_mem: int = self.index_in_shm_mem |
139 | 144 | self.ref_count: int = self.ref_count |
| 145 | + self.recv_time: float = time.time() |
140 | 146 |
|
141 | 147 | self.request_id = request_id |
142 | 148 | self.group_req_id = convert_sub_id_to_group_id(request_id) |
@@ -290,6 +296,10 @@ def is_infer_decode(self) -> bool: |
290 | 296 | else: |
291 | 297 | return False |
292 | 298 |
|
| 299 | + def print_time_log(self, log_info: str): |
| 300 | + logger.info(f"req_id: {self.request_id} cost_time {time.time() - self.recv_time} s log_info: {log_info}") |
| 301 | + return |
| 302 | + |
293 | 303 |
|
294 | 304 | # 由于目前加入了很多异步调度的方法,为了缓解异步调度带来的很多 |
295 | 305 | # 估计不准确的问题,通过加长输出的长度,进行偏向保守一些的调度 |
|
0 commit comments