-
Notifications
You must be signed in to change notification settings - Fork 5
Add PartitionedVector benchmark #1655
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
base: main
Are you sure you want to change the base?
Conversation
18b20cf to
216a2fa
Compare
|
|
||
| void run(const RowVectorPtr& vector, int32_t numPartitions) { | ||
| folly::BenchmarkSuspender suspender; | ||
| // roundRobinPartitionFunction(vector, numPartitions, partitions_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the commented out line, or make the distribution a dimension as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add a non-uniform distribution to test the skew case.
| const auto vectorCopy = std::static_pointer_cast<RowVector>( | ||
| BaseVector::copy(*vector, bm->getPool())); | ||
| suspender.dismiss(); | ||
| bm->run(vectorCopy, 10000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10000 partitions?
#partitions also need to be one test dimension. The value of intcan be {4, 8, 16, 32, 64, 128, 256, 512, 1024}
| } // namespace | ||
|
|
||
| class PartitionedVectorBenchmark : public VectorTestBase { | ||
| protected: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move the field members to the end of the class.
| return std::dynamic_pointer_cast<RowVector>(batch); | ||
| } | ||
|
|
||
| void prepareBuffers(vector_size_t numRows, int32_t numPartitions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can merge this function with calculatePartitionOffsets(). They are always called consecutively, and the reader has to jump into prepareBuffers() from the main logic to check what it does, because it's rather a very generic description. Merging it into calculatePartitionOffsets() would be easier for the reader, because "calculatePartitionOffsets" is self-explanatory.
| rawEndPartitionOffsets[i] = offset; | ||
| } | ||
| endPartitionOffsets_->setSize(numPartitions * sizeof(vector_size_t)); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where did you set beginPartitionOffsets_?
| } | ||
|
|
||
| void calculatePartitionOffsets(int32_t numPartitions) { | ||
| std::vector partitionRowCounts(numPartitions, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The local partitionRowCounts vector is not needed. We can do the calculation in place in endPartitionOffsets_.
| vector_size_t offset = 0; | ||
| for (int32_t i = 0; i < numPartitions; ++i) { | ||
| offset += partitionRowCounts[i]; | ||
| rawEndPartitionOffsets[i] = offset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge line 127 and 128 into one line.
| types.reserve(numColumns); | ||
|
|
||
| for (int i = 0; i < numColumns; ++i) { | ||
| types.push_back(typeSelection[i % typeSelection.size()]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This causes repeating patterns that optimize caching.
Better shuffle types once.
| BufferPtr topRowOffsets_; | ||
| BufferPtr beginPartitionOffsets_; | ||
| BufferPtr endPartitionOffsets_; | ||
| BufferPtr swappingBuffer_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never allocated or sized before use.
| folly::runBenchmarks(); | ||
| bm.reset(); | ||
| return 0; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add the run output as a comment at the end of the file?
No description provided.