Repository navigation
ARROW-17824: [C++][Gandiva] Implement preallocation for variable length output buffer - #14230
Conversation
|
|
|
I've tested the performance with a newly added benchmark TimedTestOutputStringAllocs. |
b42d3d1 to
c82be89
Compare
c82be89 to
79a62fb
Compare
There was a problem hiding this comment.
Could you use the target expression directly with ASSERT_OK() to get better failure message?
| auto status = TimedEvaluate<arrow::StringType, std::string>( | |
| schema, evaluator, data_generator, pool_, 1 * MILLION, 16 * THOUSAND, state); | |
| ASSERT_OK(status); | |
| ASSERT_OK(TimedEvaluate<arrow::StringType, std::string>( | |
| schema, evaluator, data_generator, pool_, 1 * MILLION, 16 * THOUSAND, state)); |
There was a problem hiding this comment.
I tried this but it doesn't compile.
/home/jinshang/arrow/cpp/src/gandiva/tests/micro_benchmarks.cc:312:138: error: macro "ASSERT_OK" passed 2 arguments, but takes just 1
312 | ASSERT_OK(TimedEvaluate<arrow::StringType, std::string>(schema, evaluator, data_generator, pool_, 100 * THOUSAND, 16 * THOUSAND, state));
| ^
In file included from /home/jinshang/arrow/cpp/src/gandiva/tests/micro_benchmarks.cc:21:
/home/jinshang/arrow/cpp/src/arrow/testing/gtest_util.h:87: note: macro "ASSERT_OK" defined here
87 | #define ASSERT_OK(expr) \
|
/home/jinshang/arrow/cpp/src/gandiva/tests/micro_benchmarks.cc: In function ‘void gandiva::TimedTestMultiOr(benchmark::State&)’:
/home/jinshang/arrow/cpp/src/gandiva/tests/micro_benchmarks.cc:312:3: error: ‘ASSERT_OK’ was not declared in this scope
312 | ASSERT_OK(TimedEvaluate<arrow::StringType, std::string>(schema, evaluator, data_generator, pool_, 100 * THOUSAND, 16 * THOUSAND, state));
Seems to be linked to this: https://stackoverflow.com/questions/32241581/c-preprocessors-are-not-aware-of-template-arguments
So I wrapped an additional pair of parentheses and it works now.
6caaeab to
77527c6
Compare
|
Thanks! |
|
Benchmark runs are scheduled for baseline = b76ddf1 and contender = cc76736. cc76736 is a master commit associated with this PR. Results will be available as each benchmark for each run completes. |
…th output buffer (apache#14230) When the output type of an expression is of variable length, e.g. string, Gandiva would realloc the output buffer to make space for new outputs for each row. When num of rows is high some memory allocators perform poorly. We can use the std::vector like approach to amortize the allcation cost. First allocate some initial space depending on the input size. Each time we run out of space, double the buffer size. In the end shrink it to fit the actual size. Arrow string builder also uses this approach. Authored-by: Jin Shang <[email protected]> Signed-off-by: Sutou Kouhei <[email protected]>
When the output type of an expression is of variable length, e.g. string, Gandiva would realloc the output buffer to make space for new outputs for each row. When num of rows is high some memory allocators perform poorly.
We can use the std::vector like approach to amortize the allcation cost. First allocate some initial space depending on the input size. Each time we run out of space, double the buffer size. In the end shrink it to fit the actual size. Arrow string builder also uses this approach.