Lurker News
A year ago, my co-founder launched Desktop Docs here on HN. It's a Mac app we built with Electron that uses CLIP embeddings to search photos and videos locally with natural language. We got positive feedback from HN and our first paying customers, but the app was almost 1GB and clunky to use.

TLDR; rebuilding in Rust was the right move.
So we rewrote the app with Rust and Tauri and here are the results:
- App size is 83% smaller: 1GB → 172MB - DMG Installer is 70% smaller: 232MB → 69.5MB - Indexing files is faster: A 38-minute video now indexes in ~3 minutes instead of 10-14 minutes - Overall more stability (old app used to randomly crash)
The original version worked, but it didn't perform well when you tried indexing thousands of images or large videos. We lost a lot of time struggling to optimize Electron’s main-renderer process communication and ended up with a complex worker system to process large batches of media files.
For months we wrestled with indecision about continuing to optimize the Electron app vs. starting a full rebuild in Swift or Rust. The main thing holding us back was that we hadn’t coded in Swift in almost 10 years and we didn’t know Rust very well.
What finally broke us was when users complained the app crashed their video calls just running in background. I guess that’s what happens when you ship an app with Chromium that takes up 200mb before any application code.
Today the app still uses CLIP for embeddings and Redis for vector storage and search, except Rust now handles the image and video processing pipeline and all the file I/O to let users browse their entire machine, not just indexed files.
For the UI, we decided to rebuild it from scratch instead of porting over the old UI. This turned out well because it resulted in a cleaner, simpler UI after living with the complexity of the old version.
The trickiest part of the migration was learning Rust. LLMs definitely help, but the Rust/Tauri community just isn’t as mature compared to Electron. Bundling Redis into the app was a permissioning nightmare, but I think our solution with Rust handles this better than what we had with Electron.
All in, the rebuild took about two months and still needs some more work to be at total parity with its Electron version, but the core functionality of indexing and searching files is way more performant than before and that made it worth the time. Sometimes you gotta throw away working code to build the right thing.
AMA about Rust/Tauri migration, Redis bundling nightmares, how CLIP embeddings work for local semantic search, or why Electron isn't always the answer.

Comments (443) 84 threads

Earlier comments
terhechte2 replies#
Why did you bundle Redis and not use one of the many key value libraries available for Rust (or even sqlite)?
correa_brian2 replies#
For vector search we couldn't get my results to return meaningful entries. My preference would have been to use sqlite. Any others you recommend besides sqlite with the vss extension?
tayo42#
How are you searching with redis?

Aren't vector searches usuaully just like nearest values with some distance calculation? Are they not all implemented the same way?

terhechte#
You could split it up in two separate entities. For vector search there's a myriad of good Rust projects. I've personally used:

- https://crates.io/crates/lancedb - https://crates.io/crates/usearch - https://crates.io/crates/simsimd
search and simsimd are fast and lightweight, but I'd advise to use lancedb if you're a bit new to Rust as the other two are a bit trickier to handle due to the C dependency (e.g. usearch needs Vec::with_capacity and will otherwise crash, etc).
And then, you take the result of this query and can combine it with a sqlite `in` query.
Or you use SQLite with a vector search extension: https://crates.io/crates/rig-sqlite

turnsout1 reply#
Came here to post this. So curious about the choice to NOT use sqlite.
correa_brian1 reply#
Would have loved to use sqlite if I could get good results. Maybe I botched the implementation.
alexgarcia-xyz2 replies#
Creator of sqlite-vec here, happy to help debug anything if you do attempt to try out SQLite vector search again.

You mentioned "VSS" in another comment, which if that was my sqlite-vss extension, I more-or-less abandoned that extension for sqlite-vec last year. The VSS extension was more unstable and bloated (based on Faiss), but the new VEC extension is much more lightweight and easy to use (custom C vector functions). The new metadata column support is also pretty nice, and can be used for push-down filtering.
That being said, sqlite-vec still doesn't have ANN yet (but can brute-force ~10k's-100k of vectors quick enough), and I've fallen behind on updates and new releases. Hoping to push out a desperately-needed update this week
link: https://alexgarcia.xyz/sqlite-vec/
And there are a few other SQLite-based vector search extensions/tools out there, so the ecosystem is general might be worth another look.

Continue this thread — 2 replies

inlinestyle_it#
Long time ago we worked on a similar concept. A framework to build native applications via plain HTML/Javascript files with support for invoking native code: https://axemas.readthedocs.io/en/latest/

At the time the native part was the reason why the project never caught up, people preferred pure JS solutions even though they were much more limited and worse performing. Do you think that Tauri will actually be able to catch up even though it requires Rust knowledge which is far from being an easy language?

Abishek_Muthian#
Congratulations on the rewrite and launch!

1. Did you consider WAILS(Go)?
2. Did you consider ColPali ?
3. Are you planning to launch for other platforms (Linux/Windows) if so how are planning to achieve self-updates & signing the binary to prevent false detections from AV.
Thank you.

porphyra2 replies#
How do you run CLIP in Rust? I'm still not sure what the best inference stack on Rust is --- I tried onnxruntime bindings in Rust a few years ago and it was rather finicky to work with.
correa_brian2 replies#
We're using the onnxruntime bindgs with the Ort crate. Our biggest challenge was just bundling the onnxruntime into the app and making sure everything was signed, etc.
arresin1 reply#
Tauri, from my experience, can be extremely frustrating.
correa_brian#
Yeah there are definitely hang ups along the way. It's a big of wack-a-model but thankfully we've had an easier time developing with Rust than on Electron.
correa_brian#
Nice. I'll try to test these out against our current implementation.
diggan2 replies#
> I'm still not sure what the best inference stack on Rust is

I was just looking into this today!
The options I've found, but yet to evaluate:
- TorchScript + tch = Use `torch.jit.trace` to create a traced model, load with tch/rust-tokenizers
- rust-bert + tch = Seems to provide slightly higher-level usage, also use traced model
- ONNX Runtime - Convert (via transformers.onnx) .pt model to .onnx encoder and decoder, then use onnxruntime+ndarray for inference
- Candle crate - Seems to have the smallest API for basic inference, and AFAIK can load up models saved with model.save() without conversion or other things
These are the different approaches I've found so far, but probably missed a bunch. All of them seem OK, but on different abstraction-levels obviously, so depends on what you want ultimately. If anyone know any other approach, would be more than happy to hear about it!

jokethrowaway#
There's also the burn framework but there are a lot of tradeoffs to consider. It's neat for wgpu targets (including web) but you'll need to implement a lot of stuff.

Candle is a great choice overall (and there are plenty of examples) but performance is slightly worse compared to tch.
Personally, if I can get it done with candle that's what I do. It's also pretty neat for serverless.
If I can't, I check if I can convert it to onnx without extra work (or if there is an onnx available).
As a last resort, I think about shipping torchlib via tch.

correa_brian#
Great resources, thanks. I'll look into the other packages and compare against our onnx runtime setup.

Load more comments