Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
change
sglang
Commits
edc21cc8
Unverified
Commit
edc21cc8
authored
Jun 22, 2025
by
fzyzcjy
Committed by
GitHub
Jun 22, 2025
Browse files
Tiny add logging for GC (#7406)
parent
05c9bc89
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
0 deletions
+29
-0
python/sglang/srt/managers/scheduler.py
python/sglang/srt/managers/scheduler.py
+4
-0
python/sglang/srt/utils.py
python/sglang/srt/utils.py
+25
-0
No files found.
python/sglang/srt/managers/scheduler.py
View file @
edc21cc8
...
@@ -140,6 +140,7 @@ from sglang.srt.utils import (
...
@@ -140,6 +140,7 @@ from sglang.srt.utils import (
DeepEPMode
,
DeepEPMode
,
DynamicGradMode
,
DynamicGradMode
,
broadcast_pyobj
,
broadcast_pyobj
,
configure_gc_logger
,
configure_logger
,
configure_logger
,
disable_request_logging
,
disable_request_logging
,
get_available_gpu_memory
,
get_available_gpu_memory
,
...
@@ -508,6 +509,9 @@ class Scheduler(
...
@@ -508,6 +509,9 @@ class Scheduler(
)
)
self
.
init_disaggregation
()
self
.
init_disaggregation
()
if
get_bool_env_var
(
"SGLANG_GC_LOG"
):
configure_gc_logger
()
def
maybe_sleep_on_idle
(
self
):
def
maybe_sleep_on_idle
(
self
):
if
self
.
idle_sleeper
is
not
None
:
if
self
.
idle_sleeper
is
not
None
:
self
.
idle_sleeper
.
maybe_sleep
()
self
.
idle_sleeper
.
maybe_sleep
()
...
...
python/sglang/srt/utils.py
View file @
edc21cc8
...
@@ -2485,3 +2485,28 @@ def dynamic_import(func_path: str):
...
@@ -2485,3 +2485,28 @@ def dynamic_import(func_path: str):
module
=
importlib
.
import_module
(
module_path
)
module
=
importlib
.
import_module
(
module_path
)
func
=
getattr
(
module
,
func_name
)
func
=
getattr
(
module
,
func_name
)
return
func
return
func
def
configure_gc_logger
():
logger
.
info
(
"Enable GC Logger"
)
import
gc
gc_start_time
=
{}
def
gc_callback
(
phase
,
info
):
gen
=
info
.
get
(
"generation"
,
"?"
)
if
phase
==
"start"
:
gc_start_time
[
gen
]
=
time
.
time
()
logger
.
info
(
f
"GC start: Time
{
time
.
time
()
}
| Generation
{
gen
}
"
)
elif
phase
==
"stop"
:
duration
=
time
.
time
()
-
gc_start_time
.
get
(
gen
,
time
.
time
())
collected
=
info
.
get
(
"collected"
,
"?"
)
uncollectable
=
info
.
get
(
"uncollectable"
,
"?"
)
logger
.
info
(
f
"GC end: Time
{
time
.
time
()
}
| Generation
{
gen
}
| "
f
"Duration:
{
duration
:.
4
f
}
s | Collected:
{
collected
}
| Uncollectable:
{
uncollectable
}
"
f
'
{
"(LONG GC)"
if
duration
>
0.1
else
""
}
'
)
gc
.
callbacks
.
append
(
gc_callback
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment