[GLUTEN-10892][VL] Use veloxPreferredBatchBytes to control the max size of memory of batches combined#11140
Conversation
97d8201 to
dbe19ba
Compare
|
Could you add a new configuration for |
Sure. Thanks for your advice. |
dbe19ba to
18bb790
Compare
98e47b9 to
0e1128b
Compare
| @@ -680,6 +682,15 @@ object VeloxConfig extends ConfigRegistry { | |||
| .bytesConf(ByteUnit.BYTE) | |||
| .createWithDefaultString("10MB") | |||
|
|
|||
| val ENABLE_LIMIT_BATCH_RESIZER = { | |||
There was a problem hiding this comment.
This can be a default behavior, please remove this config, all the operator should respect preferredBatchBytes
| @@ -60,7 +60,7 @@ Arguments: false | |||
|
|
|||
| (7) VeloxResizeBatches | |||
| Input [18]: [hash_partition_key#X, l_returnflag#X, l_linestatus#X, sum#X, isEmpty#X, sum#X, isEmpty#X, sum#X, isEmpty#X, sum#X, isEmpty#X, sum#X, count#X, sum#X, count#X, sum#X, count#X, count#X] | |||
| Arguments: X, X | |||
| Arguments: X, X, 10485760 | |||
There was a problem hiding this comment.
Please change it to X, we don't need to update it if we change the default value in the future
| plan.transformUp { | ||
| case shuffle: ColumnarShuffleExchangeExec | ||
| if resizeBatchesShuffleInputEnabled && | ||
| shuffle.shuffleWriterType.requiresResizingShuffleInput => | ||
| val appendBatches = | ||
| VeloxResizeBatchesExec(shuffle.child, range.min, range.max) | ||
| VeloxResizeBatchesExec(shuffle.child, range.min, range.max, memoryThreshold) |
There was a problem hiding this comment.
Please use the original config name preferredBatchBytes instead of a new name
| @@ -78,22 +80,43 @@ std::shared_ptr<ColumnarBatch> VeloxBatchResizer::next() { | |||
| if (cb->numRows() < minOutputBatchSize_) { | |||
There was a problem hiding this comment.
Please use cb->numBytes() to estimate the batch size, and update the numBytes(), get the numBytes does not need to flat the vector, just load the vector
This reverts commit 18bb790f472970a72af30a7db4f221c03779d25c.
0e1128b to
30fca1d
Compare
| @@ -78,22 +80,41 @@ std::shared_ptr<ColumnarBatch> VeloxBatchResizer::next() { | |||
| if (cb->numRows() < minOutputBatchSize_) { | |||
| auto vb = VeloxColumnarBatch::from(pool_, cb); | |||
| auto rv = vb->getRowVector(); | |||
| auto vector = std::static_pointer_cast<facebook::velox::BaseVector>(rv); | |||
There was a problem hiding this comment.
I don't see the vector usage
| auto nextRv = nextVb->getRowVector(); | ||
| if (buffer->size() + nextRv->size() > maxOutputBatchSize_) { | ||
| // Call reset manully to potentially release memory | ||
| vector.reset(); |
There was a problem hiding this comment.
L114 is enough, you reuse the variables in following for loop or release in the end
There was a problem hiding this comment.
And also remove following rv batch.reset
There was a problem hiding this comment.
I remove the four lines of code here.
| @@ -78,22 +80,41 @@ std::shared_ptr<ColumnarBatch> VeloxBatchResizer::next() { | |||
| if (cb->numRows() < minOutputBatchSize_) { | |||
| auto vb = VeloxColumnarBatch::from(pool_, cb); | |||
| auto rv = vb->getRowVector(); | |||
| auto vector = std::static_pointer_cast<facebook::velox::BaseVector>(rv); | |||
| uint64_t numBytes = cb->numBytes(); | |||
There was a problem hiding this comment.
Update here to only load the lazy vector, we don't need to flat dictionary vector https://github.com/apache/incubator-gluten/blob/7d491d5b373f77a3aa9a1bad14c34acb8987cfb5/cpp/velox/memory/VeloxColumnarBatch.cc#L82
There was a problem hiding this comment.
I get it. Thanks!
| @@ -73,6 +73,7 @@ abstract class VeloxTPCHSuite extends VeloxTPCHTableSupport { | |||
| // for unexpected blank | |||
| .replaceAll("Scan parquet ", "Scan parquet") | |||
| // Spark QueryStageExec will take it's id as argument, replace it with X | |||
| .replaceAll("Arguments: [0-9]+, [0-9]+, [0-9]+", "Arguments: X, X") | |||
| auto nextRv = nextVb->getRowVector(); | ||
| if (buffer->size() + nextRv->size() > maxOutputBatchSize_) { | ||
| // Call reset manully to potentially release memory | ||
| vector.reset(); |
There was a problem hiding this comment.
And also remove following rv batch.reset
390136d to
0f04ea4
Compare
| @@ -78,22 +80,34 @@ std::shared_ptr<ColumnarBatch> VeloxBatchResizer::next() { | |||
| if (cb->numRows() < minOutputBatchSize_) { | |||
| auto vb = VeloxColumnarBatch::from(pool_, cb); | |||
| auto rv = vb->getRowVector(); | |||
| uint64_t numBytes = cb->numBytes(); | |||
There was a problem hiding this comment.
Move the check with L80 if (cb->numRows() < minOutputBatchSize_ && numBytes <= preferredBatchBytes_)
There was a problem hiding this comment.
Done. Thanks
0f04ea4 to
4299d0c
Compare
4299d0c to
532faa7
Compare
|
Thanks! |
What changes are proposed in this pull request?
Now the operator
VeloxBatchResizercan use as many memory as possible, which can cause OOM. So this PR use the existing configspark.gluten.sql.columnar.backend.velox.preferredBatchBytesto control it.Closes #10892
How was this patch tested?
Inner ETL jobs.