tauri: Memory benchmark might be incorrect: Tauri might consume more RAM than Electron

Hey there! I’m researching the use of native web views in comparison Chromium (with Electron) and faced some unexpected results in terms of memory usage. The current memory benchmark (https://tauri.app/v1/references/benchmarks/) finds Electron to have a ~500 MB memory usage on Linux, being 2x from the one from Tauri.

The problem might be related to failing to account for shared memory, given that Chromium uses the same executable for multiple of its processes, with a significant part of them being read-only and thus actually shared. If we take these into account, the results are very different:

postman.com macOS 12.6.1 Ubuntu 22.04.1 Windows 10
Tauri 421 MB 581 MB 399 MB
Safari 471 MB ❌ ❌
Electron 337 MB 240 MB 318 MB
Chrome 381 MB 370 MB <not done>
vscode.dev macOS 12.6.1 Ubuntu 22.04.1 Windows 10
Tauri 429 MB 572 MB 370 MB
Electron 332 MB 222 MB 312 MB

It appears the WebKit webview uses more memory for Web apps. The difference in memory usage was >90 MB and was present across multiple platforms, architectures, and multiple different uses of the webview (Tauri and Safari). These results are potentially surprising due to the popular notion that Electron is memory-hungry. Tauri using Edge WebView 2 had similar memory usage with Electron, which makes sense given both are based on Chromium.

While the base memory of i.e. Tauri and Sockets seem lower on macOS and Linux, they seem to increase very rapidly given actual real-world usage compared to i.e. Electron.

The tool that Tauri is using to do their memory benchmark, mprof, actually supports multiple backends for running. The default is just psutil, but they also have psutil_pss and psutil_uss.

We tested the default apps for Electron and Tauri, measuring USS and PSS, on Ubuntu and got these results

USS PSS
Electron 118 MB 207 MB
Tauri 125 MB 185 MB

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 14
  • Comments: 15 (5 by maintainers)

Most upvoted comments

Apart from memory usage, we are interested in benchmarking native web views vs Chromium/Electron in terms of batter usage, CPU consumption, etc. Any findings you have would be hugely appreciated 😃

you’re basically benchmarking Webkit against Chromium.

Exactly, this is the point. We are trying to understand the underlying differences between WebKit and Chromium as the foundation for building apps on top. Complex applications make heavy use of web technologies, React, etc and then branch out to native functionality as required, so the web side of things tends to dominate.

Testing the amount of sharing between apps. Basically see how the memory consumption grows as you open more instances of the same app. Does it grow linearly or not? What’s the growth factor?

We are running some more in-depth tests on this, but initial findings show that:

  • Any application making use of native web views of course reaps the benefits
  • Sharing happens on Electron when multiple applications use the exact same Electron version (which comes back to the initial shared memory observation)

Okay so given the specific workload you tested with the results make sense.

Since you’re not using any native functionality (which uses nodejs with electron and rust with Tauri) you’re basically benchmarking Webkit against Chromium.

So for this benchmark it means since Tauri uses webkit on macOS you would expect it’s memory consumption to be equal to Safari, same for chrome on windows. That there is a memory consumption difference between webkit and chromium doesn’t surprise much.

I would be interested to see us investigate the following things:

  1. Benchmarks using native code. This is where I would predict the biggest difference, since Tauri uses Rust for this. But it would be interesting to see exact numbers.
  2. Testing the amount of sharing between apps. Basically see how the memory consumption grows as you open more instances of the same app. Does it grow linearly or not? What’s the growth factor?
  3. Benchmark against more frameworks. While this issue got started with a comparison to electron it would be interesting to know how we compare to other frameworks like Wails, Flutter, etc.