Because the proxy is in the middle of a client and a server, it has to decode incoming requests to check their validity, perform routing and potentially modify their content. Then the requests is re-encoded again to be transmitted to the backend server.
Then the same operation repeat for the response received from the server.
This processing could be reduced (and as such optimized), when the message is not modified by the proxy. We could indeed keep a serialized version of the incoming message and push it directly to the remote peer without having to re-serialize the ProtocolOp object.
To achieve this, the Codec needs to attach the serialized form to the decoded object and needs to be able to extract this serialized form from an incoming object to serialized. To do so we could use a Control which will be used by the proxy internal only and never transmitted to the network. Another possibility is to use a dynamic proxy which would decorate the de-serialized object.
Ideally, for best performance gain, the serialized form should be a reference to the original input rather than copied into separate buffer.