Add stats estimation accuracy to benchmarks#556
Conversation
ada6559 to
53809fb
Compare
| #[structopt(long = "broadcast-joins")] | ||
| broadcast_joins: bool, | ||
|
|
||
| /// Collects metrics across network boundaries |
There was a problem hiding this comment.
Now these two are always enabled. I don't think we want them disabled at any moment, as they are pretty stable now.
There was a problem hiding this comment.
Unless tomorrow we want to follow Spark example and have a global AQE knob to turn it off, at that point we can avoid the overhead as there is no consumer. But we can probably do this later
There was a problem hiding this comment.
We would probably have the same effect by not inserting SampleExec nodes, so it's probably enough to do that tomorrow to disable AQE
53809fb to
050416b
Compare
050416b to
aac68dd
Compare
| let _ = plan.apply(|node| { | ||
| if let Some(boundary) = node.as_network_boundary() | ||
| && let Stage::Local(input_stage) = boundary.input_stage() | ||
| && let Some(sampled_bytes) = metric_total(&input_stage.metrics_set, "sampled_bytes") |
There was a problem hiding this comment.
I think bytes will be the dominating factor in most cases, but we estimate row count too, I am OK to start with bytes only but if we see that this doesn't correlate with performance benchmarks, we might need to track row counts similarly.
Similarly for median, it's more stable than avg, and I think it's what we need to track, but we might need to add other percentile values possibly if we see that median is not enough.
There was a problem hiding this comment.
I think bytes will be the dominating factor in most cases, but we estimate row count too
Yeah, in fact, for future optimizations, rows will start being relevant, as that's what DF optimizer uses for several things.
As today we don't do those optimizations dynamically, and we just care about bytes for sizing the stages, bytes is the only thing that actually use.
When we start doing the other optimizations, I think we should start taking into account output rows as well.
71c347f to
e7ee621
Compare
| Ok(TreeNodeRecursion::Continue) | ||
| }); | ||
|
|
||
| median(boundary_q_errors) |
There was a problem hiding this comment.
@asolimando I'm not sure if median is the best here... it has the chance of swallowing very bad estimations in cases there are enough straight-forward stages in the plan to even that out.
I'm thinking that avg might be a bit better. WDYT?
There was a problem hiding this comment.
I'm getting some more meaningful metrics with a mean rather than median here, I'm going to go for it.
There was a problem hiding this comment.
I briefly touched upon this here and I agree that median, being robust to outliers, will "absord" degenerate cases that might result in individual queries to fail.
Being robust to outliers is a good property for this type of measures, avg would suffer from the opposite problem, it won't provide a clear signal for the "regular" case and conflate the two behaviors.
To track also outliers we need to complement median with P90 or P95, exactly as https://vldb.org/pvldb/vol9/p204-leis.pdf does (look at Table 1 page 4 for an example).
Median will already provide a good signal for most cases but as we move forward and refine the approach we will surely need more to avoid regressions for extreme cases.
If that's easy enough to add now, it would be safer, if you don't feel like adding it now, we can wait and see if better q-error median values positively correlates with improvements in benchmark results, otherwise we need extra signals.
There was a problem hiding this comment.
🤔 this is a good call... it's not trivial to do, but it's worth it, because I'm seeing that P50 is swallowing pretty wild overestimation, just because there's a few stages that are trivial to estimate (because 100% of the data was sampled for example)
There was a problem hiding this comment.
Even if it's not super trivial, I'm going to go with P95 additionally, even if that will bloat a bit this PR.
There was a problem hiding this comment.
Done, P50 and P95 looking very good now, thanks for the suggestion!
82e6199 to
1610648
Compare
1610648 to
94eec9c
Compare
This PR enhances the benchmarks by comparing estimated bytes vs actual bytes in network boundaries during dynamic planninng:
QERR P50) in benchmark comparisons.Preliminary step for #552.
Sample output: