Skip to content

[VL shuffle] Add VeloxSplitter to split with velox::RowVector - #1003

Merged
zuochunwei merged 2 commits into
apache:mainfrom
zuochunwei:ss
Feb 24, 2023
Merged

zuochunwei merged 2 commits into
apache:mainfrom
zuochunwei:ss

Conversation

@zuochunwei

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

  1. add VeloxSplitter to support splitting with velox::RowVector. when the backend is Velox, splitting with RowVector can avoid transferring from velox::RowVector to arrow::RowBatch, it's more efficient.
  2. we should avoid writing using namespace arrow or using namespace facebook::velox in header files, this usage brings mess and conflict.
  3. I will add Unit test soon, so file cpp/velox/tests/VeloxSplitterTest.cc is not ready now, but it will not affect others.
  4. I will also add the JNI call functions in file velox/jni/JniWrapper soon.

(Please fill in changes proposed in this fix)

How was this patch tested?

(Please explain how this patch was tested. E.g. unit tests, integration tests, manual tests)

(If this patch involves UI changes, please attach a screenshot; otherwise, remove this)

@github-actions

Copy link
Copy Markdown

Thanks for opening a pull request!

Could you open an issue for this pull request on Github Issues?

https://github.com/oap-project/gluten/issues

Then could you also rename commit message and pull request title in the following format?

[Gluten-${ISSUES_ID}] ${detailed message}

See also:

Comment thread cpp/velox/shuffle/VeloxSplitter.h Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please change the remark to english

@zuochunwei zuochunwei Feb 22, 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.

done

@jinchengchenghh

Copy link
Copy Markdown
Contributor

Can you use the benchmark https://github.com/oap-project/gluten/blob/main/cpp/core/benchmarks/ShuffleSplitBenchmark.cc to test if it works better than old shuffle?

Comment thread cpp/core/tests/ShuffleSplitTest.cc Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe you can use using namespace arrow in this .cc file

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.

:)

@zuochunwei

Copy link
Copy Markdown
Contributor Author

Can you use the benchmark https://github.com/oap-project/gluten/blob/main/cpp/core/benchmarks/ShuffleSplitBenchmark.cc to test if it works better than old shuffle?

The Unit test is not completed yet, I will run bench-mark after I complete the unit-test

@FelixYBW FelixYBW added the velox backend works for Velox backend label Feb 22, 2023
@FelixYBW FelixYBW changed the title [shuffle] Add VeloxSplitter to split with velox::RowVector [VL shuffle] Add VeloxSplitter to split with velox::RowVector Feb 22, 2023
Comment thread cpp/velox/shuffle/VeloxSplitter.h Outdated

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.

Will Arrow IPC writer be used in velox splitter? or probably the headers need to be minimized

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.

OK, I will check it, and we should minimize the header files to include

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.

yes, structs such as arrow::ipc::IpcPayload and arrow::ipc::IpcWriteOptions are used, so including these header files is necessary.

Comment thread cpp/velox/shuffle/VeloxSplitter.cc Outdated

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.

I don't have much context here but my intuition is that the code can base on row vector's schema instead of Arrow schema. But current way is also OK to me as of now.

@zuochunwei zuochunwei Feb 23, 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.

I don't have much context here but my intuition is that the code can base on row vector's schema instead of Arrow schema. But current way is also OK to me as of now.

In my first implementation, I tried to use Row Vector‘s schema, but I found it was not a good way because too many changes are required.

I get the arrow::Schema from RowVector using the interface velox::exportToArrow provided by Velox, and then it works well with RowVector. otherwise, I will have to switch case every Velox DataType and be careful of the relations of the two type systems.

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.

OK. So let's just keep the current way, it's not a big deal at this time.

Comment thread cpp/velox/shuffle/VeloxSplitter.h Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we get arrow Schema here?

@zuochunwei zuochunwei Feb 23, 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.

I kept this interface here, after I add the code for JNI, I will delete it if I find that it is useless. OK?

@FelixYBW FelixYBW removed the velox backend works for Velox backend label Feb 23, 2023
@zuochunwei

Copy link
Copy Markdown
Contributor Author

@zzcclp would you help me to check the problem of CH Unit-Test for this PR

@FelixYBW

Copy link
Copy Markdown
Contributor

There is a shuffle benchmark here: cpp/core/benchmarks/ShuffleSplitBenchmark.cc. Current the benchmark read parquet by arrow then do the slit. You may modify it as read parquet by velox, then test velox->arrow + arrow split vs. velox split to arrow. We may check the perf gain and optimize the velox split code.

@zuochunwei

Copy link
Copy Markdown
Contributor Author

There is a shuffle benchmark here: cpp/core/benchmarks/ShuffleSplitBenchmark.cc. Current the benchmark read parquet by arrow then do the slit. You may modify it as read parquet by velox, then test velox->arrow + arrow split vs. velox split to arrow. We may check the perf gain and optimize the velox split code.

got it, I will append the benchmark

@zuochunwei
zuochunwei merged commit 746154d into apache:main Feb 24, 2023
@zuochunwei
zuochunwei deleted the ss branch March 23, 2023 09:00
#endif

// partition number should be less than 64k
ARROW_CHECK_LE(num_partitions_, 64 * 1024);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why num_partitions_ can not be greater then 64K?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Because the partition id is 16bit to save memory footprint. If your case needs more than 64K reducers, feel free to add 32bit support through template.

// subscript: Row ID
// value: Partition ID
// TODO: rethink, is uint16_t better?
std::vector<uint32_t> row_2_partition_; // note: partition_id_

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why naming these fields as xxx_2_xxx ? it is not a map, why not just partitionIds ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Feel free to update for more reasonable names.

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.

6 participants