Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Speed up large group by (top k) queries#15

Open
mtanski wants to merge 1 commit intogoogle:masterfrom
mtanski:upstream_hash_groupby_speedup
Open

Speed up large group by (top k) queries#15
mtanski wants to merge 1 commit intogoogle:masterfrom
mtanski:upstream_hash_groupby_speedup

Conversation

@mtanski
Copy link
Copy Markdown

@mtanski mtanski commented May 29, 2015

Doing groupby string column (domains in reverse order) is one of our worse
performingqueries we have. Mostly because we're grouping by 10s and 100s
thousands of unique values. I've been trying to make this perform better for
a long time. We got a nice but small speedup (5%) before by using CityHash64.

After spending more time with perf, it looked like of the if condition branches
was always taking a lot of time. For some reason it kept getting miss
predicted. It was a simple boolean condition.

On very large groupby (100,000 elements) this improves execution time by 5% to
10%. No observable regression to small inputs once the hash size check was
introduced.

Doing groupby string column (domains in reverse order) is one of our worse
performingqueries we have. Mostly because we're grouping by 10s and 100s
thousands of unique values. I've been trying to make this perform better for
a long time. We got a nice but small speedup (5%) before by using CityHash64.

After spending more time with perf, it looked like of the if condition branches
was always taking a lot of time. For some reason it kept getting miss
predicted. It was a simple boolean condition.

On very large groupby (100,000 elements) this improves execution time by 5% to
10%. No observable regression to small inputs once the hash size check was
introduced.
@mtanski
Copy link
Copy Markdown
Author

mtanski commented May 29, 2015

It wouldn't hurt to use CityHash64 too. It's faster then the included Murmurhash64 about a net %5 shaved of our large group by queries with no other regressions. Works well for both large and small strings.

Also tried FarmHash but it performed noticeably worse for short strings (like domains) then CityHash.

@mtanski
Copy link
Copy Markdown
Author

mtanski commented Jun 1, 2015

Actually, I'm seeing the small integer group by case (~ 250 values) get faster on a large number of runs by like 1.2%.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite all the other work (CityHash), LRU buckets, moving the HASH_COMP_ONLY branch out (template arg). The end of the linked list check is the largest time sink. Not sure what we can do about this branch.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant