chore: add startup timing diagnostics for #270
Add [STARTUP] timing logs to Rust setup (plugin registration, storage open, migration) and Vue frontend (onMounted, initFromStorage, initFromDisk) to help diagnose slow startup reported in #270.
This commit is contained in:
parent
c37caeba78
commit
ecb878315c
|
|
@ -12,6 +12,8 @@ use tauri::{Manager, RunEvent};
|
|||
pub fn run() {
|
||||
rustls::crypto::aws_lc_rs::default_provider().install_default().expect("Failed to install rustls crypto provider");
|
||||
|
||||
let startup_begin = Instant::now();
|
||||
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.plugin(tauri_plugin_fs::init())
|
||||
|
|
@ -19,7 +21,10 @@ pub fn run() {
|
|||
.plugin(tauri_plugin_updater::Builder::new().build())
|
||||
.plugin(tauri_plugin_process::init())
|
||||
.plugin(tauri_plugin_window_state::Builder::default().build())
|
||||
.setup(|app| {
|
||||
.setup(move |app| {
|
||||
let setup_start = Instant::now();
|
||||
eprintln!("[STARTUP] plugins registered in {:?}", startup_begin.elapsed());
|
||||
|
||||
if cfg!(debug_assertions) {
|
||||
app.handle().plugin(tauri_plugin_log::Builder::default().level(log::LevelFilter::Info).build())?;
|
||||
}
|
||||
|
|
@ -29,17 +34,23 @@ pub fn run() {
|
|||
std::fs::create_dir_all(&data_dir).expect("Failed to create data dir");
|
||||
let db_path = data_dir.join("dbx.db");
|
||||
|
||||
let t = Instant::now();
|
||||
let storage = tauri::async_runtime::block_on(async {
|
||||
let s = Storage::open(&db_path).await.expect("Failed to open storage");
|
||||
eprintln!("[STARTUP] Storage::open in {:?}", t.elapsed());
|
||||
let t2 = Instant::now();
|
||||
s.migrate_from_json(&data_dir).await.expect("Failed to migrate JSON data");
|
||||
eprintln!("[STARTUP] migrate_from_json in {:?}", t2.elapsed());
|
||||
s
|
||||
});
|
||||
eprintln!("[STARTUP] storage ready in {:?}", t.elapsed());
|
||||
|
||||
let state = Arc::new(AppState::new_with_plugin_dir(storage, data_dir.join("plugins")));
|
||||
app.manage(state.clone());
|
||||
|
||||
let app_handle = app.handle().clone();
|
||||
commands::mcp_bridge::start(app_handle, state);
|
||||
eprintln!("[STARTUP] setup complete in {:?} (total {:?})", setup_start.elapsed(), startup_begin.elapsed());
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
{
|
||||
|
|
|
|||
11
src/App.vue
11
src/App.vue
|
|
@ -466,10 +466,16 @@ function onLoginSuccess() {
|
|||
}
|
||||
|
||||
function initApp() {
|
||||
const t0 = performance.now();
|
||||
console.log("[STARTUP] initApp begin");
|
||||
savedSqlStore
|
||||
.initFromStorage()
|
||||
.then(() => connectionStore.initFromDisk())
|
||||
.then(() => {
|
||||
console.log(`[STARTUP] savedSqlStore.initFromStorage: ${(performance.now() - t0).toFixed(0)}ms`);
|
||||
return connectionStore.initFromDisk();
|
||||
})
|
||||
.then(() => {
|
||||
console.log(`[STARTUP] connectionStore.initFromDisk: ${(performance.now() - t0).toFixed(0)}ms`);
|
||||
reconnectRestoredTabs();
|
||||
})
|
||||
.catch((e: any) => {
|
||||
|
|
@ -501,6 +507,8 @@ function handleContextMenu(e: MouseEvent) {
|
|||
}
|
||||
|
||||
onMounted(async () => {
|
||||
console.log("[STARTUP] onMounted begin");
|
||||
const mountStart = performance.now();
|
||||
applyTheme();
|
||||
window.addEventListener("keydown", handleKeydown, true);
|
||||
if (isDesktop) {
|
||||
|
|
@ -541,6 +549,7 @@ onMounted(async () => {
|
|||
})
|
||||
.catch(() => {});
|
||||
setupTauriListeners();
|
||||
console.log(`[STARTUP] onMounted sync done: ${(performance.now() - mountStart).toFixed(0)}ms`);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue