Skip to content

[#1213] feat(rust): Support block filter by taskId when getting memory data - #1311

Merged
zuston merged 13 commits into
apache:masterfrom
wenlongbrother:users/wenlong/SupportBlockIdFilterWhenGettingDataFromMemory
Nov 22, 2023
Merged

[#1213] feat(rust): Support block filter by taskId when getting memory data#1311
zuston merged 13 commits into
apache:masterfrom
wenlongbrother:users/wenlong/SupportBlockIdFilterWhenGettingDataFromMemory

Conversation

@wenlongbrother

@wenlongbrother wenlongbrother commented Nov 12, 2023

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Support block filter by taskId when getting memory data

Why are the changes needed?

In AQE, after executing the sub-QueryStages, collect the shuffle data size, So if we can filter block,
it will improve the performance of AQE.

Fix: #1213

Does this PR introduce any user-facing change?

No.

How was this patch tested?

  1. UTs

@wenlongbrother
wenlongbrother marked this pull request as draft November 12, 2023 14:00
@wenlongbrother

Copy link
Copy Markdown
Contributor Author

Hi @zuston , could you please help reivew this pr , I may have lost some context.

@codecov-commenter

codecov-commenter commented Nov 12, 2023

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (d5de299) 53.35% compared to head (8335f44) 54.41%.
Report is 6 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1311      +/-   ##
============================================
+ Coverage     53.35%   54.41%   +1.05%     
- Complexity     2690     2695       +5     
============================================
  Files           410      391      -19     
  Lines         23590    21283    -2307     
  Branches       2003     2006       +3     
============================================
- Hits          12587    11581    -1006     
+ Misses        10229     8997    -1232     
+ Partials        774      705      -69     

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

@wenlongbrother
wenlongbrother marked this pull request as ready for review November 12, 2023 14:24
@zuston

zuston commented Nov 13, 2023

Copy link
Copy Markdown
Member

Could you help add some UTs?

@wenlongbrother

wenlongbrother commented Nov 13, 2023

Copy link
Copy Markdown
Contributor Author

Could you help add some UTs?

sure, @zuston plz do review again, thank you. 😄

@zuston zuston left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This part could be referred by the java side shuffle-server

Comment thread rust/experimental/server/src/proto/uniffle.proto
@wenlongbrother

Copy link
Copy Markdown
Contributor Author

Hi @zuston , could you please help review this pr again? Thanks! I have update ut and parameter

@zuston zuston left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall lgtm. I believe this pr is in good shape

Comment thread rust/experimental/server/src/store/memory.rs Outdated
Comment thread rust/experimental/server/src/app.rs Outdated
Comment thread rust/experimental/server/src/grpc.rs Outdated
Comment thread rust/experimental/server/src/store/memory.rs
@wenlongbrother

Copy link
Copy Markdown
Contributor Author

Hi @zuston thank you for your review and helpful comment.

// get block_ids filter
// In AQE, after executing the sub-QueryStages, collect the shuffle data size
// So if we can filter block, it will improve the performance of AQE.
candidate_blocks = candidate_blocks

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This part looks not correct. I hope this could be bound to the read_partial_data_with_max_size_limit .

Without the bitmap filter, we will read it the (last_block_id, end] without the limited size. But for now, I think it will read from (last_block_id, end] with filter and then in a limited size. Right?

So it's better to refactor the read_partial_data_with_max_size_limit, maybe the name of read_partial_data_with_max_size_limit_and_filter will be better. Like that

pub(crate) fn read_partial_data_with_max_size_limit_and_task_filter<'a>(
        &'a self,
        blocks: Vec<&'a PartitionedDataBlock>,
        fetched_size_limit: i64,
        serialized_expected_task_ids_bitmap: Option<Treemap>,
    ) -> (Vec<&PartitionedDataBlock>, i64) {
        let mut fetched = vec![];
        let mut fetched_size = 0;

        for block in blocks {
            if &serialized_expected_task_ids_bitmap.is_some() {
                if !&serialized_expected_task_ids_bitmap.unwrap().contains(block.task_attempt_id as u64) {
                    continue;
                }
            }
            if fetched_size >= fetched_size_limit {
                break;
            }
            fetched_size += block.length as i64;
            fetched.push(block);
        }

        (fetched, fetched_size)
    }

@wenlongbrother wenlongbrother Nov 17, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi @zuston Your consideration is correct.
Integrating filter logic into read_partial_data_with_max_size_limit_and_task_filter functions is indeed a better design choice, so that the filter can be applied directly when the data is read, rather than filtering and then reading.
The advantage of this is that data can be processed more efficiently, especially when the amount of data is large or the filtering conditions are complex.
Thank you for your meticulous guidance and patience.

candidate_blocks,
max_size,
if last_block_id == -1 {
None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why the bitmap will be ignored when the last_block_id = -1 ?

@wenlongbrother wenlongbrother Nov 20, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You mentioned

Otherwise, when the last_block_id = -1, the filter is not valid. This case also should be added into test.

I may misunderstood you, let me update it, sorry

@zuston zuston left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thanks @wenlongbrother

@zuston zuston changed the title [#1213] feat: Support block id filter when getting data from memory [#1213] feat(rust): Support block filter by taskId when getting memory data Nov 22, 2023
@zuston
zuston merged commit 4edd60f into apache:master Nov 22, 2023
zuston pushed a commit to zuston/incubator-uniffle that referenced this pull request Jan 18, 2024
… memory data (apache#1311)

### What changes were proposed in this pull request?

Support block filter by taskId when getting memory data

### Why are the changes needed?

In AQE, after executing the sub-QueryStages, collect the shuffle data size, So if we can filter block, 
it will improve the performance of AQE.

Fix: apache#1213

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

No.

### How was this patch tested?

1. UTs

---------

Co-authored-by: 蒋文龙 <jiangwenlong@192.168.1.7>
Co-authored-by: 蒋文龙 <jiangwenlong@192.168.1.6>
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.

[FEATURE][RUST] Support blockId filter when getting data from memory

3 participants