Skip to content

Conversation

@ResuBaka
Copy link
Contributor

@ResuBaka ResuBaka commented Jul 21, 2025

Description of Changes

This updates the tungstenite lib to get two changes which make good improvements to the performance and reduces cpu usage.

API and ABI breaking changes

Expected complexity level and risk

1

Testing

  • Check performance
  • Check cpu usage from before after

For me testing it locally in my application my whole application used like 2x to 3x less cpu and the the over all time spend.

Before the Update. (I tried to have the time span for the profile but they could be off by like total time the application did run by 30s)

image

After the update.

image

Here are links to the two PRs.

snapview/tungstenite-rs#501
snapview/tungstenite-rs#496

@ResuBaka ResuBaka changed the title Update tungstenite to get client red performance improvement Update tungstenite to get client read performance improvement Jul 21, 2025
They did a small change around the way the handle the read buffer resize
which bring a perf improvement for bigger messages and smaller ones.
@ResuBaka ResuBaka force-pushed the update-tokio-tungstenite-for-performance branch from 4e62805 to 2a837a3 Compare July 21, 2025 19:38
@ResuBaka
Copy link
Contributor Author

Oh it looks like I need to check how I can run spacetime locally. As before I used the docker compose setup but that does not want to start with other errors then in the ci. E.g. it can not find all the crates and if I add them it is missing the feature setup in one crate.

Is the docker setup still some supported or preferred way or should it be just run directly in development?

@kim
Copy link
Contributor

kim commented Jul 22, 2025

@ResuBaka docker compose up should work. If you want the binary to be built in release mode, you'll need to edit the docker-compose.yml file and set CARGO_PROFILE: release.

Alternatively, you can install from source and run spacetimedb start.

CI errors are because tungstenite's Error enum changed.

@ResuBaka
Copy link
Contributor Author

Then maybe it is an issue with using the docker compose on linux?

As I am getting this output:

Attaching to node-1
node-1  | Finding local deps failed: Failed to execute `cargo metadata`: `cargo metadata` exited with an error: error: failed to load manifest for workspace member `/usr/src/app/crates/auth`
node-1  | referenced by workspace at `/usr/src/app/Cargo.toml`
node-1  |
node-1  | Caused by:
node-1  |   failed to load manifest for dependency `spacetimedb-lib`
node-1  |
node-1  | Caused by:
node-1  |   failed to load manifest for dependency `spacetimedb-memory-usage`
node-1  |
node-1  | Caused by:
node-1  |   failed to read `/usr/src/app/crates/memory-usage/Cargo.toml`
node-1  |
node-1  | Caused by:
node-1  |   No such file or directory (os error 2)
node-1  |
node-1  | [Running 'cargo run start --data-dir=/stdb/data --jwt-pub-key-path=/etc/spacetimedb/id_ecdsa.pub --jwt-priv-key-path=/etc/spacetimedb/id_ecdsa']
node-1  | error: failed to load manifest for workspace member `/usr/src/app/crates/auth`
node-1  | referenced by workspace at `/usr/src/app/Cargo.toml`
node-1  |
node-1  | Caused by:
node-1  |   failed to load manifest for dependency `spacetimedb-lib`
node-1  |
node-1  | Caused by:
node-1  |   failed to load manifest for dependency `spacetimedb-memory-usage`
node-1  |
node-1  | Caused by:
node-1  |   failed to read `/usr/src/app/crates/memory-usage/Cargo.toml`
node-1  |
node-1  | Caused by:
node-1  |   No such file or directory (os error 2)
node-1  | [Finished running. Exit status: 101]

@ResuBaka
Copy link
Contributor Author

It is also the same on a fresh clone.

@ResuBaka ResuBaka force-pushed the update-tokio-tungstenite-for-performance branch from 525fbdb to e7fcf7e Compare July 22, 2025 17:01
@CLAassistant
Copy link

CLAassistant commented Jul 23, 2025

CLA assistant check
All committers have signed the CLA.

@kim
Copy link
Contributor

kim commented Jul 23, 2025

Then maybe it is an issue with using the docker compose on linux?

I don't know, mine works fine. Do you maybe have the deprecated docker-compose installed, instead of the built-in docker compose?

@ResuBaka
Copy link
Contributor Author

Then maybe it is an issue with using the docker compose on linux?

I don't know, mine works fine. Do you maybe have the deprecated docker-compose installed, instead of the built-in docker compose?

I will check later but I should run the latest arch linux version e.g. 2.38.2 of docker compose. Maybe I need to rebuild the docker image it would want to build. I will try that later to see if that fixes the issue.

On the other note, is that to be expected that Unity test fails? Or is it okay as I have not changed anything that should make that one fail or not even run correctly.

@kim kim enabled auto-merge July 23, 2025 12:32
@kim
Copy link
Contributor

kim commented Jul 23, 2025

is that to be expected that Unity test fails

Yeah it isn't allowed to read the Unity license data, because your PR is coming from outside the clockworklabs org. I'll have that sorted out.

Thanks for your contribution!

@ResuBaka
Copy link
Contributor Author

Now after using docker compose up --build it is working again. Should maybe have tried that first but I did not think about that.

@kim kim added this pull request to the merge queue Jul 23, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 23, 2025
@kim kim added this pull request to the merge queue Jul 23, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 23, 2025
@bfops bfops added this pull request to the merge queue Jul 23, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 23, 2025
@kim kim added this pull request to the merge queue Jul 24, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 24, 2025
@kim kim enabled auto-merge July 24, 2025 16:40
@kim kim added this pull request to the merge queue Jul 24, 2025
Merged via the queue into clockworklabs:master with commit 7fb4df4 Jul 24, 2025
17 of 18 checks passed
@ResuBaka ResuBaka deleted the update-tokio-tungstenite-for-performance branch July 24, 2025 17:29
Shubham8287 pushed a commit that referenced this pull request Jul 28, 2025
mamcx pushed a commit that referenced this pull request Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants