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

[C++] Support arm64 optimized CRC32c hardware-instructions #13246

Merged
merged 9 commits into from
Dec 12, 2021

Conversation

Demogorgon314
Copy link
Member

Motivation

Add arm64 optimized crc32c instructions support to optimize arm64 performance.

Modifications

Add arm64 optimized crc32c instructions support.

Verifying this change

  • Use arm64 compile to verify.

Documentation

Need to update docs?

  • no-need-doc

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Dec 12, 2021
@Demogorgon314
Copy link
Member Author

Look like the https://maven.restlet.com secure certificate has expired, the dependency org.restlet.jee:org.restlet:jar:2.4.3 can't download now.

@Demogorgon314
Copy link
Member Author

Demogorgon314 commented Dec 12, 2021

Here is a simple benchmark for arm64 instructions optimized and software implementation.

TEST(ClientTest, testSwHwArmChecksumBench) {
    std::string data = "This is a simple benchmark for CRC32C hardware and software implementation.";
    int times = 100000;
    clock_t startTime,endTime;
    uint32_t hwArmChecksum;
    startTime = clock();
    for(int i = 0; i < times; i++) {
        hwArmChecksum = crc32cHwArm(0, (char *)data.c_str(), data.length());
    }
    endTime = clock();
    LOG_INFO("Crc32cHwArm run time is: " << endTime - startTime << " ms");
    uint32_t swChecksum;
    startTime = clock();
    for(int i = 0; i < times; i++) {
        swChecksum = crc32cSw(0, (char *)data.c_str(), data.length());
    }
    endTime = clock();
    LOG_INFO("Crc32cSw run time is: " << endTime - startTime << " ms");
}

Result:

2021-12-12 17:58:36.299 INFO  [0x10594c580] ClientTest:104 | Crc32cHwArm run time is: 563 ms
2021-12-12 17:58:36.303 INFO  [0x10594c580] ClientTest:111 | Crc32cSw run time is: 3840 ms

The arm64 hardware-instructions implementation is 6 times faster than the software implementation.

@Demogorgon314
Copy link
Member Author

/pulsarbot run-failure-checks

@merlimat merlimat added component/c++ type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages labels Dec 12, 2021
@merlimat merlimat added this to the 2.10.0 milestone Dec 12, 2021
@merlimat merlimat merged commit 38fb839 into apache:master Dec 12, 2021
@Demogorgon314 Demogorgon314 deleted the support-arm-crc32c branch December 13, 2021 07:11
fxbing pushed a commit to fxbing/pulsar that referenced this pull request Dec 19, 2021
)

* Add arm support

* Support arm crc32c

* Add crc32c sse4.2 disable warn log

* Fix x86 compile

* Add more test case

* Add license header

* Add license header

* Fix clang format

* Remove HAVE_ARM64_CRC warning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-not-needed Your PR changes do not impact docs type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants