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

Enhance optimizeDictionary to optionally optimize var-width type cols #13994

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

itschrispeck
Copy link
Collaborator

@itschrispeck itschrispeck commented Sep 13, 2024

Changes

  • Add noDictionaryCardinalityRatioThreshold config.
    • If populated, and optimizeDictionary is true, then Pinot will override dictionary encoding with raw encoding based on the condition cardinality / numDocs > noDictionaryCardinalityRatioThreshold.
    • If the new config is omitted, optimizeDictionary behavior is unchanged

Motivation

When storing log data, often columns will contain many repeated values. It's useful to take advantage of Pinot's dictionary encoding which usually provides better storage/query performance for these columns. Dictionary encoding high cardinality columns is cost/storage prohibitive, so we'd like to avoid applying dictionary encoding unless it is safe. Since column cardinality/values can change rapidly we'd like to make these decisions within Pinot itself.

In our experience, cardinality is a good indicator of whether to dictionary or raw encode a col. With a 0.10 threshold (10%), we see roughly 40-60% improvement in storage compared to raw encoding everything.

@codecov-commenter
Copy link

codecov-commenter commented Sep 13, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 65.09%. Comparing base (59551e4) to head (e9259ea).
Report is 1069 commits behind head on master.

Files with missing lines Patch % Lines
...ot/segment/spi/creator/SegmentGeneratorConfig.java 25.00% 3 Missing ⚠️
.../segment/index/dictionary/DictionaryIndexType.java 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #13994      +/-   ##
============================================
+ Coverage     61.75%   65.09%   +3.34%     
- Complexity      207     1533    +1326     
============================================
  Files          2436     2564     +128     
  Lines        133233   140778    +7545     
  Branches      20636    21611     +975     
============================================
+ Hits          82274    91645    +9371     
+ Misses        44911    42388    -2523     
- Partials       6048     6745     +697     
Flag Coverage Δ
custom-integration1 100.00% <ø> (+99.99%) ⬆️
integration 100.00% <ø> (+99.99%) ⬆️
integration1 100.00% <ø> (+99.99%) ⬆️
integration2 0.00% <ø> (ø)
java-11 65.02% <80.00%> (+3.31%) ⬆️
java-21 64.96% <80.00%> (+3.33%) ⬆️
skip-bytebuffers-false 65.09% <80.00%> (+3.35%) ⬆️
skip-bytebuffers-true 64.87% <80.00%> (+37.14%) ⬆️
temurin 65.09% <80.00%> (+3.34%) ⬆️
unittests 65.09% <80.00%> (+3.34%) ⬆️
unittests1 56.53% <55.00%> (+9.64%) ⬆️
unittests2 35.07% <65.00%> (+7.34%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@itschrispeck itschrispeck marked this pull request as draft September 13, 2024 01:21
@itschrispeck itschrispeck marked this pull request as ready for review September 13, 2024 18:26
Copy link
Contributor

@SabrinaZhaozyf SabrinaZhaozyf left a comment

Choose a reason for hiding this comment

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

Thanks for adding this heuristic!

Overall lgtm, can we add a test case/example where noDictionarySizeRatioThreshold is used for fixed length when both thresholds are specified?

@Jackie-Jiang Jackie-Jiang added the Configuration Config changes (addition/deletion/change in behavior) label Sep 18, 2024
@@ -293,8 +293,9 @@ private boolean createDictionaryForColumn(ColumnIndexCreationInfo info, SegmentG

FieldIndexConfigs fieldIndexConfigs = config.getIndexConfigsByColName().get(column);
if (DictionaryIndexType.ignoreDictionaryOverride(config.isOptimizeDictionary(),
config.isOptimizeDictionaryForMetrics(), config.getNoDictionarySizeRatioThreshold(), spec, fieldIndexConfigs,
info.getDistinctValueCount(), info.getTotalNumberOfEntries())) {
config.isOptimizeDictionaryForMetrics(), config.getNoDictionarySizeRatioThreshold(),
Copy link
Contributor

Choose a reason for hiding this comment

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

This list has become quite long. Suggest adding a new config class for dictionary tuning related configs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Configuration Config changes (addition/deletion/change in behavior) documentation enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants