Skip to content

Commit

Permalink
Support adjusting GIL monitoring interval (#7650)
Browse files Browse the repository at this point in the history
  • Loading branch information
milesgranger authored Mar 15, 2023
1 parent 12bc98c commit 0a88b76
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
16 changes: 13 additions & 3 deletions distributed/distributed-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1141,9 +1141,19 @@ properties:
host-cpu:
type: boolean
description: Should we include host-wide CPU usage, with very granular breakdown?
gil-contention:
type: boolean
description: Should we include GIL contention metrics, requires `gilknocker` to be installed.
gil:
type: object
description: |
Should we include GIL contention metrics, requires `gilknocker` to be installed.
properties:
enabled:
type: boolean
description: Enable monitoring of GIL contention
interval:
type: string
description: |
GIL polling interval. More frequent polling will reflect a more accurate GIL
contention metric but will be more likely to impact runtime performance.
rmm:
type: object
Expand Down
4 changes: 3 additions & 1 deletion distributed/distributed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ distributed:
interval: 500ms
disk: true # Monitor host-wide disk I/O
host-cpu: false # Monitor host-wide CPU usage, with very granular breakdown
gil-contention: false # Monitor GIL contention
gil:
enabled: false # Monitor GIL contention
interval: "1ms" # Frequency to poll GIL
event-loop: tornado
rmm:
pool-size: null
9 changes: 7 additions & 2 deletions distributed/system_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def __init__(

if monitor_gil_contention is None:
monitor_gil_contention = dask.config.get(
"distributed.admin.system-monitor.gil-contention"
"distributed.admin.system-monitor.gil.enabled"
)
self.monitor_gil_contention = monitor_gil_contention
if self.monitor_gil_contention:
Expand All @@ -108,7 +108,12 @@ def __init__(
self.monitor_gil_contention = False
else:
self.quantities["gil_contention"] = deque(maxlen=maxlen)
self._gilknocker = KnockKnock(1_000) # TODO(miles) param interval?
raw_interval = dask.config.get(
"distributed.admin.system-monitor.gil.interval",
)
interval = dask.utils.parse_timedelta(raw_interval, default="us") * 1e6

self._gilknocker = KnockKnock(polling_interval_micros=int(interval))
self._gilknocker.start()

if not WINDOWS:
Expand Down
2 changes: 1 addition & 1 deletion distributed/tests/test_system_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_gil_contention():
a = sm.update()
assert "gil_contention" in a

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

0 comments on commit 0a88b76

Please sign in to comment.