Repository navigation
Enable dynamic evaluation of whether a short-circuit function's argument should be lazily executed - #73776
Enable dynamic evaluation of whether a short-circuit function's argument should be lazily executed#73776lgbo-ustc wants to merge 28 commits into
Conversation
2a7cd69 to
04e6b79
Compare
|
Performance test Use
|
|
Please fix the conflicts. |
0021b5b to
9e439b1
Compare
9e439b1 to
28175ea
Compare
Done |
78d4c14 to
1f4c842
Compare
48d5317 to
43997c1
Compare
39fefaa to
b7a3fc8
Compare
|
The
|
b8848ae to
98b2359
Compare
ecc8e6c to
af54d6e
Compare
4cfea9e to
a69fbca
Compare
|
@alexey-milovidov I think this PR is almost ready, could anyone review it? |
|
@lgbo-ustc This PR adds a lot of complex logic in central places. Before reviewing it, can you please explain the background and implementation in more detail? |
|
The short-circuit evaluation function can perform lazy evaluation on parameter expressions. While the original intention might have been to avoid exceptions caused by computing invalid data, lazy evaluation can also be used to improve computational performance. For example, in the expression Where Therefore, we generally do not enable short-circuit evaluation for performance improvement. This PR aims to enhance short-circuit evaluation so that it can automatically determine whether an expression is worth evaluating lazily. To achieve this, we have made the following modifications. During runtime, we collect statistics for each necessary function, including its execution time(denoted as ColumnPtr execute(const ColumnsWithTypeAndName & arguments,
const DataTypePtr & result_type,
size_t input_rows_count,
bool dry_run,
FunctionExecutionProfile * profile = nullptr) const;Three shor-circuit functions( Based on the above statistics, we use the following method to determine whether to apply lazy evaluation to an expression. If the above condition is false, it is deemed not worthwhile to apply lazy evaluation to the expression. Otherwise, lazy evaluation should be applied. This is done in |
|
Dear @SmitaRKulkarni, this PR hasn't been updated for a while. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
|
Dear @SmitaRKulkarni, this PR hasn't been updated for a while. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
|
@lgbo-ustc : Sorry for the delay. I will review this PR. Looks like we have lot of conflicts, could you please resolve them ? |
|
🕵 @SmitaRKulkarni @lgbo-ustc — I rebased this branch onto the current The branch was ~17 months behind and 27 files conflicted, so it is more than a mechanical merge. The author's commits are preserved; the notable changes on top of them:
Verified locally: This PR is left open — please decide whether to continue here (the branch is in a fork with maintainer edits disabled, so I could not push the resolution to it) or to review the rebased one. |
|
🕵 Superseded by #114734, which rebases and reworks this change on the current |



Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Lazy execution in short-circuit evaluation is not entirely cost-free. The
maskedExecutemethod incurs additional overhead for filtering and expanding columns. In certain scenarios, this overhead can exceed the cost of fully evaluating the expression.In this PR, we have added runtime performance profiling for functions. Based on the collected runtime performance data, we can evaluate the cost of using lazy evaluation versus direct full computation for a function, and dynamically select the execution strategy with the lower cost.
Documentation entry for user-facing changes
CI Settings (Only check the boxes if you know what you are doing):