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

Improve String Last/First Storage Efficiency #12879

Merged
merged 1 commit into from
Sep 7, 2022

Conversation

rash67
Copy link
Contributor

@rash67 rash67 commented Aug 8, 2022

Description

This PR should serve as a simple example of how to do entire column storage
which uses delta encoding as well as block compression (default LZ4).

Discussion:
This implementation was designed and discussed with @cheddar offline.

Details

-Add classes for writing cell values in LZ4 block compressed format.
Payloads are indexed by element number for efficient random lookup
-update SerializablePairLongStringComplexMetricSerde to use block
compression
-SerializablePairLongStringComplexMetricSerde also uses delta encoding
of the Long by doing 2-pass encoding: buffers first to find min/max
numbers and delta-encodes as integers if possible

Entry points for doing block-compressed storage of byte[] payloads
are the CellWriter and CellReader class. See
SerializablePairLongStringComplexMetricSerde for how these are used
along with how to do full column-based storage (delta encoding here)
which includes 2-pass encoding to compute a column header

Key changed/added classes in this PR
  • CellReader
  • CellWriter
  • SerializablePairLongStringComplexMetricSerde
  • SerializablePairLongStringColumnSerializer
  • SerializablePairLongStringComplexColumn

Storage Efficiency Improvement Measurement

The following shows a comparison of before and after on the simple
wikipedia edits dataset. The entire size went from 2.65mb to 2.25mb.

druid-screenshot

However, for the affected column, lastUser, the storage went from
730k to 330k which is about a 55% reduction in size. The overall size
did not change as much as the dominant column was page, which is not affected.

See commands to view each column's size:

Current implementation:
master u=!druid/distribution/target/apache-druid-0.24.0-SNAPSHOT/var/druid/segment-cache/wikipedia_old_format/2016-06-27T00:00:00.000Z_2016-06-28T00:00:00.000Z/2022-08-03T18:47:50.431Z/0> cat meta.smoosh | tail +2 | tr ',' ' ' | awk '{print $1,$4-$3}' | sort -rn -k2
page 1368012
last_user 731794
channel 54074
cityName 48640
sum_delta 48405

after this PR's changes
byte-storage-and-string-agg-use!druid/distribution/target/apache-druid-0.24.0-SNAPSHOT/var/druid/segment-cache/wikipedia_new_format/2016-06-27T00:00:00.000Z_2016-06-28T00:00:00.000Z/2022-08-03T19:08:23.690Z/0 *> cat meta.smoosh | tail +2 | tr ',' ' ' | awk '{print $1,$4-$3}' | sort -rn -k2
page 1368012
last_user 331024
channel 54074
cityName 48640
sum_delta 48405


This PR has:

  • [ X] been self-reviewed.
  • [ X] added documentation for new or modified features or behaviors.
  • [ X] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • [ X] added or updated version, license, or notice information in licenses.yaml
  • [ X] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • [ X] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • [ X] been tested in a test Druid cluster.

@rash67 rash67 force-pushed the byte-storage-and-string-agg-use branch 9 times, most recently from a2462d4 to bd68d14 Compare August 10, 2022 19:58
@@ -0,0 +1,44 @@
/*
Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, did not mean to add this file. I'll remove before finalizing the PR

@rash67 rash67 force-pushed the byte-storage-and-string-agg-use branch 3 times, most recently from 63b8767 to edf5c10 Compare September 2, 2022 01:42
-Add classes for writing cell values in LZ4 block compressed format.
Payloads are indexed by element number for efficient random lookup
-update SerializablePairLongStringComplexMetricSerde to use block
compression
-SerializablePairLongStringComplexMetricSerde also uses delta encoding
of the Long by doing 2-pass encoding: buffers first to find min/max
numbers and delta-encodes as integers if possible

Entry points for doing block-compressed storage of byte[] payloads
are the CellWriter and CellReader class. See
SerializablePairLongStringComplexMetricSerde for how these are used
along with how to do full column-based storage (delta encoding here)
which includes 2-pass encoding to compute a column header
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants