Skip to content

Commit 5fc5e90

Browse files
authored
add time log for debug. (#1087)
1 parent 16a41d2 commit 5fc5e90

File tree

1 file changed

+10
-0
lines changed
  • lightllm/server/core/objs

1 file changed

+10
-0
lines changed

lightllm/server/core/objs/req.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import math
33
import ctypes
44
import numpy as np
5+
import time
56
from .sampling_params import SamplingParams
67
from .out_token_circlequeue import CircularQueue
78
from .shm_array import ShmArray
@@ -11,6 +12,9 @@
1112
from lightllm.utils.envs_utils import get_env_start_args
1213
from lightllm.utils.kv_cache_utils import compute_token_list_hash
1314
from typing import List, Any, Union
15+
from lightllm.utils.log_utils import init_logger
16+
17+
logger = init_logger(__name__)
1418

1519

1620
class FinishStatus(ctypes.Structure):
@@ -68,6 +72,7 @@ class Req(ctypes.Structure):
6872
_fields_ = [
6973
("index_in_shm_mem", ctypes.c_int),
7074
("ref_count", ctypes.c_int), # 个人不要操作这个计数 # 个人不要操作这个引用计数
75+
("recv_time", ctypes.c_double), # 用于记录请求到达服务的时间,主要用于调试
7176
("request_id", ctypes.c_int64), # 引用计数
7277
("group_req_id", ctypes.c_int64),
7378
("input_len", ctypes.c_int),
@@ -137,6 +142,7 @@ def init(
137142
# 只是为了有更好的编码辅助类型提示
138143
self.index_in_shm_mem: int = self.index_in_shm_mem
139144
self.ref_count: int = self.ref_count
145+
self.recv_time: float = time.time()
140146

141147
self.request_id = request_id
142148
self.group_req_id = convert_sub_id_to_group_id(request_id)
@@ -290,6 +296,10 @@ def is_infer_decode(self) -> bool:
290296
else:
291297
return False
292298

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+
293303

294304
# 由于目前加入了很多异步调度的方法,为了缓解异步调度带来的很多
295305
# 估计不准确的问题,通过加长输出的长度,进行偏向保守一些的调度

0 commit comments

Comments
 (0)