-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Response handling on the client is very slow comparing to server #1189
Comments
Hey @nazar-pc are you using the http client or ws client? Then also report which jsonrpsee version you are running.... |
WS client, version is unfortunately still 0.16.2 (what Substrate is using) |
Ok I see, we merged #1145 recently included in v0.20. I hope that makes things better because we refactored the background task to multiplex send/receive operations maybe you could test it by patching just the client if it's not to annoying. |
Hm.. simply swapping the version with git didn't quite work, it failed to compile, probably some version needs to be bumped somewhere or there is semver violation somewhere:
|
ah ok, maybe try updating tokio_rustls but not sure whether it works you have version 0.16.2 in your tree. |
Semver exists such that it shouldn't break, especially I wouldn't expect tokio to break it 😕 UPD: Nope, didn't work. |
I see, the reason is |
Tested current git of jsonrpsee (1af525c), it used 120% of CPU and finished in 74 seconds. I suspect it might take a while to deserialize 2GiB of JSON, but even then it should have ideally used more than one core doing so. Release build of the client took 42 seconds. Still a lot. |
Ok, that makes sense and deserializing the response is single-threaded and is not split across different tasks/cores. It's really intended for async I/O but perhaps we could do something better is message is larger than some limit |
Yeah, that was my thought as well. JSON messages that are 2 MiB in size are not very typical for JSON-RPC. |
On this topic making requests from Similarly I see in What I don't know is how much concurrency is applied on the server side. Either way current versions of jsonrpsee are WAY BETTER than 0.16.2 I used originally. |
There are two apps: one server and one client.
Client makes 1000 requests asynchronously to the server, server replies to each of them with 2MiB response (1MiB in hex).
Result: server (Substrate node actually) is done preparing responses in under 5 seconds (debug build) and has near zero CPU usage after this, client is busy for ~70 seconds with ~130% CPU usage (so using just over 1 CPU core).
Test is running on 24C/32T 13900K and tokio runtime used is multi-threaded, I have no idea what the client is doing for so long occupying just one core and why this affects client, but not server.
The text was updated successfully, but these errors were encountered: