Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

speed up cold debug builds (#5267)

Ezra Elletteadf2266c42be
diff --git a/.cargo/config.toml b/.cargo/config.toml
index 1addc1e12..c1503cdb3 100644
--- a/.cargo/config.toml
+++ b/.cargo/config.toml
@@ -19,6 +19,7 @@ rustflags = "-lc++ -l framework=Accelerate"
AWS_LC_SYS_PREBUILT_NASM = "1"
CMAKE_POLICY_VERSION_MINIMUM = "3.5"
-# Faster builds - use more threads for codegen
-[build]
-jobs = 16 # Parallel compilation jobs (adjust to your CPU cores)
+# Cargo already uses the machine's available parallelism. A fixed value made
+# 10-core developer machines run 16 compiler processes at once, increasing
+# memory pressure and making cold builds slower. Keep this adaptive so
+# concurrent worktrees also divide the machine's resources more gracefully.
diff --git a/apps/screenpipe-app-tauri/scripts/build-frontend.js b/apps/screenpipe-app-tauri/scripts/build-frontend.js
index c6c9e2b28..a43074454 100644
--- a/apps/screenpipe-app-tauri/scripts/build-frontend.js
+++ b/apps/screenpipe-app-tauri/scripts/build-frontend.js
@@ -9,8 +9,9 @@
// of a rebuild.
//
// How it works:
-// 1. Hash the frontend inputs — every file in the app package EXCEPT known
-// build outputs / heavy artifacts (node_modules, .next, out, .git, ...).
+// 1. Hash the frontend inputs — every file in the app package EXCEPT the
+// native src-tauri tree and known build outputs / heavy artifacts
+// (node_modules, .next, out, .git, ...).
// This is an exclude-list, never an include-list: any new source file or
// dir is hashed automatically, so we can never silently miss an input and
// ship a stale UI. Over-inclusion only ever costs a redundant rebuild.
@@ -47,11 +48,13 @@ const cacheRoot =
// Keep at most this many cached builds; least-recently-used are pruned.
const MAX_CACHE_ENTRIES = 8
-// Directory/file names that are build outputs or heavy, churny, non-input
-// artifacts. Excluding them keeps the hash stable and the walk fast. Missing
-// one here only ever causes a redundant rebuild — never a stale build.
+// Directory/file names that cannot affect the Next.js static export, or that
+// are build outputs/heavy artifacts. The native src-tauri tree is compiled and
+// bundled by Cargo/Tauri after this script; none of it is consumed by Next.js.
+// Excluding it prevents every Rust edit and generated schema update from
+// pointlessly rebuilding an identical frontend.
const SKIP_DIRS = new Set([
- 'node_modules', '.next', 'out', 'target', '.git', '.turbo', '.vercel',
+ 'src-tauri', 'node_modules', '.next', 'out', 'target', '.git', '.turbo', '.vercel',
'coverage', '.e2e-data', '.e2e', 'videos', 'screenshots', 'results',
])
const SKIP_FILES = new Set(['.DS_Store', 'tsconfig.tsbuildinfo'])
diff --git a/apps/screenpipe-app-tauri/scripts/build-frontend.test.js b/apps/screenpipe-app-tauri/scripts/build-frontend.test.js
index 1b75c50ba..e52831d01 100644
--- a/apps/screenpipe-app-tauri/scripts/build-frontend.test.js
+++ b/apps/screenpipe-app-tauri/scripts/build-frontend.test.js
@@ -9,7 +9,7 @@ import path from 'path'
import { computeInputHash } from './build-frontend.js'
-test('Cargo target artifacts do not invalidate the frontend input hash', async () => {
+test('native backend changes do not invalidate the frontend input hash', async () => {
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'screenpipe-frontend-hash-'))
try {
await fs.mkdir(path.join(root, 'app'), { recursive: true })
@@ -17,6 +17,10 @@ test('Cargo target artifacts do not invalidate the frontend input hash', async (
const initial = await computeInputHash(root)
+ await fs.mkdir(path.join(root, 'src-tauri'), { recursive: true })
+ await fs.writeFile(path.join(root, 'src-tauri', 'Cargo.toml'), '[package]\nname = "native"\n')
+ expect(await computeInputHash(root)).toBe(initial)
+
const cargoTarget = path.join(root, 'src-tauri', 'target', 'debug')
await fs.mkdir(cargoTarget, { recursive: true })
await fs.writeFile(path.join(cargoTarget, 'screenpipe-app.exe'), 'first build')
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
index 291470ada..8432d4cb4 100644
--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
@@ -346,6 +346,18 @@ debug = false
# Faster dev builds
[profile.dev]
opt-level = 0
+debug = false
+# Per-worktree incremental state cannot help a cold target and prevents the
+# shared compiler cache from reusing screenpipe's path crates across worktrees.
+incremental = false
[profile.dev.package."*"]
opt-level = 2
+debug = false
+
+# Proc macros and build scripts do not ship in the application. Compiling them
+# with the dependency-wide opt-level=2 only slows the build and cannot improve
+# app runtime performance.
+[profile.dev.build-override]
+opt-level = 0
+debug = false