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)
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 😃
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.
We are running some more in-depth tests on this, but initial findings show that:
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: