Skip to content
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

More efficient ColumnChunk string dictionary caching #2994

Merged
merged 1 commit into from
Mar 5, 2024

Conversation

benjaminwinger
Copy link
Collaborator

@benjaminwinger benjaminwinger commented Mar 4, 2024

Something from #2979 when I was testing in-memory compression, as the original implementation of the DictionaryChunk's index performed poorly on that dataset (largely due to the size and number of the chunks in the partitioner magnifying the overhead of the dictionary's cache).

This changes the storage of the DictionaryChunk's indexTable to store just the index and use custom comparison and hashing functions instead of storing a second copy of the string. In addition to removing one extra copy of the string data, it reduces the memory overhead of the cache from 32 bytes per entry (sizeof(std::string), though this may also include the string data for short strings, so this change won't necessarily reduce memory by >=28 bytes per string in the dictionary) to just 4 bytes per entry (plus whatever overhead is required for std::unordered_set, but that hasn't really changed).

I did a few benchmarks, and when copying 60000000 strings with random numbers, performance improved from ~25s to ~16s for long strings (~20 characters long), and 12s to 10s for short strings (both should have no duplication, so this tests the worst case where all entries get added to the dictionary; the table has one string column with a serial primary key).

Copy link

codecov bot commented Mar 4, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 93.31%. Comparing base (1131621) to head (3415ff1).

Files Patch % Lines
src/include/storage/store/dictionary_chunk.h 75.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2994   +/-   ##
=======================================
  Coverage   93.31%   93.31%           
=======================================
  Files        1123     1124    +1     
  Lines       42892    42901    +9     
=======================================
+ Hits        40026    40035    +9     
  Misses       2866     2866           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@ray6080 ray6080 left a comment

Choose a reason for hiding this comment

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

LGTM.

@benjaminwinger benjaminwinger merged commit 93e6b3e into master Mar 5, 2024
15 checks passed
@benjaminwinger benjaminwinger deleted the string-column-chunk-index branch March 5, 2024 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants