-
Notifications
You must be signed in to change notification settings - Fork 80
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
RPC: Decouple message creation from message encoding/decoding #6027
RPC: Decouple message creation from message encoding/decoding #6027
Conversation
5994f92
to
bce027e
Compare
2207382
to
f318061
Compare
efe7f9f
to
0b5eaa3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, did you check the CI failures?
@nimrod-becker I'm not sure what happened to TravisCI but I cant find how to restart thee build. |
@guymguym I restarted the build |
@nb-ohad It failed. Not clear if related so I restarted the tests now. |
It seems that not serializing the payload (body) into a buffer (and then deserializing) creates a difference with regard to encoding. I am working on trying to pinpoint the problem. |
any news on that? |
0b5eaa3
to
c51c44e
Compare
c51c44e
to
b840d29
Compare
@guymguym ping on review for the second commit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nb-ohad One last comment about making the omit conditional to avoid copying the params/reply objects, the copy is shallow but still this is very much unneeded.
Other than that it looks good to me.
b840d29
to
bbac13a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nb-ohad To summarize this PR - it tries to improve how rpc_fcall (which is an optimized rpc path for calls which are executed in the same process) by getting rid of the intermediate large memory allocations created by JSON.parse(JSON.stringify(..)) and instead use cloneDeep. It does introduce some subtleties of cloning in rpc_fcall, but the rest of the system is not affected.
However, how do you measure the effect of this change? Did it help? is it possible that it is somehow slower/heavier than previous solution? Of course - I don't really think so. But we need to work with some numbers here.
I would suggest to enhance rpc_benckmark.js for that. You can add a new --fcall
flag that will do the benchmark inside one process (both client and server). And then our main metric is operations/second and the higher the better, or something more complicated is needed to see the effect? We can run it with node --trace-gc
for GC info. And we can add anything else we need to that benchmark to simulate the effect on a real process...
@guymguym This optimization is not about getting rid of regarding measurements, This is a thing that is very hard to measure and the normal We decided to tackle the points according to their impact and ease of fixing. So we choose to improve memory allocations in the instantiation of our API clients (#6022) and minimizing allocations for RPC calls via 'fcall' connections |
eb2ed8c
to
64a5f89
Compare
64a5f89
to
31bba1d
Compare
allowing rpc_fcall to override defualt encoding/decoding decoding Ensure cloning of rpc messages procude a clone that is more like a message decoded form buffers by: 1. Removing rpc_buffers from message body (and n2n_proxy messages) 2. serializing object ids into strings 3. ensuring empty buffers array on every message Signed-off-by: nb-ohad <[email protected]>
31bba1d
to
a9c0f44
Compare
Explain the changes
fcall
connections to passthrough the RpcMessage without encoding or decoding.Issues: Fixed #xxx / Gap #xxx
Testing Instructions: