Skip to content

Conversation

@cloud-fan
Copy link
Contributor

What changes were proposed in this pull request?

According to the discussion in #21175 , this PR proposes 2 improvements:

  1. add comments to explain why we call limit to write out ByteBuffer with slices.
  2. remove the try ... finally

How was this patch tested?

existing tests

@cloud-fan
Copy link
Contributor Author

cc @Manbuyun @JoshRosen @jiangxb1987

@SparkQA
Copy link

SparkQA commented May 15, 2018

Test build #90622 has finished for PR 21327 at commit cd2f0e3.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor Author

retest this please

@SparkQA
Copy link

SparkQA commented May 15, 2018

Test build #90628 has finished for PR 21327 at commit cd2f0e3.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

} finally {
bytes.limit(curChunkLimit)
}
// If `bytes` is an on-heap ByteBuffer, the JDK will copy it to a temporary direct
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about the JDK -> the JVM?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the caching happens in the JDK code, not some magic inside JVM.

bytes.limit(curChunkLimit)
}
// If `bytes` is an on-heap ByteBuffer, the JDK will copy it to a temporary direct
// ByteBuffer when writing it out. The JDK caches one temporary buffer per thread, and we
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JDK caches one temporary buffer per thread

I don't think this statement is correct. According to Util.java, the cached number of temporary direct buffer is up to IOUtil.IOV_MAX.

if the cached temp buffer gets created and freed frequently

The problem is that the varied-sized heap buffers could cause a new allocation of temporary direct buffer and free of old direct buffer if the buffer size is larger than before

@SparkQA
Copy link

SparkQA commented May 16, 2018

Test build #90686 has finished for PR 21327 at commit ad91422.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented May 16, 2018

Test build #90689 has finished for PR 21327 at commit d651d3e.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@JoshRosen
Copy link
Contributor

LGTM. Thanks for these changes; they really help to clarify this tricky piece of code for readers.

@cloud-fan
Copy link
Contributor Author

retest this please

@SparkQA
Copy link

SparkQA commented May 17, 2018

Test build #90710 has finished for PR 21327 at commit d651d3e.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@viirya
Copy link
Member

viirya commented May 17, 2018

LGTM. It's good comment added.

@viirya
Copy link
Member

viirya commented May 17, 2018

retest this please.

@SparkQA
Copy link

SparkQA commented May 17, 2018

Test build #90715 has finished for PR 21327 at commit d651d3e.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor Author

thanks, merging to master!

@asfgit asfgit closed this in 6ec0582 May 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants