Skip to content

Commit 126af39

Browse files
staging-devin-ai-integration[bot]streamkit-devinstreamer45
authored
feat(profiling): add dev-profiling Cargo profile for fast iteration (#284)
Add a 'dev-profiling' Cargo profile that inherits from 'dev' with opt-level 2. This gives meaningful profiles (inlining, vectorisation) without the expensive LTO link step, and benefits from incremental compilation for fast rebuilds. Two profiling modes are now available: Dev (fast): just skit-profiling-dev serve Release (accurate): just skit-profiling serve The dev mode drops target-cpu=native (vs release) so the cache stays stable across rebuilds. Both modes enable frame pointers for pprof and share the same HTTP profiling endpoints. Signed-off-by: StreamKit Devin <devin@streamkit.dev> Co-authored-by: StreamKit Devin <devin@streamkit.dev> Co-authored-by: Claudio Costa <cstcld91@gmail.com>
1 parent 304c0b9 commit 126af39

File tree

2 files changed

+36
-10
lines changed

2 files changed

+36
-10
lines changed

Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ opt-level = 3
7878
[profile.dev.package.maybe-rayon]
7979
opt-level = 3
8080

81+
# Fast development profiling — no LTO, incremental compilation.
82+
# Inherits dev's per-package overrides (rav1e, rav1d at opt-level 3) and
83+
# incremental compilation. Uses opt-level 2 so profiles are meaningful
84+
# (inlining, vectorisation) while skipping the expensive LTO link step.
85+
# First build populates the cache; subsequent rebuilds are incremental.
86+
[profile.dev-profiling]
87+
inherits = "dev"
88+
opt-level = 2
89+
8190
[workspace.lints.rust]
8291
unsafe_code = "forbid"
8392
# missing_debug_implementations = "warn"

justfile

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,25 +104,40 @@ build-skit-native:
104104
@echo "Building skit (target-cpu=native)..."
105105
@RUSTFLAGS="-C target-cpu=native" cargo build --release {{moq_features}} {{extra_features}} -p streamkit-server --bin skit
106106

107-
# Build the skit with profiling support
107+
# Build skit for quick dev profiling (no LTO, incremental, fast rebuild)
108+
# Uses opt-level 2 for meaningful profiles without the LTO link overhead.
109+
# Frame pointers are required by pprof's frame-pointer unwinder.
110+
build-skit-profiling-dev:
111+
@echo "Building skit for dev profiling (opt-level 2, no LTO, frame pointers)..."
112+
@RUSTFLAGS="-C force-frame-pointers=yes" cargo build --profile dev-profiling {{moq_features}} {{profiling_features}} -p streamkit-server --bin skit
113+
114+
# Build skit with release profiling support (production-accurate)
108115
# Uses release-lto profile for thin LTO (eliminates UB-check overhead and enables
109116
# cross-crate SIMD inlining), frame pointers for fast stack unwinding (required by
110117
# pprof frame-pointer feature), and target-cpu=native so profiles reflect host-tuned codegen.
111118
build-skit-profiling:
112-
@echo "Building skit with profiling support (release-lto + frame pointers + native CPU)..."
119+
@echo "Building skit with release profiling support (release-lto + frame pointers + native CPU)..."
113120
@RUSTFLAGS="-C force-frame-pointers=yes -C target-cpu=native" cargo build --profile release-lto {{moq_features}} {{profiling_features}} -p streamkit-server --bin skit
114121

115122
# Start the skit server
116123
skit *args='': check-ui-dist
117124
@echo "Starting skit..."
118125
@cargo run {{moq_features}} {{extra_features}} -p streamkit-server --bin skit -- {{args}}
119126

120-
# Start the skit server with profiling support (CPU + heap)
127+
# Start skit with dev profiling support (CPU + heap, no LTO, fast rebuild)
128+
# Use this for quick iteration: profiles are representative enough to find
129+
# bottlenecks without the compile-time cost of release-lto.
130+
skit-profiling-dev *args='':
131+
@echo "Starting skit with dev profiling (opt-level 2, no LTO, frame pointers)..."
132+
@echo "Note: Profiles reflect opt-level 2 without LTO — faster build, slightly less accurate than release"
133+
@RUSTFLAGS="-C force-frame-pointers=yes" cargo run --profile dev-profiling {{moq_features}} {{profiling_features}} -p streamkit-server --bin skit -- {{args}}
134+
135+
# Start skit with release profiling support (CPU + heap, production-accurate)
121136
# Uses release-lto profile for thin LTO (eliminates UB-check overhead and enables
122137
# cross-crate SIMD inlining), frame pointers for fast stack unwinding (required by
123138
# pprof frame-pointer feature), and target-cpu=native so profiles reflect host-tuned codegen.
124139
skit-profiling *args='':
125-
@echo "Starting skit with profiling support (release-lto + CPU + heap, frame pointers + native CPU)..."
140+
@echo "Starting skit with release profiling support (release-lto + CPU + heap, frame pointers + native CPU)..."
126141
@echo "Note: Heap profiling configuration is embedded in the binary"
127142
@RUSTFLAGS="-C force-frame-pointers=yes -C target-cpu=native" cargo run --profile release-lto {{moq_features}} {{profiling_features}} -p streamkit-server --bin skit -- {{args}}
128143

@@ -355,17 +370,19 @@ fix-plugins:
355370
@echo "✓ All native plugins fixed"
356371

357372
# --- Profiling ---
358-
# Note: Profiling requires server to be running with --features profiling
359-
# Start server with: just skit-profiling serve
373+
# Two modes: dev (fast iteration) and release (production-accurate).
374+
# Dev: just skit-profiling-dev serve (opt-level 2, no LTO, incremental)
375+
# Release: just skit-profiling serve (release-lto, target-cpu=native)
376+
# Both enable CPU + heap profiling via the same HTTP endpoints below.
360377

361378
# Fetch a CPU profile from running skit server (requires Go with pprof installed)
362379
# Duration in seconds (default: 30), format: flamegraph or protobuf (default: protobuf)
363380
profile-fetch duration='30' format='protobuf' output='profile.pb':
364381
@echo "Fetching {{duration}}s CPU profile in {{format}} format..."
365-
@echo "Note: Server must be running with profiling enabled (just skit-profiling serve)"
382+
@echo "Note: Server must be running with profiling enabled (just skit-profiling-dev serve or just skit-profiling serve)"
366383
@curl -s "http://127.0.0.1:4545/api/v1/profile/cpu?duration_secs={{duration}}&format={{format}}" -o {{output}} || (echo "❌ Failed to fetch profile. Is the server running with profiling enabled?" && exit 1)
367384
@if [ ! -s {{output}} ] || grep -q "501 Not Implemented" {{output}} 2>/dev/null; then \
368-
echo "❌ Profiling not enabled. Start server with: just skit-profiling serve"; \
385+
echo "❌ Profiling not enabled. Start server with: just skit-profiling-dev serve (fast) or just skit-profiling serve (release)"; \
369386
rm -f {{output}}; \
370387
exit 1; \
371388
fi
@@ -395,10 +412,10 @@ profile-top duration='30':
395412
# Fetch a heap profile from running skit server (requires Go with pprof installed)
396413
heap-profile-fetch output='heap.pb.gz':
397414
@echo "Fetching heap profile..."
398-
@echo "Note: Server must be running with profiling enabled (just skit-profiling serve)"
415+
@echo "Note: Server must be running with profiling enabled (just skit-profiling-dev serve or just skit-profiling serve)"
399416
@curl -s "http://127.0.0.1:4545/api/v1/profile/heap" -o {{output}} || (echo "❌ Failed to fetch heap profile. Is the server running with profiling enabled?" && exit 1)
400417
@if [ ! -s {{output}} ] || grep -q "501 Not Implemented" {{output}} 2>/dev/null; then \
401-
echo "❌ Heap profiling not enabled. Start server with: just skit-profiling serve"; \
418+
echo "❌ Heap profiling not enabled. Start server with: just skit-profiling-dev serve (fast) or just skit-profiling serve (release)"; \
402419
rm -f {{output}}; \
403420
exit 1; \
404421
fi

0 commit comments

Comments
 (0)