Skip to content

Conversation

@Tunglies
Copy link
Contributor

Introducing Dashmap dependency. Test with example, trigge the spawn button on UI.

Some testing usage:

let start_insert_time = std::time::Instant::now();
            webview
              .state::<ChannelDataIpcQueue>()
              .0
              .lock()
              .unwrap()
              .insert(data_id, body);
            let elapsed_insert = start_insert_time.elapsed();
              println!(
                "[tauri::ipc::channel] inserted channel data id {data_id} in {:?}",
                elapsed_insert
              );
// The repo's example cmd.rs
#[command]
pub fn spam(channel: Channel<Vec<u8>>) -> tauri::Result<()> {
  // make greater than MAX_RAW_DIRECT_EXECUTE_THRESHOLD(1024)
  let size = 50_000usize;
  let data = vec![0u8; size];
  channel.send(data)?;
  Ok(())
}

Previous Arc<Mutex>

[tauri::ipc::channel] inserted channel data id 0 in 34.334µs

Current Dashmap

[tauri::ipc::channel] inserted channel data id 0 in 15.958µs

Roughly improved 53% cost time.

@Tunglies Tunglies requested a review from a team as a code owner December 17, 2025 10:25
@github-project-automation github-project-automation bot moved this to 📬Proposal in Roadmap Dec 17, 2025
@github-actions
Copy link
Contributor

Package Changes Through 9989d28

There are 4 changes which include tauri-utils with patch, tauri-build with patch, tauri-cli with patch, tauri with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
tauri-utils 2.8.1 2.8.2
tauri-bundler 2.7.5 2.7.6
tauri-runtime 2.9.2 2.9.3
tauri-runtime-wry 2.9.3 2.9.4
tauri-codegen 2.5.2 2.5.3
tauri-macros 2.5.2 2.5.3
tauri-plugin 2.5.2 2.5.3
tauri-build 2.5.3 2.5.4
tauri 2.9.5 2.9.6
@tauri-apps/cli 2.9.6 2.9.7
tauri-cli 2.9.6 2.9.7

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@Tunglies Tunglies force-pushed the perf/ChannelDataIpcQueue branch from 92f1105 to f51fc36 Compare December 17, 2025 11:07
@sftse
Copy link
Contributor

sftse commented Dec 17, 2025

Is there a more macroscopic example how this benefits performance? I'm in favor but for other reasons, already a transitive dependency and gets rid of unwraps for data structures that don't benefit from poisoning.

@Legend-Master
Copy link
Contributor

I am not sure how much this would benefit performance to be honest, with the test code you provided, my results are like this in release build (size optimized not speed)

[tauri::ipc::channel] inserted channel data id 0 in 1.1µs
[tauri::ipc::channel] inserted channel data id 1 in 700ns

And the whole fetch process takes milliseconds, I'm not sure if it makes sense to bring in a new dependency just for this

already a transitive dependency

This is in the tauri-cli's dependency tree, but in not tauri's

@sftse
Copy link
Contributor

sftse commented Dec 17, 2025

In that case no longer in favor.

On another note, removing the Arc here is almost certainly going to change behavior unless the derived Clone is never called.

@Tunglies
Copy link
Contributor Author

Clone is never called.

Yes, there is no any clone with ChannelDataIpcQueue.

macroscopic example & how much this would benefit performance

In the clash-verge-rev project, the optimization reduced the average IPC channel insertion time from approximately 2.36µs to 1.15µs, achieving a significant performance gain of over 50%.

bring in a new dependency

Since Dashmap already in the lock file, bringing it as tauri's dependency did not need compile new units.

@Legend-Master
Copy link
Contributor

Legend-Master commented Dec 18, 2025

In the clash-verge-rev project, the optimization reduced the average IPC channel insertion time from approximately 2.36µs to 1.15µs, achieving a significant performance gain of over 50%.

Could you share some benchmark results on the actual time used for a whole send operation for the channel? I think this insert call is most definitely not a bottleneck

Since Dashmap already in the lock file, bringing it as tauri's dependency did not need compile new units.

As I said, it is only in a dependency of tauri-cli, if we add it to tauri, we need to consider the trade offs around the extra compile time and final binary size

@Tunglies
Copy link
Contributor Author

Compile Config:

[profile.release]
panic = "abort"
codegen-units = 1
lto = "thin"
opt-level = 3
debug = false
strip = true
overflow-checks = false
rpath = false

Compile Command:

// Equal to cargo build --release --timings
pnpm build -- --timings

Baseline:

Compile Units: 1008
Compile Time: 6m14s
Binary Size: 27272512

With Dashmap as dependency:

Compile Units: 1011
Compile Time: 6m33s
Binary Size: 27272528

some benchmark results on the actual time used for a whole send operation for the channel

This PR forcusing on reduce IPC communication lantancy when inserting data when IPC payload over MAX_RAW_DIRECT_EXECUTE_THRESHOLD.

I would like to share some of actually runtime measurement with same compile config. I measure with launch to main dashboard, and do no extra user-operations, but cancle run mannualy. The order may not exactually same since async.
insert_lantancy_baseline.txt
insert_lantancy_with_dashmap.txt

need to consider the trade offs

Sorry to bother you, I'm used to developing user applications and may lack experience in considering as upstream aspects.

@Legend-Master
Copy link
Contributor

I would like to share some of actually runtime measurement with same compile config. I measure with launch to main dashboard, and do no extra user-operations, but cancle run mannualy. The order may not exactually same since async.
insert_lantancy_baseline.txt
insert_lantancy_with_dashmap.txt

The data seems to suggest the 2 took very similar times, no? With insert_lantancy_with_dashmap.txt having some more outliers that took milliseconds

Sorry to bother you, I'm used to developing user applications and may lack experience in considering as upstream aspects.

No worries, we all learned our way through 🙃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📬Proposal

Development

Successfully merging this pull request may close these issues.

4 participants