Skip to content

Commit 0a88b76

Browse files
authored
Support adjusting GIL monitoring interval (#7650)
1 parent 12bc98c commit 0a88b76

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

distributed/distributed-schema.yaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,9 +1141,19 @@ properties:
11411141
host-cpu:
11421142
type: boolean
11431143
description: Should we include host-wide CPU usage, with very granular breakdown?
1144-
gil-contention:
1145-
type: boolean
1146-
description: Should we include GIL contention metrics, requires `gilknocker` to be installed.
1144+
gil:
1145+
type: object
1146+
description: |
1147+
Should we include GIL contention metrics, requires `gilknocker` to be installed.
1148+
properties:
1149+
enabled:
1150+
type: boolean
1151+
description: Enable monitoring of GIL contention
1152+
interval:
1153+
type: string
1154+
description: |
1155+
GIL polling interval. More frequent polling will reflect a more accurate GIL
1156+
contention metric but will be more likely to impact runtime performance.
11471157
11481158
rmm:
11491159
type: object

distributed/distributed.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,9 @@ distributed:
310310
interval: 500ms
311311
disk: true # Monitor host-wide disk I/O
312312
host-cpu: false # Monitor host-wide CPU usage, with very granular breakdown
313-
gil-contention: false # Monitor GIL contention
313+
gil:
314+
enabled: false # Monitor GIL contention
315+
interval: "1ms" # Frequency to poll GIL
314316
event-loop: tornado
315317
rmm:
316318
pool-size: null

distributed/system_monitor.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def __init__(
9595

9696
if monitor_gil_contention is None:
9797
monitor_gil_contention = dask.config.get(
98-
"distributed.admin.system-monitor.gil-contention"
98+
"distributed.admin.system-monitor.gil.enabled"
9999
)
100100
self.monitor_gil_contention = monitor_gil_contention
101101
if self.monitor_gil_contention:
@@ -108,7 +108,12 @@ def __init__(
108108
self.monitor_gil_contention = False
109109
else:
110110
self.quantities["gil_contention"] = deque(maxlen=maxlen)
111-
self._gilknocker = KnockKnock(1_000) # TODO(miles) param interval?
111+
raw_interval = dask.config.get(
112+
"distributed.admin.system-monitor.gil.interval",
113+
)
114+
interval = dask.utils.parse_timedelta(raw_interval, default="us") * 1e6
115+
116+
self._gilknocker = KnockKnock(polling_interval_micros=int(interval))
112117
self._gilknocker.start()
113118

114119
if not WINDOWS:

distributed/tests/test_system_monitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def test_gil_contention():
109109
a = sm.update()
110110
assert "gil_contention" in a
111111

112-
with dask.config.set({"distributed.admin.system-monitor.gil-contention": True}):
112+
with dask.config.set({"distributed.admin.system-monitor.gil.enabled": True}):
113113
sm = SystemMonitor()
114114
a = sm.update()
115115
assert "gil_contention" in a

0 commit comments

Comments
 (0)