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

Compression: support FOR & replace Delta with DeltaFOR #8983

Merged
merged 16 commits into from
May 8, 2024

Conversation

Lloyd-Pottiger
Copy link
Contributor

@Lloyd-Pottiger Lloyd-Pottiger commented Apr 24, 2024

What problem does this PR solve?

Issue Number: ref #8982

Problem Summary:

What is changed and how it works?

FOR: https://dbms-arch.fandom.com/wiki/Frame_of_Reference_(Compression_Scheme)

Delta is not a compression algorithm, but Delta + FOR be.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Apr 24, 2024
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Apr 25, 2024
@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 25, 2024
@Lloyd-Pottiger Lloyd-Pottiger changed the title Compression: replace Delta with DeltaPFor Compression: replace Delta with DeltaFor Apr 26, 2024
Copy link
Member

@CalvinNeo CalvinNeo left a comment

Choose a reason for hiding this comment

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

lgtm

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Apr 26, 2024
@Lloyd-Pottiger Lloyd-Pottiger force-pushed the delta-pfor branch 2 times, most recently from 3545c0d to 6e0840d Compare April 28, 2024 02:20
@Lloyd-Pottiger Lloyd-Pottiger changed the title Compression: replace Delta with DeltaFor Compression: support For & replace Delta with DeltaFor May 6, 2024
// store frame of reference
unalignedStore<T>(dest, frame_of_reference);
dest += sizeof(T);
if (frame_of_reference != 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

What if frame_of_reference is negative?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

T can only be an unsigned type, frame_of_reference can not be negative.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now we support signed types, but here is just an optimization, when frame_of_reference = 0, no need to do minus.

And for signed types, there is no need to consider overflow, because

int count = std::numeric_limits<int>::min();
count -= std::numeric_limits<int>::max();
count += std::numeric_limits<int>::max();
std::cout << count << "\n"; // equal to std::numeric_limits<int>::min()

Lloyd-Pottiger and others added 11 commits May 8, 2024 14:21
Signed-off-by: Lloyd-Pottiger <[email protected]>
Signed-off-by: Lloyd-Pottiger <[email protected]>
Signed-off-by: Lloyd-Pottiger <[email protected]>
Signed-off-by: Lloyd-Pottiger <[email protected]>
Signed-off-by: Lloyd-Pottiger <[email protected]>
Signed-off-by: Lloyd-Pottiger <[email protected]>
Signed-off-by: Lloyd-Pottiger <[email protected]>
Signed-off-by: Lloyd-Pottiger <[email protected]>
Signed-off-by: Lloyd-Pottiger <[email protected]>
@JaySon-Huang
Copy link
Contributor

/hold

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 8, 2024
Comment on lines 126 to 129
for (; i < misaligned_count; ++i)
{
dst[i] += frame_of_reference;
}
Copy link
Contributor

@JaySon-Huang JaySon-Huang May 8, 2024

Choose a reason for hiding this comment

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

I think doing this for loop after the for (; i < count; i += (sizeof(__m256i) / sizeof(T))) can bring better performance. Because we can assume the memory address of dst + 0 should be aligned with the cache line, but it is not always aligned when it starts with dst + misaligned_count

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, fixed.

Signed-off-by: Lloyd-Pottiger <[email protected]>
Signed-off-by: Lloyd-Pottiger <[email protected]>
Signed-off-by: Lloyd-Pottiger <[email protected]>
Copy link
Contributor

@JaySon-Huang JaySon-Huang left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

ti-chi-bot bot commented May 8, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CalvinNeo, JaySon-Huang, JinheLin

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [CalvinNeo,JaySon-Huang,JinheLin]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Lloyd-Pottiger
Copy link
Contributor Author

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 8, 2024
@ti-chi-bot ti-chi-bot bot merged commit 2251037 into pingcap:master May 8, 2024
4 of 5 checks passed
@Lloyd-Pottiger Lloyd-Pottiger deleted the delta-pfor branch May 8, 2024 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants