HDDS-6400. EC: Refactor ECKeyOutputStream for better code reuse - #3372
Conversation
|
Thanks @kaijchen for working on this patch. Overall it looks good to me. |
umamaheswararao
left a comment
There was a problem hiding this comment.
LGTM, pending CI
|
Thanks @umamaheswararao for the review, actually I have a few more commits working on. I have included them in this PR, please take another look at the 2 commits added.
|
umamaheswararao
left a comment
There was a problem hiding this comment.
LGTM. Lets get this in.
|
Please resolve conflicts and pending CI one more time just to make sure. Thanks |
| // = dataBuffer[0].position() | ||
| final int parityCellSize = dataBuffers[0].position(); | ||
|
|
||
| // Duplicate dataBuffers and add padding |
There was a problem hiding this comment.
Isn't this buffers we are creating out side of cache?
I think this may be a performance impact if there are many small files?
Pretty much for every file we will endup creating this buffer once outside of cache.
There was a problem hiding this comment.
The duplicate() don't create extra buffer, it shares underlying content with the original ByteBuffer.
https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html#duplicate--
There was a problem hiding this comment.
Or can we add dataBuffersForRead in ECChunkBuffers to avoid the object creation cost here?
There was a problem hiding this comment.
Yeah you are right. Also this will happen sequentially so underlying buffer sharing is ok.
IIUC, How about we do this only when padding is necessary? Otherwise we may can use original buffers when all databuffers actually full right? So, min size of databuffers should tell use whether we will need padding or not right?
That way this extra object will be created only for last stripe right.
There was a problem hiding this comment.
I don't think it's safe to use the original buffers here because encoder.encode() will modify the position of the input ByteBuffer.
There was a problem hiding this comment.
Do you think adding a dataBufferForEncode like kaijchen@b15799b is OK?
There was a problem hiding this comment.
That would too much usage of cache buffers class than needed.
IIUC, How about we do this only when padding is necessary? Otherwise we may can use original buffers when all databuffers actually full right?
Not sure you got what I was trying to say. Why original buffers will be modified when original buffers already full (all full with ecChunkSize)?
I was suggesting to create this duplicate buffers only when we really do padding. Let's say if all data buffers are full, then we will not do any padding. But still we create this duplicate right.
I don't think it's safe to use the original buffers here because encoder.encode() will modify the position of the input ByteBuffer.
Just for argument: Ideally you will modify original buffer here also. But we will have our own tracking pointers. Similar way, when you change the original buffer directly and we track that length, we are ok too.
ead84f1 to
be450b1
Compare
|
Yeah generateParityCells looks little bit messy, but it should be ok as it got some checks needed there. |
|
Thanks @umamaheswararao for the review. |
What changes were proposed in this pull request?
Refactor ECKeyOutputStream to make the code cleaner.
Reuse code when writing the last stripe or rewriting failed stripes.
The changes includes:
it will check strip full and call encodeAndWriteParityCells().
and it can be reused to encode partial stripe in close().
it can be reused in rewriteStripeToNewBlockGroup().
it will exclude both failed pipeline and failed datanodes.
so we don't have to track stripe length in rewrite.
so that we don't need to pass isClose parameter around in rewrite.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-6400
How was this patch tested?
Existing CI