Performance optimization for message forwarding
Scenario: Client is communicating with Silo B via Silo A as gateway.
When Silo B is sending a reply message to the client the current messaging implementation will trigger deserialization of the whole message body in Silo A prior to forwarding. For forwarding the message body is then serialized again. Current implementation does not perform lazy deserialization of the message body by default since this requires additional memory to be allocated. From a cost perspective it is assumed that requests between silos are much more frequent than forwarding messages to a client.
For future performance improvements this scenario could be considered for special treatment.
Agreed. We lost lazy deserialization when we implemented the buffered read because a single buffer could contain data from two messages. When forwarding is expected (client to silo pipe), we support lazy deserialization at the cost of additional data copies (not allocations, because the buffers are pooled). These additional copies were acceptable due to the overall performance gain introduced by the buffered read.
These additional copies are, however, inefficient because we really only need to copy the first and last buffer blocks and only when these buffers contain other message data. It may be worth implementing a more efficient copy (as described above), performing this for both the silo to silo and client to silo paths, and measuring the performance to see if there is a meaningful gain.