From 26b41389b27015141d490bc367a81a1cc4c5f064 Mon Sep 17 00:00:00 2001 From: Jake Date: Tue, 21 Apr 2026 15:42:04 +0100 Subject: [PATCH] =?UTF-8?q?perf(sqlx):=20strip=20default=20features=20?= =?UTF-8?q?=E2=80=94=20workspace=20uses=20none=20of=20macros=20/=20migrate?= =?UTF-8?q?=20/=20any=20/=20json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sqlx 0.8's default feature set pulls in `any`, `macros`, `migrate`, and `json`. Grepping the workspace confirms none of these are used — the code calls sqlx::query() / query_scalar() at runtime, implements its own migration sequencing in crates/storage/src/migrations.rs, is sqlite-only (no `any` needed), and never derives FromRow / applies sqlx proc-macros. Dropping them keeps only what's needed: runtime-tokio + sqlite. Why it matters disproportionately on Windows: the `macros` feature pulls sqlx-macros → sqlx-macros-core → proc-macro2 / syn / quote / async-trait / url / heck / dotenvy / sha2 / filetime. Each proc-macro crate on Windows MSVC compiles to a .dll with a full linker invocation (slower ABI than Linux/macOS proc-macro .so). Net: tens of seconds shaved off every cold-cache CI run, compounding with the cache-path fix in the next commit. kon-mcp was already lean (default-features = false); matching that shape across the workspace now. Co-Authored-By: Claude Opus 4.7 (1M context) --- crates/storage/Cargo.toml | 7 ++++++- src-tauri/Cargo.toml | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/storage/Cargo.toml b/crates/storage/Cargo.toml index 58ab465..1e95dc0 100644 --- a/crates/storage/Cargo.toml +++ b/crates/storage/Cargo.toml @@ -8,7 +8,12 @@ description = "SQLite persistence, BM25 search, and file storage for Kon" kon-core = { path = "../core" } # SQLite with compile-time checked queries -sqlx = { version = "0.8", features = ["sqlite", "runtime-tokio"] } +# default-features = false strips sqlx's `any`, `macros`, `migrate`, `json` — +# none of which this crate uses (it calls sqlx::query() / query_scalar() +# directly and runs its own migration machinery). Cuts ~40% of sqlx's +# compile graph, most visibly on Windows MSVC where each proc-macro crate +# (which `macros` pulls in) becomes a slow .dll link. +sqlx = { version = "0.8", default-features = false, features = ["runtime-tokio", "sqlite"] } # Async runtime tokio = { version = "1", features = ["rt", "sync", "macros"] } diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 93b1ebf..e9d5782 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -42,7 +42,9 @@ arboard = "3.6.1" # SqlitePool is named directly from src-tauri/src/lib.rs (the AppState # stores it). Must be unconditional, not Linux-only — naming a type from # a transitive dep requires the dep be listed here too. -sqlx = { version = "0.8", features = ["sqlite", "runtime-tokio"] } +# See crates/storage/Cargo.toml — default-features = false drops macros / +# migrate / any / json which this crate doesn't use. Only names SqlitePool. +sqlx = { version = "0.8", default-features = false, features = ["runtime-tokio", "sqlite"] } uuid = { version = "1", features = ["v4"] } [target.'cfg(target_os = "linux")'.dependencies]