mbutrovich commented on PR #27985: URL: https://github.com/apache/datafusion/pull/27985#issuecomment-7384033278
Item 8 is good evidence that pausing join filters that keep almost every row pays off. In q9, [three of the four dynamic filters on `lineitem` keep every row and cost 14% of CPU in `contain_hashes`](https://github.com/apache/datafusion/blob/7c78b7a572af2fcc448d982dbb056db63746f986/benchmarks/polars-gap/REPORT.md?plain=1#L100). The 1M-row and 90% parameters are a useful data point too. I think the way to land it is to get the adaptive predicate work in #22883 over the finish line. @adriangb's draft stack there covers the same case. The stack and its order are in https://github.com/apache/datafusion/issues/22883#issuecomment-5808424593. The gate in #25674 compares the measured cost of a filter with the probe work it saves, not only its pass rate. Skew is the property we need to get right there. Item 8 shows how it fails: - Every copy of the expression shares one counter ([`with_new_children`](https://github.com/apache/datafusion/blob/7c78b7a572af2fcc448d982dbb056db63746f986/datafusion/physical-plan/src/joins/hash_join/partitioned_hash_eval.rs#L675-L686)). All scan partitions and files add to it. At 16 partitions, 1M rows is about 62K rows per partition, which is the first few batches of each file. - [`record`](https://github.com/apache/datafusion/blob/7c78b7a572af2fcc448d982dbb056db63746f986/datafusion/physical-plan/src/joins/hash_join/partitioned_hash_eval.rs#L313-L325) compares the rows kept with the rows seen since the first batch. Take a filter on a clustered key that keeps 95% of the rows in the first row groups and 5% in the rest. It switches off at 1M rows. - Nothing clears `disabled` once it is set ([`evaluate`](https://github.com/apache/datafusion/blob/7c78b7a572af2fcc448d982dbb056db63746f986/datafusion/physical-plan/src/joins/hash_join/partitioned_hash_eval.rs#L697-L702)), so the filter is never checked again. #25674 avoids all three. Each stream has its own gate, and each decision uses a new window. A paused gate checks the filter again after a pause that doubles up to [32 batches](https://github.com/apache/datafusion/blob/87974dcdf98dfa042a67c229c97005238cef7992/datafusion/physical-expr/src/optional_filter_gate.rs#L198). @adriangb, I have one skew question about the [shared verdict](https://github.com/apache/datafusion/blob/87974dcdf98dfa042a67c229c97005238cef7992/datafusion/physical-expr/src/optional_filter_gate.rs#L124-L148). A new gate starts paused if another gate published a pause. A gate in a probe window also stops when another gate publishes a pause. Suppose most files of a scan don't match the filter and a few do, as with a clustered key. Could the gates of the few files keep getting cut short and never gather the evidence to keep the filter? If so, should a gate always finish its first window on its own data before it uses a shared pause? That brings back one window per file for each filter, which #25682 says the shared pauses removed in q9. @andygrove, could you run q9 with item 8 and with the stack's `datafusion.execution.optional_filter_mode = 'adaptive'`, and compare them? Hash join filters are optional only with #25681. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
