add an option to record time spent waiting for GIL (#30842)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30842

We'd like to profile the time spent on GIL acqusiition to debug
performance issues.

Test Plan: Unit tests pass.

Differential Revision: D18837590

fbshipit-source-id: 925968f71c5fb96b8cd93f1eab4647602d2617d1
This commit is contained in:
Rohan Varma
2020-01-21 10:51:06 -08:00
committed by Facebook Github Bot
parent 1177191c8e
commit 9ce25cce91
9 changed files with 179 additions and 38 deletions

View File

@ -416,6 +416,17 @@ def _invoke_rpc(to, func, rpc_type, args=None, kwargs=None):
_agent, info, pickled_python_udf, tensors, rf)
return fut
@_require_initialized
def enable_gil_profiling(flag):
r"""
Set whether GIL wait times should be enabled or not. This incurs a slight
overhead cost. Default is disabled for performance reasons.
Arguments:
flag (bool): True to set metrics profiling, False to disable.
"""
_agent.enable_gil_profiling(flag)
@_require_initialized
def rpc_sync(to, func, args=None, kwargs=None):