While compiling a Tauri app, a lot of time[^1] is spent compiling the final binary. This also applies for hot/incremental builds using yarn tauri build (including ones with no real changes to the code, like white space changes), with several users reporting compilation times also taking up to several minutes.
When profiling rustc (using RUSTC_BOOTSTRAP=1 cargo rustc -p theseus_gui -- -Z self-profile -Z self-profile-events=default,args), I noticed that most of the compilation time is spend compiling #[tauri::command] macros, in codegen_select_candidate (~52% of compile time). Most of the queries seem related to tauri::InvokeResolver::respond_async_serialized and tokio::runtime::task::harness.
More notably, almost half of the compilation time is spent compiling two small functions in the (barely 19 LOC long!) pack.rs file.
Attached is a Chrome Profiler file, converted from the original ~600MB .mm_profdata file using crox, with the minimum duration of 1ms: chrome_profiler-gui.zip[^2]
[^1]: Up to 10 minutes when compiling the binary itself, with dependencies precompiled to reduce noise.
[^2]: Can recommend ui.perfetto.dev for inspecting the file.
Reproduction
I could use some help isolating the issue to a minimal reproduction example, primarily because I'm not entirely sure what is the real cause of the compilation issues. In the meantime, I invite you to take a look at pack.rs in the Theseus project.
Describe the bug
While compiling a Tauri app, a lot of time[^1] is spent compiling the final binary. This also applies for hot/incremental builds using
yarn tauri build
(including ones with no real changes to the code, like white space changes), with several users reporting compilation times also taking up to several minutes.When profiling rustc (using
RUSTC_BOOTSTRAP=1 cargo rustc -p theseus_gui -- -Z self-profile -Z self-profile-events=default,args
), I noticed that most of the compilation time is spend compiling#[tauri::command]
macros, incodegen_select_candidate
(~52% of compile time). Most of the queries seem related totauri::InvokeResolver::respond_async_serialized
andtokio::runtime::task::harness
.More notably, almost half of the compilation time is spent compiling two small functions in the (barely 19 LOC long!)
pack.rs
file.Attached is a Chrome Profiler file, converted from the original ~600MB .mm_profdata file using crox, with the minimum duration of 1ms: chrome_profiler-gui.zip[^2]
[^1]: Up to 10 minutes when compiling the binary itself, with dependencies precompiled to reduce noise.
[^2]: Can recommend ui.perfetto.dev for inspecting the file.
Reproduction
I could use some help isolating the issue to a minimal reproduction example, primarily because I'm not entirely sure what is the real cause of the compilation issues. In the meantime, I invite you to take a look at pack.rs in the Theseus project.
Expected behavior
No response
Platform and versions
Stack trace
Additional context
See: https://discord.com/channels/616186924390023171/1110350612345917532 (links to Tauri Discord server)
Credits to @Geometrically for the initial investigation.