diff --git a/navi/api/routes/sessions.py b/navi/api/routes/sessions.py index 9b9dff6..84c9f0e 100644 --- a/navi/api/routes/sessions.py +++ b/navi/api/routes/sessions.py @@ -594,6 +594,9 @@ store: Annotated[SessionStore, Depends(get_session_store)], user: Annotated[User, Depends(require_user)], ) -> None: + import time as _time + + _t0 = _time.perf_counter() session = await store.get(session_id) if session is None: raise HTTPException(status_code=404, detail="Session not found") @@ -610,16 +613,29 @@ # store (suppress_note = True, set inside cancel_session_jobs). from navi.core.tasks import get_task_manager from navi.core.task_notes import clear as clear_task_notes + _t_get = _time.perf_counter() get_task_manager().cancel_session_jobs(session_id) # Pending notes from earlier completed jobs would never drain — the # session is going away. await clear_task_notes(session_id) + _t_tasks = _time.perf_counter() deleted = await store.delete(session_id) + _t_db = _time.perf_counter() if not deleted: raise HTTPException(status_code=404, detail="Session not found") # Remove session file directory if it exists await delete_session_dir(session_id) + _t_dir = _time.perf_counter() + log.info( + "sessions.delete_timing", + session_id=session_id, + lookup_terminals_ms=round((_t_get - _t0) * 1000, 1), + tasks_notes_ms=round((_t_tasks - _t_get) * 1000, 1), + db_delete_ms=round((_t_db - _t_tasks) * 1000, 1), + files_dir_ms=round((_t_dir - _t_db) * 1000, 1), + total_ms=round((_t_dir - _t0) * 1000, 1), + ) @router.get("/{session_id}/messages/archive")