Skip to content

Commit 1cb81c9

Browse files
committed
Rename to dask-profiling
1 parent 311ff5f commit 1cb81c9

11 files changed

+165
-213
lines changed

Dockerfile

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ RUN apt install -y python3-pip
55
RUN pip3 install --upgrade pip poetry
66
# ^ pip: https://github.com/python-poetry/poetry/issues/5104
77

8-
WORKDIR /opt/src/scheduler-profilers
8+
WORKDIR /opt/src/dask-profiling
99

1010
COPY poetry.lock .
1111
COPY pyproject.toml .
1212

13-
RUN poetry config virtualenvs.create false && poetry install --only main,docker
13+
RUN poetry config virtualenvs.in-project true && \
14+
poetry install --only main,docker
1415

15-
COPY scheduler_profilers /opt/src/scheduler-profilers/scheduler_profilers
16+
ENV PATH="/opt/src/dask-profiling/.venv/bin:$PATH"
17+
18+
COPY dask_profiling /opt/src/dask-profiling/dask_profiling
1619
RUN pip3 install --no-deps .

README.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# scheduler-profilers
1+
# dask-profiling
22

3-
Profile the dask [distributed](https://github.com/dask/distributed) scheduler with [py-spy](https://github.com/benfred/py-spy) or [viztracer](https://github.com/gaogaotiantian/viztracer).
3+
Profile dask [distributed](https://github.com/dask/distributed) clusters with [py-spy](https://github.com/benfred/py-spy) or [viztracer](https://github.com/gaogaotiantian/viztracer).
44

55
```python
66
import dask
77
import distributed
88

9-
from scheduler_profilers import pyspy_on_scheduler, viztrace_scheduler
9+
from dask_profiling import pyspy_on_scheduler, viztrace_scheduler
1010

1111
client = distributed.Client()
1212

@@ -32,25 +32,29 @@ Using `pyspy_on_scheduler` or `viztrace_scheduler` attaches a profiler to the sc
3232

3333
By default, py-spy profiles are recorded in [speedscope](https://www.speedscope.app/) format. [Viztracer profiles](https://viztracer.readthedocs.io/en/latest/basic_usage.html#display-report) are recorded in Chrome trace format, viewable with [Perfetto](https://ui.perfetto.dev/) or <chrome://tracing>.
3434

35-
`scheduler-profilers` (and, transitively, `py-spy`/`viztracer`) must be installed in the environment where the scheduler is running.
35+
`dask-profiling` (and, transitively, `py-spy`/`viztracer`) must be installed in the environment where the scheduler is running.
3636

3737
## Installation
3838

3939
```
40-
python -m pip install git+https://github.com/gjoseph92/scheduler-profilers.git@main
40+
python -m pip install git+https://github.com/gjoseph92/dask-profiling.git@main
4141
```
4242

4343
## Privileges for py-spy
4444

45-
You may need to run the scheduler process as root for py-spy to be able to profile it (especially on macOS). See https://github.com/benfred/py-spy#when-do-you-need-to-run-as-sudo.
45+
**tl;dr:**
46+
* On macOS, you have to launch your cluster with `sudo`
47+
* For `docker run`, pass `--cap-add SYS_PTRACE`, or download this newer [`seccomp.json`](https://github.com/moby/moby/blob/d39b075302c27f77b2de413697a5aacb034d8286/profiles/seccomp/default.json) file and use `--seccomp=default.json`.
4648

47-
In a Docker container, `scheduler-profilers` will "just work" for Docker/moby versions >= 21.xx. As of right now (May 2021), Docker 21.xx doesn't exist yet, so read on.
49+
You may need to run the dask process as root for py-spy to be able to profile it (especially on macOS). See https://github.com/benfred/py-spy#when-do-you-need-to-run-as-sudo.
4850

49-
[moby/moby#42083](https://github.com/moby/moby/pull/42083/files) recently allowlisted the `process_vm_readv` system call that py-spy uses, which used to be blocked unless you set `--cap-add SYS_PTRACE`. This has been reasonable/safe to do for a while, but just wasn't enabled. So your options right now are:
51+
In a Docker container, `dask-profiling` will "just work" for Docker/moby versions >= 21.xx. As of right now (Nov 2022), Docker 21.xx doesn't exist yet, so read on.
52+
53+
[moby/moby#42083](https://github.com/moby/moby/pull/42083/files) recently allowlisted the `process_vm_readv` system call that py-spy uses, which used to be blocked unless you set `--cap-add SYS_PTRACE`. Allowing this specific system call in unprivileged containers has been safe to do for a while (since linux kernel versions > 4.8), but just wasn't enabled in Docker. So your options right now are:
5054
* (low/no security impact) Download the newer [`seccomp.json`](https://github.com/moby/moby/blob/d39b075302c27f77b2de413697a5aacb034d8286/profiles/seccomp/default.json) file from moby/master and pass it to Docker via `--seccomp=default.json`.
5155
* (more convenient) Pass `--cap-add SYS_PTRACE` to Docker. This enables more than you need, but it's one less step.
5256

53-
On Ubuntu-based containers, ptrace system calls are [further blocked](https://www.kernel.org/doc/Documentation/admin-guide/LSM/Yama.rst): processes are prohibited from ptracing each other even within the same UID. To work around this, `scheduler-profilers` automatically uses [`prctl(2)`](https://man7.org/linux/man-pages/man2/prctl.2.html) to mark the scheduler process as ptrace-able by itself and any child processes, then launches py-spy as a child process.
57+
On Ubuntu-based containers, ptrace system calls are [further blocked](https://www.kernel.org/doc/Documentation/admin-guide/LSM/Yama.rst): processes are prohibited from ptracing each other even within the same UID. To work around this, `dask-profiling` automatically uses [`prctl(2)`](https://man7.org/linux/man-pages/man2/prctl.2.html) to mark the scheduler process as ptrace-able by itself and any child processes, then launches py-spy as a child process.
5458

5559
## Viztracer targeting with `trace_sparse`
5660

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

docker-compose.yml

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
services:
22
scheduler:
33
build: .
4-
command: dask-scheduler
4+
command: dask scheduler
55
ports:
66
- "8786:8786"
77
- "8787:8787"
@@ -10,11 +10,17 @@ services:
1010
- seccomp:./moby-20.10.6-seccomp.json
1111
worker-1:
1212
build: .
13-
command: dask-worker tcp://scheduler:8786
13+
command: dask worker tcp://scheduler:8786
1414
depends_on:
1515
- scheduler
16+
security_opt:
17+
# Remove for docker >= 20.10.6
18+
- seccomp:./moby-20.10.6-seccomp.json
1619
worker-2:
1720
build: .
18-
command: dask-worker tcp://scheduler:8786
21+
command: dask worker tcp://scheduler:8786
1922
depends_on:
2023
- scheduler
24+
security_opt:
25+
# Remove for docker >= 20.10.6
26+
- seccomp:./moby-20.10.6-seccomp.json

0 commit comments

Comments
 (0)