Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,16 @@ lto = "fat"
codegen-units = 1
opt-level = 3

# Release-grade optimization with DWARF line info and no symbol stripping so
# heaptrack can resolve native allocation backtraces during leak investigation.
# Uses thin LTO and more codegen units to keep frames un-inlined and builds fast.
[profile.profiling]
inherits = "release"
debug = 1
lto = "thin"
codegen-units = 16
strip = false

[profile.quick]
inherits = "dev"
debug = false # no debug info → faster link, smaller binary
Expand Down
47 changes: 33 additions & 14 deletions rivetkit-typescript/packages/rivetkit-napi/src/napi_actor_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,21 +181,40 @@ async fn run_event_loop(
dirty: &Arc<AtomicBool>,
events: &mut ActorEvents,
) {
while let Some(event) = events.recv().await {
loop {
pump_registered_tasks(tasks, registered_task_rx);
dispatch_event(
event,
bindings,
config,
ctx,
abort,
tasks,
registered_task_rx,
dirty,
)
.await;
if ctx.has_end_reason() {
break;

tokio::select! {
// Reap completed background tasks as they finish. A tokio JoinSet
// retains each finished task's allocation until it is joined, so
// without this the set grows for the entire actor lifetime and
// shows up as native (non-V8) RSS growth.
Some(result) = tasks.join_next(), if !tasks.is_empty() => {
if let Err(error) = result {
if !error.is_cancelled() {
tracing::error!(?error, "napi background task failed to join");
}
}
}
event = events.recv() => {
let Some(event) = event else {
break;
};
dispatch_event(
event,
bindings,
config,
ctx,
abort,
tasks,
registered_task_rx,
dirty,
)
.await;
if ctx.has_end_reason() {
break;
}
}
}
}
}
Expand Down
Loading