[SPARK-46567][CORE] Remove ThreadLocal for ReadAheadInputStream#44563
Closed
beliefer wants to merge 1 commit intoapache:masterfrom
Closed
[SPARK-46567][CORE] Remove ThreadLocal for ReadAheadInputStream#44563beliefer wants to merge 1 commit intoapache:masterfrom
beliefer wants to merge 1 commit intoapache:masterfrom
Conversation
LuciferYang
reviewed
Jan 2, 2024
| // short path - just get one byte. | ||
| return activeBuffer.get() & 0xFF; | ||
| } else { | ||
| byte[] oneByteArray = oneByte.get(); |
Contributor
There was a problem hiding this comment.
The original writing seems to be to avoid creating byte[1] repeatedly. Have you encountered any bad cases? The new writing seems to create more objects of type byte[1]
Contributor
Author
There was a problem hiding this comment.
byte[1] is very cheap and change it to local variable could avoid GC.
Contributor
Author
There was a problem hiding this comment.
We can decorate it with private final if we really need to avoid creating byte[1] repeatedly.
Contributor
Author
|
ping @dongjoon-hyun @srowen cc @sitalkedia |
Contributor
Author
|
The GA failure is unrelated. |
Member
|
I agree with this change, I would be surprised if it's even an optimization |
LuciferYang
approved these changes
Jan 3, 2024
Member
|
Merged to master. |
Member
|
Thank you, @beliefer and all. |
Contributor
Author
|
@srowen @dongjoon-hyun @LuciferYang Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This PR propose to remove
ThreadLocalforReadAheadInputStream.Why are the changes needed?
ReadAheadInputStreamhas a fieldoneBytedeclared asTheadLocal.In fact,
oneByteonly used in read.We can remove it by the way that the closure of local variables in instance methods can provide thread safety guarantees.
On the other hand, the
TheadLocaloccupies a certain amount of space in the heap and there are allocation and GC costs.Does this PR introduce any user-facing change?
'No'.
How was this patch tested?
Exists test cases.
Was this patch authored or co-authored using generative AI tooling?
'No'.