-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Out-of-Core Hash Aggregate #7931
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
…in Agg HT partitioning
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! Looks great - and great performance results! Some comments:
| group_types, op.payload_types, op.bindings); | ||
| make_uniq<PartitionableHashTable>(context.client, BufferAllocator::Get(context.client), | ||
| *gstate.partition_info, group_types, op.payload_types, op.bindings); | ||
| if (context.client.config.force_external) { |
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.
Not directly related but can we perhaps rename this to verify_external in the codebase as well to prevent confusion?
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.
We already have a verify_external, which triggers the ExternalStatementVerifier, running the query once with and once without force_external. I can rename this to debug_force_external.
Edit: Actually on second though, both of these settings are already in line with other config options. I think this should stay as is. We have a verify_... and a force_... for testing external functionality, which is similar to other debug config options.
|
I don't think the failing test has anything to do with my changes. This fails on vector size 2, somehow strings become invalid: statement ok
CREATE VIEW strlists AS SELECT * FROM (VALUES
(1, ['a']),
(2, [NULL]),
(3, []),
(4, ['Branta Canadensis', 'c']),
(5, ['i','j','k']),
(NULL::INTEGER, ['Somateria mollissima'])
) lv(pk, p);
query II
SELECT * FROM strlists
----
NULL [Somateria mollissima]
1 [a]
2 [NULL]
3 []
4 [Branta Canadensis, c]
5 [i, j, k]Actual result: 1 [a]
2 [NULL]
3 []
4 [Branta Canadensis, c]
5 [i, j, Z]
NULL [ZZZZZZZZZZZZZZZZZZZZ]I will investigate, but maybe I can add a |
|
I have not seen this issue before in other PRs - perhaps you could investigate? |
|
I think this is ready to go! |
|
Thanks! LGTM |
This PR implements out-of-core functionality for our aggregate hash table.
This is done by abandoning hash tables when they reach a specific memory limit in
PartitionableHashTable::ListAddChunk, as well as repartitioning hash tables inRadixPartitionedHashTable::ScheduleTaskspartitions would otherwise not fit within the memory limit.This is a basic implementation, and I have many ideas to improve our hash aggregate, which I will implement in the coming weeks. For now, though, I wanted to send this PR with the out-of-core functionality so this PR is manageable.
This implementation also forces all aggregates that use an
Allocatorto useArenaAllocatorinstead. This means that aggregate states are never explicitly destroyed but are destroyed when theArenaAllocatorgoes out of scope. We already used theAllocatorwrapper for theArenaAllocator, so the aggregate states were usually not destroyed explicitly. Of course, we want to destroy/serialize the aggregate states for the out-of-core hash aggregate. I will address this at some point in the future, but I will focus on improving the hash aggregate (both in-memory and out-of-core) first.As always, I have a little benchmark! This is the query:
Where
'lineitem30.parquet'is the first 30M rows from TPC-Hlineitemat SF10. These are the results:Interestingly, the execution time decreases as the memory limit decreases. This is due to the out-of-core strategy creating more fine-grained partitions. This improves cache-locality, which explains the improved runtime.