Skip to content

Commit

Permalink
Omit unhelpful files from profiling
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mrocklin committed Oct 28, 2023
1 parent 6f9e491 commit faa9065
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions distributed/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import bisect
import dis
import linecache
import os
import sys
import threading
from collections import defaultdict, deque
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -184,6 +193,7 @@ def process(
return None

prev = frame.f_back

if (
depth > 0
and prev is not None
Expand All @@ -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:
Expand Down

0 comments on commit faa9065

Please sign in to comment.