Skip to content

[SLOP(claude-opus-4-8-medium)] chore: add profiling cargo profile for heaptrack leak investigation#5314

Open
MasterPtato wants to merge 2 commits into
stack/slop-claude-opus-4-8-fix-kitchen-sink-serve-built-frontend-from-server-rymmurrkfrom
stack/slop-claude-opus-4-8-medium-chore-add-profiling-cargo-profile-for-heaptrack-leak-investigation-xsoysnqs
Open

[SLOP(claude-opus-4-8-medium)] chore: add profiling cargo profile for heaptrack leak investigation#5314
MasterPtato wants to merge 2 commits into
stack/slop-claude-opus-4-8-fix-kitchen-sink-serve-built-frontend-from-server-rymmurrkfrom
stack/slop-claude-opus-4-8-medium-chore-add-profiling-cargo-profile-for-heaptrack-leak-investigation-xsoysnqs

Conversation

@MasterPtato

@MasterPtato MasterPtato commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@MasterPtato

MasterPtato commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Stack for rivet-dev/rivet

Get stack: forklift get 5314
Push local edits: forklift submit
Merge when ready: forklift merge 5314

@claude

claude Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

This PR does two things: adds a `[profile.profiling]` Cargo profile for heaptrack-based leak investigation, and refactors `run_event_loop` in `napi_actor_events.rs` to interleave `JoinSet` reaping with event dispatch so completed background tasks don't accumulate RSS over an actor's lifetime. The change is small and well-motivated. Four issues worth addressing:


`drain_tasks` inconsistency with cancelled-task error suppression
rivetkit-typescript/packages/rivetkit-napi/src/napi_actor_events.rs:195 — The new run_event_loop join arm correctly suppresses cancelled-task errors (if !error.is_cancelled()), but drain_tasks at ~line 854 still error-logs all join failures including cancellations. Tasks cancelled via abort.cancel() before the event loop exits will be silently passed in the loop drain, then if somehow reaped in drain_tasks they'd spuriously error-log. At minimum the two paths should be consistent — drain_tasks should also apply !error.is_cancelled() to match.


Profiling profile comment overstates inlining suppression
Cargo.toml:660 — The comment says "keep frames un-inlined," but opt-level = 3 is inherited from release and not overridden. codegen-units = 16 + lto = "thin" suppresses cross-codegenunit inlining, but opt-level = 3 still aggressively inlines within each codegen unit. For heaptrack allocation backtraces, intra-crate allocation sites inside hot functions will still collapse into their callers. If the goal is fully un-inlined frames, add opt-level = 1. If opt-level = 3 is intentional (to keep runtime performance representative), the comment should say "limits cross-crate inlining" rather than implying frames are generally un-inlined.


select! without biased — probabilistic event delay under task burst
rivetkit-typescript/packages/rivetkit-napi/src/napi_actor_events.rs:187 — When many background tasks complete simultaneously, select! randomly picks between join_next and events.recv() each iteration, so N completed tasks in the backlog means event processing waits an expected O(N) extra iterations before the action queue drains. This is bounded and exponentially unlikely to cause real starvation, but adding biased; to the select! (placing events.recv() first) would guarantee event processing is never delayed by a task-reap backlog and more closely matches the original code's event-priority semantics.


Missing actor_id on the new join-failure error log
rivetkit-typescript/packages/rivetkit-napi/src/napi_actor_events.rs:195run_event_loop receives ctx: &ActorContext which exposes actor_id. The existing error logs throughout this file include it as a structured field, but the new log does not: tracing::error!(?error, "napi background task failed to join"). Should be tracing::error!(?error, actor_id = %ctx.inner().actor_id(), "napi background task failed to join") (or however actor_id is accessed on ctx) so join failures are attributable in production.

@railway-app

railway-app Bot commented Jun 22, 2026

Copy link
Copy Markdown

🚅 Deployed to the rivet-pr-5314 environment in rivet-frontend

Service Status Web Updated (UTC)
frontend-cloud 😴 Sleeping (View Logs) Web Jun 24, 2026 at 1:09 pm
website 😴 Sleeping (View Logs) Web Jun 24, 2026 at 5:09 am
kitchen-sink 😴 Sleeping (View Logs) Web Jun 23, 2026 at 8:38 pm
frontend-inspector 😴 Sleeping (View Logs) Web Jun 23, 2026 at 8:32 pm
ladle ✅ Success (View Logs) Web Jun 22, 2026 at 10:43 pm
mcp-hub ✅ Success (View Logs) Web Jun 22, 2026 at 10:42 pm

@MasterPtato MasterPtato force-pushed the stack/slop-claude-opus-4-8-fix-kitchen-sink-serve-built-frontend-from-server-rymmurrk branch from 051f338 to 6efb5f5 Compare June 23, 2026 20:22
@MasterPtato MasterPtato force-pushed the stack/slop-claude-opus-4-8-medium-chore-add-profiling-cargo-profile-for-heaptrack-leak-investigation-xsoysnqs branch from 4128684 to 5e48af6 Compare June 23, 2026 20:23
…ks from event-loop JoinSet (#5315)

* [SLOP(claude-opus-4-8)] fix(kitchen-sink): serve built frontend from server

* [SLOP(claude-opus-4-8-medium)] chore: add profiling cargo profile for heaptrack leak investigation

* [SLOP(claude-opus-4-8-medium)] fix(rivetkit-napi): reap completed tasks from event-loop JoinSet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant