added: profiling toolchain (py-spy, pyinstrument, pytest-benchmark, memray, snakeviz)
New `profile` optional-deps group, opt-in Pyinstrument ASGI middleware gated by DECNET_PROFILE_REQUESTS, bench marker + tests/perf/ micro-benchmarks for repository hot paths, and scripts/profile/ helpers for py-spy/cProfile/memray.
This commit is contained in:
18
scripts/profile/pyspy-attach.sh
Executable file
18
scripts/profile/pyspy-attach.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
# Attach py-spy to the running DECNET uvicorn worker(s) and record a flamegraph.
|
||||
# Requires sudo on Linux because of kernel.yama.ptrace_scope=1 by default.
|
||||
set -euo pipefail
|
||||
|
||||
DURATION="${DURATION:-30}"
|
||||
OUT="${OUT:-profiles/pyspy-$(date +%s).svg}"
|
||||
mkdir -p "$(dirname "$OUT")"
|
||||
|
||||
PID="$(pgrep -f 'uvicorn decnet.web.api' | head -n 1 || true)"
|
||||
if [[ -z "${PID}" ]]; then
|
||||
echo "No uvicorn worker found. Start the API first (e.g. 'decnet deploy ...')." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Attaching py-spy to PID ${PID} for ${DURATION}s -> ${OUT}"
|
||||
sudo py-spy record -o "${OUT}" -p "${PID}" -d "${DURATION}" --subprocesses
|
||||
echo "Wrote ${OUT}"
|
||||
Reference in New Issue
Block a user