You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: PERFORMANCE_AUDIT.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,10 +24,10 @@ This document details the performance improvements made in V0.5.0-beta by migrat
24
24
## 3. The Tauri Migration (V0.5.0-beta)
25
25
*Goal: Remove the massive Electron overhead for a background utility.*
26
26
27
-
-**Removed Node.js & Chromium:**Replaced with Rust backend and native OS webview (WebKit on macOS).
28
-
-*Impact:* The `.dmg` size plummeted from ~80MB down to 7.3MB.
29
-
-**Rust Backend:**All IPC calls now run through a highly optimized Rust backend using `std::fs` asynchronously.
30
-
-*Impact:* IPC latency is effectively instantaneous, with lower memory overhead for background processes.
27
+
-**Zero-Copy IPC via `serde`:**Electron relies on JSON stringification over a Node.js bridge. Tauri uses Rust's `serde` library, which serializes and deserializes IPC payloads with near-zero overhead, making data transfer between the UI and backend virtually instantaneous.
28
+
-**Native Async Runtime:** The Rust backend utilizes the `tokio` multi-threaded async runtime. Heavy operations like recursive directory walking (`get_notes`) and HTTP requests (`reqwest` for OpenAI) are executed off the main thread, ensuring the UI never stutters during disk I/O.
29
+
-**Native Security:**Replaced Electron's `safeStorage` with a custom Rust implementation using the `keyring` crate (for OS-level credential storage) and `aes-gcm` (for AES-256-GCM encryption). This provides hardware-backed security with a fraction of the memory footprint.
30
+
-**Strict Capability Scoping:** Migrated to Tauri v2's capability system, ensuring the frontend can only invoke explicitly whitelisted Rust commands and access strictly scoped file paths, eliminating entire classes of XSS-to-filesystem vulnerabilities present in Electron.
31
31
32
32
---
33
33
@@ -65,6 +65,6 @@ This document details the performance improvements made in V0.5.0-beta by migrat
65
65
*Intellectual honesty: Where the app is still not perfectly optimized, and why.*
66
66
67
67
1.**Graph View Rendering:** The D3.js graph view currently recalculates the entire force-directed layout on every node addition. With 1,000+ notes, this causes a 2-second UI freeze.
68
-
-*Mitigation:* We accept this for V0.4.0 as graph view is a secondary feature. V0.5.0 will implement WebGL (via `react-force-graph`) or web workers for layout calculation.
69
-
2.**Regex Parsing on Large Files:** The custom DSL regex runs on the entire document string on every keystroke. For files >50KB, this causes minor input latency.
70
-
-*Mitigation:*CodeMirror's incremental parsing helps, but we may need to move the DSL parser to a Web Worker in the future.
68
+
-*Mitigation:* We accept this for V0.4.0 as graph view is a secondary feature. V0.5.0 will implement WebGL (via `react-force-graph`) to offload layout calculations to the GPU.
69
+
2.**Regex Parsing on Large Files:** The custom DSL regex runs on the entire document string on every keystroke. For files >50KB, this causes minor input latency in the JS main thread.
70
+
-*Mitigation:*In V0.5.0, this parsing can be ported to a `#[tauri::command]` in Rust. Rust's regex engine is highly performant and completely bypasses the JS main thread, eliminating input latency without needing Web Workers.
PaperCache was originally built on Electron. While Electron provides a fantastic, unified cross-platform development environment, it ships an entire Chromium browser and Node.js runtime with every application. For a minimalist, lightweight, global scratchpad that is designed to stay out of the user's way and be invoked instantly via a global hotkey, the overhead was simply too high.
5
+
6
+
-**Resource Heaviness**: Electron apps consume hundreds of megabytes of RAM even when idling in the background. For a background-first application, this was a major flaw.
7
+
-**Binary Size**: Installers were large, routinely exceeding 80MB, just to run a relatively lightweight notepad application.
8
+
-**Security Posture**: Embedding Node.js alongside a Chromium rendering engine requires significant hardening (IPC sandboxing, context isolation) to prevent XSS attacks from becoming arbitrary remote code executions.
9
+
10
+
## The Tauri & Rust Advantage
11
+
Tauri takes a fundamentally different approach. Instead of bundling Chromium and Node.js, Tauri leverages the system's native webview (e.g., WebKit on macOS, WebView2 on Windows) and uses Rust for the backend architecture.
12
+
13
+
### Benefits
14
+
1.**Dramatically Smaller Binaries**: Since we aren't bundling a browser engine, the PaperCache macOS installer shrank from ~80MB down to ~7.3MB (an ~90% reduction).
15
+
2.**Fractional Memory Usage**: PaperCache now uses the OS's shared webview processes, resulting in a >66% reduction in idle RAM usage.
16
+
3.**Lightning Fast Startup**: The compiled native Rust backend and the lack of a bundled Node.js runtime mean the app spawns and responds to global hotkeys almost instantaneously.
17
+
4.**Enhanced Security Posture**: Tauri uses a highly restrictive capabilities system. The frontend only has access to the exact commands we explicitly expose via Rust (e.g., specific file system access or global shortcuts). Rust's strict memory safety rules further eliminate entire classes of backend vulnerabilities.
18
+
5.**Native OS Integrations**: Rust allows us to hook directly into low-level operating system APIs (like `cocoa` on macOS) to handle complex edge cases—such as hiding the dock icon, intercepting sleep/wake events, and injecting custom shadow states—without relying on heavy Node.js bridging.
19
+
20
+
### Potential Cons and Trade-offs
21
+
1.**Webview Inconsistencies**: Because Tauri relies on the OS's native webview (WebKit/Safari on macOS, Edge/WebView2 on Windows, WebKitGTK on Linux), CSS and JavaScript might behave slightly differently depending on the operating system. We lose the "write once, render exactly the same everywhere" guarantee of Electron's bundled Chromium.
22
+
2.**Rust Learning Curve**: Building backend features, managing the system tray state, and handling global shortcuts now require writing Rust code, which has a steeper learning curve and stricter compilation rules than Node.js.
23
+
3.**Ecosystem Maturity**: While growing rapidly, Tauri's plugin ecosystem is not quite as extensive as Electron's decade-old NPM module library. Advanced or niche OS integrations may require writing custom Rust wrappers.
24
+
25
+
## Conclusion
26
+
The migration to Tauri in `v0.5.0-beta` aligns perfectly with PaperCache's core philosophy: to be a lightning-fast, secure, and native-feeling utility. The incredible performance and resource gains vastly outweigh the minor webview fragmentation, solidifying Tauri as the optimal choice for the future of the application.
Copy file name to clipboardExpand all lines: features.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ This document outlines every feature available in the PaperCache codebase, organ
11
11
-**Date & Time Formats**: Highlights standard date (`DD-MM-YYYY` or `YYYY-MM-DD`) and time (`HH:MM` or `HH:MM:SS`) formats into clean, distinct pills.
12
12
-**Interactive Checkboxes**: Type `/check` to create an interactive checkbox widget. Clicking it changes it to `/checked` and visually strikes through the text on that line!
13
13
-**Tasks & Reminders**: Type `/task` to create a task widget. Add a space followed by `@` and a time (like `1d2h`, `tmrw`, or a specific date `YYYY-MM-DD HH:MM`) to set a due date. Press `Cmd+T` (or `Ctrl+T`) to open the Tasks Page, which tracks all tasks, calculates due times, and highlights overdue tasks in red.
14
-
-**Customizable Theming & Fonts**: Customize fonts, text colors, background colors, background images, and individual highlight colors for variables, AI, and math. Supports full dark mode (`grid-dark`, `blueprint`) and custom zoom scaling.
14
+
-**Customizable Theming & Fonts**: Customize fonts, text colors, background colors, background images, and individual highlight colors for variables, AI, and math. Supports full dark mode (`grid-dark`, `blueprint`).
0 commit comments