-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Internal #330: Quantile Performance #9461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add Python implementation of skip lists to libraries.
Convert basic scalar quantile window to use skip lists. Performance on 1e9 rows, single partition, 16 cores went from 11:11 to 00:36.
Convert scalar and list windowed quantile to use skip lists. Performance on 1e9 rows, single partition, 16 cores went from 11:11 to 00:36.
Create MST template for use in quantile and other aggregates.
* Define QuantileSortTree for quantile acceleration. * Add aggregate_wininit_t for constructing global windowing state. * Update aggregate_window_t to take optional global windowing state. * Add quantile WindowInit function (not used yet).
Call window initialisation if it is defined.
Switch quantile computations to use merge sort trees. MAD not converted yet.
Fix double decrement.
Add MIT License.
Toggle 32/64 bit versions.
Refactor, simplify and deploy to Median Absolute Deviation.
Plumb through statistics and extract min/max for ROWS.
Use frame expression statistics to choose between Skip Lists and Merge Sort Trees
Test statistics and handle no propagation situation.
Fix fanout misplacement.
Finish implementing and testing merge sort trees by supporting EXCLUDE/multiple frames.
Fix CI issues (formatting, includes)
Remove non-portable #pragma mark lines.
Standardise SubFrame typing.
Push subframes into the Merge Sort Tree.
The merge sort tree code is Adrian's but I modified it so we could compile it and we collaborated on adding the The skip list code is a direct import of the code used by Python (it is a separate project). I just added a very simple one element memory pool (pooling is on their TODO list.) and you can look at the diff there (just routing new and delete through an internal class.) |
Integrate Tania' feedback (thanks!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool results, I only took a look at the skiplist library, minor comments
Incorporate Carlo's review (thanks!)
Fix signed/unsigned portability issue and extra include.
Revert single-bit prng use as it trashes performance by 2x.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Some minor comments. I also launched a NightlyTests to check the code coverage on this feature. Perhaps some more tests could be added after that to ensure the new code is fully tested? I'm not sure how many tests we have that correctly test all of the edge cases here.
Yeah there is coverage in the benchmark suite but I could certainly move those queries into a |
Clean them up in response to PR feedback. Note that ListWindow is being naughty and modifying the partition data, which is not thread-safe.
Restore the statistics API to use signed values. Add coverage tests for quantile variants.
Thanks! LGTM |
Merge pull request duckdb/duckdb#9392 from lnkuiper/parquet_encryption Merge pull request duckdb/duckdb#9461 from hawkfish/merge-sort-trees Merge pull request duckdb/duckdb#8788 from alnkesq/capi_create_enum_type Merge pull request duckdb/duckdb#9513 from Tmonster/5614-database-invalidated Merge pull request duckdb/duckdb#9622 from Mytherin/typescoping Merge pull request duckdb/duckdb#9615 from hawkfish/strptime-infinity Merge pull request duckdb/duckdb#9627 from Mytherin/attachifnotexists Merge pull request duckdb/duckdb#9648 from samansmink/add-keep-alive-toggle Merge pull request duckdb/duckdb#9638 from taniabogatsch/bench-refactor Merge pull request duckdb/duckdb#9651 from Mytherin/getenv
Rewrite of moving
quantile
andmad
to use better/faster data structures.window_init
aggregate API to allow custom window functions to create global data structuresSelectNth
method to handle newEXCLUDE
functionalityValidityMask::Resize
where it was always allocating memory instead of deferring if all rows were validfixes: duckdblabs/duckdb-internal#330