Improve network usage for small text changes #166
No reviewers
Labels
No labels
bug
dependencies
docker
documentation
duplicate
enhancement
good first issue
help wanted
invalid
javascript
question
rust
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: andras/vault-link#166
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "asch/compact-reconcile"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Only send the changes to the server when the user is typing avoiding sending the entire document on each key stroke.
We only ever know the current state of a document by reading it from disk, so this PR adds a small cache with confirmed document version id - content pairs. When sending requests, it calculates the diff between them first. This results in higher overall CPU usage but a smaller network footprint which tends to be the bottleneck in practice.
Also fix flaky log rotation logic with Claude
It's a bit useless
@ -18,3 +18,3 @@"p-queue": "^8.1.0","reconcile-text": "^0.5.0","reconcile-text": "^0.7.1","uuid": "^13.0.0"Pick up https://github.com/schmelczer/reconcile/pull/21 & https://github.com/schmelczer/reconcile/pull/24
Pull Request Overview
This PR optimizes network usage by sending only text changes (diffs) instead of entire documents when the user is typing. The implementation introduces a client-side cache to track document content by version ID, enabling diff calculation for text documents while maintaining full content transfers for binary files. Additionally, it fixes flaky log rotation logic by properly reusing existing log files when appropriate.
/textand/binaryroutesReviewed Changes
Copilot reviewed 18 out of 20 changed files in this pull request and generated 4 comments.
Show a summary per file
Files not reviewed (1)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@ -297,11 +347,19 @@ export class SyncService {return `${safeRemoteUri}/vaults/${vaultName}${path}`;Setting
Content-Type: multipart/form-datamanually will break multipart requests. The browser/fetch API must set this header automatically to include the correct boundary parameter. Remove this line and let the API set the header whenFormDatais used.@ -0,0 +1,113 @@// Implements an in-memory fixed-size cache for document contents,Filtering the entire usage order array on every
getoperation is O(n). Consider using a doubly-linked list or Map-based approach to track order in O(1) time. With frequent reads, this could become a significant performance bottleneck.Filtering the entire usage order array on every
putoperation when updating existing entries is O(n). This compounds the performance issue noted in thegetmethod. Consider using a doubly-linked list or Map-based approach.@ -0,0 +9,4 @@// human-readable text.return true;}The
containsmethod performs a linear search through the entire byte slice. For large files, this could be inefficient. Consider usingmemchr::memchr(0, data).is_some()which uses SIMD optimizations, or at minimum check only a sample of the data (e.g., first few KB) since NUL bytes in text files typically appear early if present.@ -0,0 +9,4 @@// human-readable text.return true;}Don't want to add another dep