HDDS-9369. Avoid deserializing OMRequest multiple times in OzoneManagerStateMachine.#5376
HDDS-9369. Avoid deserializing OMRequest multiple times in OzoneManagerStateMachine.#5376szetszwo merged 3 commits intoapache:masterfrom
Conversation
| try { | ||
| OMRequest request = OMRatisHelper.convertByteStringToOMRequest( | ||
| trx.getStateMachineLogEntry().getLogData()); | ||
| final OMRequest request = (OMRequest) trx.getStateMachineContext(); |
There was a problem hiding this comment.
Please add a line that this case depends on the deserialization done in startTransaction.
kerneltime
left a comment
There was a problem hiding this comment.
Looks good, pending CI and minor nit.
| trx.getStateMachineLogEntry().getLogData()); | ||
| final OMRequest request = (OMRequest) trx.getStateMachineContext(); | ||
| OzoneManagerProtocolProtos.Type cmdType = request.getCmdType(); | ||
|
|
There was a problem hiding this comment.
All these validations should be on startTransaction as well. The creation of UGI is quite expensive as well.
There was a problem hiding this comment.
The UGI is only for upgrade Prepare. Let's don't optimize it here.
|
In looking at this, I checked: And I noticed it takes the passed byteString and converts it to Bytes and then passes the bytes to I don't know much about how this Ratis stuff is put together, but it seems that we are paying the price for an extra copy on every message received due to "different" but likely the same classes being used behind the scenes. |
|
We had the similar problem in HBase where the protobuf it used collides with the one shaded by Hadoop 3.3. |
|
Proto 3 support wrapping a ByteString proto2 = wrap(proto3byteString.asReadOnlyByteBuffer());Let me try it in a separated JIRA. |
| // For the Leader, the OMRequest is set in trx in startTransaction. | ||
| // For Followers, the OMRequest hast to be converted from the log entry. | ||
| final Object context = trx.getStateMachineContext(); | ||
| final OMRequest request = context != null ? (OMRequest) context |
There was a problem hiding this comment.
So, the followers need to deserialize. That's OK if applyTransaction on the followers does not slow the commit phase down. Is that the case?
I think applyTransaction is done after the majority commit, just wanna double check.
There was a problem hiding this comment.
...
applyTransactionis done after the majority commit, ...
That is correct.
|
@kerneltime , @duongkame , @sodonnel , @jojochuang , thanks a lot for the review and ideas! |
Tried it a little bit but not succeeded. Many |
What changes were proposed in this pull request?
In OzoneManagerStateMachine, the same log data is deserialized to the same OMRequest multiple times. It can be avoided by setting stateMachineContext.
What is the link to the Apache JIRA
HDDS-9369
How was this patch tested?
By existing tests.