Sign in

Improving performance with Rust

In this post I would like to share how Rust language helped a lot to improve my note taking application’s performance.

GigaNotes is an open source a cross platform note taking application. It is written using Angular framework and was previously relying on some Electron / Cordova bindings for SQLITE, depending on the operating system it was build for.

It has a desktop version for Windows / Linux:

Giganotes Desktop

And a mobile version for Android devices:

As the whole application code was written in Javascript, it had a lot of annoying performance issues because of single-threaded nature of Javascript engines. This was especially noticeable during the execution of heavy operations like synchronization of large set of notes. The recent technologies aiming to help developing multi-threaded JavaScript applications have been introduced recently, but still have a lot of limitations. Besides, the overall javascript performance is not goog enough for writing application’s core. However, JavaScript is still pretty good for writing user interfaces of cross-platform applications, so I didn’t consider to fully abandon it. As it said, each tool is good for its own purposes.

After researching a lot of options how to get the optimal performance combined to maximum code re-usability and cross-platform compilation. I found Rust as the best option to implement application’s core. Except for the perfect package management tool, Rust has all the necessary bindings — Neon for Electron, Rust code easily compiles for Android. So it was relatively easy to implement the communication layer between Rust native code and those platforms like Node.Js (Electron) and Android.

After the transition was done, application architecture started to look like below:

It also allowed me to add new key features like full text search. It was much harder to implement it in Javascript. Thankfully, Rust has a great crate for full text search called tantivy.

Thanks to Rust, Giganotes application now has a fully multi-threaded core and works much faster than before.