From faa9065fbab81f27b24a2096bce13697096886dc Mon Sep 17 00:00:00 2001 From: Matthew Rocklin Date: Fri, 27 Oct 2023 20:52:09 -0500 Subject: [PATCH] Omit unhelpful files from profiling Systems like concurrent.futures and distributed/utils.py::sync aren't helpful to include in user profiles. This omits them. Not a big deal, it just felt a little cleaner. --- distributed/profile.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/distributed/profile.py b/distributed/profile.py index 46420ca4ebf..ea2f0f72ad5 100644 --- a/distributed/profile.py +++ b/distributed/profile.py @@ -29,6 +29,7 @@ import bisect import dis import linecache +import os import sys import threading from collections import defaultdict, deque @@ -125,12 +126,20 @@ def info_frame(frame: FrameType) -> dict[str, Any]: } +_skip_default = ( + os.path.join("concurrent", "futures", "_base.py"), + "threading.py", + os.path.join("distributed", "utils.py"), +) + + def process( frame: FrameType, child: object | None, state: dict[str, Any], *, stop: str | None = None, + skip: Collection[str] = _skip_default, omit: Collection[str] = (), depth: int | None = None, ) -> dict[str, Any] | None: @@ -184,6 +193,7 @@ def process( return None prev = frame.f_back + if ( depth > 0 and prev is not None @@ -194,6 +204,9 @@ def process( return None state = new_state + if any(frame.f_code.co_filename.endswith(s) for s in skip): + return state + ident = identifier(frame) try: