villebro commented on code in PR #2671: URL: https://github.com/apache/datafusion-ballista/pull/2671#discussion_r4391916002
########## ballista/core/src/hll.rs: ########## @@ -0,0 +1,219 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! HyperLogLog distinct-count sketch for shuffle output columns. +//! +//! Shuffle writers update one sketch per sketched column, executors ship the +//! registers to the scheduler in `TaskColumnStats.sketches`, and the scheduler +//! merges every task's sketch for a column into a stage-level distinct count. +//! +//! Values are hashed with DataFusion's `HLL_RANDOM_STATE`, the hash state +//! `approx_distinct` uses, and the count uses the same estimator (Ertl, +//! "New cardinality estimation algorithms for HyperLogLog sketches", 2017). +//! Precision is 12 rather than DataFusion's 14: 4 KiB of registers per +//! column per task instead of 16 KiB, for a standard error of about 1.6%, +//! which is plenty for join cardinality estimation. Review Comment: I don't disagree with 12 over 14 here, but it does pose the question, why not 10, or some other less memory intensive number? ########## docs/source/user-guide/configs.md: ########## @@ -152,6 +152,7 @@ explanation of the sort-based shuffle writer. <!-- prettier-ignore --> | key | type | default | description | | -------------------------------------------------------- | ------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| ballista.shuffle.collect_distinct_counts | Boolean | true | Sketch the approximate distinct count of each hash-partitioning key column with HyperLogLog while writing shuffle output, so the adaptive planner can estimate join cardinalities downstream of the shuffle. Costs hashing every key value on the write path and 4 KiB per key column in each task's status update. | Review Comment: Optional consideration: expose `ballista.shuffle.collect_distinct_counts_precision` that defaults to 12 for those that really want to fine tune their deployment? -- 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]
