Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CELEBORN-1300] Optimize CelebornInputStreamImpl's memory usage #2348

Closed
wants to merge 5 commits into from

Conversation

waitinfuture
Copy link
Contributor

@waitinfuture waitinfuture commented Mar 1, 2024

What changes were proposed in this pull request?

To avoid too much memory usage when CelebornShuffleReader creates input streams.
This PR does the following:

  1. Constructor of CelebornInputStream does not fetch chunk
  2. compressedBuf and rawDataBuf are created first time fillBuffer is called
  3. When fillBuffer returns false, which means the inputstream is exhausted, close is called and resource released
  4. CelebornFetchFailureSuite is only run for Spark 3.0 and newer

Why are the changes needed?

ditto

Does this PR introduce any user-facing change?

No

How was this patch tested?

GA and e2e test.

@waitinfuture
Copy link
Contributor Author

waitinfuture commented Mar 1, 2024

cc @CodingCat @RexXiong @FMX @ErikFang

@waitinfuture waitinfuture marked this pull request as draft March 1, 2024 08:39
Copy link

codecov bot commented Mar 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 48.85%. Comparing base (cae4de1) to head (5bdd9ad).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2348      +/-   ##
==========================================
- Coverage   48.90%   48.85%   -0.04%     
==========================================
  Files         207      207              
  Lines       12965    12965              
  Branches     1113     1113              
==========================================
- Hits         6339     6333       -6     
- Misses       6220     6224       +4     
- Partials      406      408       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@waitinfuture waitinfuture changed the title [CELEBORN-1300] Don't fetch chunk in CelebornInputStreamImpl's constructor [CELEBORN-1300] Optimize CelebornInputStreamImpl's memory usage Mar 3, 2024
@waitinfuture waitinfuture marked this pull request as ready for review March 3, 2024 07:35
Copy link
Contributor

@RexXiong RexXiong left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

waitinfuture and others added 3 commits March 5, 2024 10:28
…nputStream.java

Co-authored-by: Nicholas Jiang <programgeek@163.com>
…SparkTestBase.scala

Co-authored-by: Nicholas Jiang <programgeek@163.com>
@waitinfuture
Copy link
Contributor Author

Comments addressed, PTAL @CodingCat @SteNicholas @pan3793

@CodingCat
Copy link
Contributor

LGTM

@@ -32,6 +33,10 @@ import org.apache.celeborn.service.deploy.MiniClusterFeature

trait SparkTestBase extends AnyFunSuite
with Logging with MiniClusterFeature with BeforeAndAfterAll with BeforeAndAfterEach {

val Spark3OrNewer = SPARK_VERSION >= "3.0"
Copy link
Member

@pan3793 pan3793 Mar 5, 2024

Choose a reason for hiding this comment

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

not a big deal, in some cases, SPARK_VERSION returns "unknown", and

scala> "unknown" >= "3.0"
res0: Boolean = true

waitinfuture added a commit that referenced this pull request Mar 5, 2024
### What changes were proposed in this pull request?
To  avoid too much memory usage when CelebornShuffleReader creates input streams.
This PR does the following:

1. Constructor of `CelebornInputStream` does not fetch chunk
2. `compressedBuf` and `rawDataBuf` are created first time `fillBuffer` is called
3. When `fillBuffer` returns false, which means the inputstream is exhausted, `close` is called and resource released
4. `CelebornFetchFailureSuite` is only run for Spark 3.0 and newer

### Why are the changes needed?
ditto

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
GA and e2e test.

Closes #2348 from waitinfuture/1300.

Lead-authored-by: zky.zhoukeyong <zky.zhoukeyong@alibaba-inc.com>
Co-authored-by: Keyong Zhou <waitinfuture@gmail.com>
Signed-off-by: zky.zhoukeyong <zky.zhoukeyong@alibaba-inc.com>
(cherry picked from commit 8b6bc35)
Signed-off-by: zky.zhoukeyong <zky.zhoukeyong@alibaba-inc.com>
@waitinfuture
Copy link
Contributor Author

Thanks! Merged to main(0.5.0)/branch-0.4(v0.4.1)

cfmcgrady pushed a commit to cfmcgrady/incubator-celeborn that referenced this pull request May 31, 2024
To  avoid too much memory usage when CelebornShuffleReader creates input streams.
This PR does the following:

1. Constructor of `CelebornInputStream` does not fetch chunk
2. `compressedBuf` and `rawDataBuf` are created first time `fillBuffer` is called
3. When `fillBuffer` returns false, which means the inputstream is exhausted, `close` is called and resource released
4. `CelebornFetchFailureSuite` is only run for Spark 3.0 and newer

ditto

No

GA and e2e test.

Closes apache#2348 from waitinfuture/1300.

Lead-authored-by: zky.zhoukeyong <zky.zhoukeyong@alibaba-inc.com>
Co-authored-by: Keyong Zhou <waitinfuture@gmail.com>
Signed-off-by: zky.zhoukeyong <zky.zhoukeyong@alibaba-inc.com>
(cherry picked from commit 8b6bc35)
Signed-off-by: zky.zhoukeyong <zky.zhoukeyong@alibaba-inc.com>
RexXiong pushed a commit that referenced this pull request Jul 18, 2024
…ream

### What changes were proposed in this pull request?
#2348 avoids fetching first chunk in the constructor
of `CelebornInputStreamImpl`, but in some cases, i.e. coalescing 3000 partitions into one in Spark,
it can be beneficial to do so for performance. This PR adds back prefetching with knobs default to false.

### Why are the changes needed?

### Does this PR introduce _any_ user-facing change?
Yes, two configs are added.

### How was this patch tested?
Extended `MemorySkewJoinSuite` and `ReusedExchangeSuite`, and manual test.

Closes #2549 from waitinfuture/1446.

Authored-by: zky.zhoukeyong <zky.zhoukeyong@alibaba-inc.com>
Signed-off-by: Shuang <lvshuang.xjs@alibaba-inc.com>
RexXiong pushed a commit that referenced this pull request Jul 18, 2024
…ream

### What changes were proposed in this pull request?
#2348 avoids fetching first chunk in the constructor
of `CelebornInputStreamImpl`, but in some cases, i.e. coalescing 3000 partitions into one in Spark,
it can be beneficial to do so for performance. This PR adds back prefetching with knobs default to false.

### Why are the changes needed?

### Does this PR introduce _any_ user-facing change?
Yes, two configs are added.

### How was this patch tested?
Extended `MemorySkewJoinSuite` and `ReusedExchangeSuite`, and manual test.

Closes #2549 from waitinfuture/1446.

Authored-by: zky.zhoukeyong <zky.zhoukeyong@alibaba-inc.com>
Signed-off-by: Shuang <lvshuang.xjs@alibaba-inc.com>
(cherry picked from commit d692e49)
Signed-off-by: Shuang <lvshuang.xjs@alibaba-inc.com>
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