perf: JSON-RPC: faster eventLoop: request buffer
#7795
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before this commit we would not start another
getNextEvent()before we have received a response for the previous one.
This commit makes a pool of
getNextEvent()requestsso that the server always has a request
that it can readily respond to.
Measurements
I have tested this on Delta Chat desktop.
This seems to provide a measurable speedup in handling event bursts.
I did
console.time()when we starta
BackendRemote.rpc.maybeNetwork()request(which we do every time the main window is focused),
and a
console.timeEnd()when we receive the first"IDLE entering wait-on-remote state" entry, inside of
ipcBackend.on('json-rpc-message'.For these measurements I also disabled request-response logging
with
config['log-debug'] = false.Each such
maybeNetwork()resulted in ~1000getNextEvent()responses.With the original event loop (without a pool) the average time
based on 150 measurements was 1152.28 ms.
With the new event loop with a pool of 20
based on 150 measurements it was 774.58 ms.
That is 67.22% of the original average duration.
TODO:
Please check that this doesn't break stuff.
I heard that there was some issue with Delta Chat bots
trying to not miss a single event.
If that's the case, or if in doubt, we can set
the default pool size to 1 instead of 20,
and only set it to 20 in Delta Chat Desktop.
Related:
Infoevents deltachat/deltachat-desktop#5282