Repository navigation
perf: Concretely typed TopK ArrowHashTable storage - #23609
Conversation
|
run benchmark topk_aggregate |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing concrete-topk-storage (8a7b678) to 95de385 (merge-base) diff using: topk_aggregate File an issue against this benchmark runner |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #23609 +/- ##
=======================================
Coverage 81.29% 81.29%
=======================================
Files 1110 1110
Lines 385336 385311 -25
Branches 385336 385311 -25
=======================================
- Hits 313261 313257 -4
+ Misses 53594 53569 -25
- Partials 18481 18485 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
🤖 Benchmark completed (GKE) | trigger Instance: CPU Details (lscpu)Details
Resource Usagetopk_aggregate — base (merge-base)
topk_aggregate — branch
File an issue against this benchmark runner |
|
Benchmarks look good -- I am running them once more to see if htey are reproducable |
|
run benchmark topk_aggregate |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing concrete-topk-storage (8a7b678) to 95de385 (merge-base) diff using: topk_aggregate File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Instance: CPU Details (lscpu)Details
Resource Usagetopk_aggregate — base (merge-base)
topk_aggregate — branch
File an issue against this benchmark runner |
|
🤔 These two seem to reproducibly get worse Can you look into that @MassivePizza ? |
|
Only getting noise locally. I don't think my changes should affect "no TopK" regardless. |
avoiding from(Vec) into drop.
|
run benchmark topk_aggregate |
Retriggered the benchmark, let's see if it can be reproduced |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing concrete-topk-storage (5e07c8d) to e8a65f2 (merge-base) diff using: topk_aggregate File an issue against this benchmark runner |
|
This is very nice @MassivePizza and @xudong963 and @jayzhan211 -- I think it is close. |
|
🤖 Benchmark completed (GKE) | trigger Instance: Comparing concrete-topk-storage (5e07c8d) to e8a65f2 (merge-base) diff Run configurationrun benchmark topk_aggregateCPU Details (lscpu)Details
Resource Usagetopk_aggregate — base (merge-base)
topk_aggregate — branch
File an issue against this benchmark runner |
|
This PR feels pretty solid on its own now.
|
|
run benchmark topk_aggregate |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing concrete-topk-storage (e5861d2) to 62650ef (merge-base) diff Run configurationrun benchmark topk_aggregateResults will be posted here when complete File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Instance: Comparing concrete-topk-storage (e5861d2) to 62650ef (merge-base) diff Run configurationrun benchmark topk_aggregateCPU Details (lscpu)Details
Resource Usagetopk_aggregate — base (merge-base)
topk_aggregate — branch
File an issue against this benchmark runner |
|
@MassivePizza can you resolve the clippy issue |
|
I just realized that the benches are extra flaky due to heavy multithreading, which seems to affect string aggregate the most. My M4 Mac throttles quite quickly on those, but I'm certain the StringArrayType change is not a regression otherwise. |
|
Is this one ready to merge? |
|
Sure thing. The mentioned PR is a follow-up. |
|
THanks for your review @alamb @jayzhan211 and thanks for your first contribution! |
This restores behavior from before apache#23609.
This restores behavior from before apache#23609.
apache#24105) ## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes apache#123` indicates that this PR will close issue apache#123. --> N/A. Continuation of apache#23609. ## Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> Improve perf of TopK. ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> Eliminate overhead of casting with `dyn Any` for every String in `topk::StringHeap`. Rearrange `HashTableItem<ID>` `Option`-ness to avoid unnecessary unwraps on lookups in `topk::TopKHashTable`. Rewrite inserts to take a borrowable type, delaying clones and allowing reuse of storage slots (mostly Strings). ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> Should be covered by existing tests. Making `ID` an `Option<ID>` inside `HashTableItem` should be fine, since the internal `HashTable` keeps track of valid items (although this could be hard to verify properly). It runs with the assumption that "if everything needed an unwrap, nothing needs an unwrap". ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> No. <!-- If there are any breaking changes to public APIs, please add the `api change` label. --> --------- Co-authored-by: kosiew <kosiew@gmail.com>
Which issue does this PR close?
N/A
Rationale for this change
Eliminate the overhead of casting with
dyn Anyfor every item inArrowHashTable.What changes are included in this PR?
Cast once per batch and store the typed array.
PrimitiveHashTables was already generic, so this was a big and simple win.
StringHashTable was made
to use an enum for consistency/readabilitygeneric for a miniscule perf improvement over enum.Are these changes tested?
Should be covered by existing tests.
For benching try
cargo bench -p datafusion --bench topk_aggregate -- "top k=10 aggregate".Are there any user-facing changes?
None.