Skip to content

phar: use crc32 bulk method instead. #6099

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

Merged
merged 2 commits into from
Jun 19, 2021
Merged

Conversation

frankdjx
Copy link
Contributor

@frankdjx frankdjx commented Sep 9, 2020

Benefit from the hardware crc32 computing.

Signed-off-by: Frank Du frank.du@intel.com

@frankdjx frankdjx force-pushed the phar_crc32 branch 2 times, most recently from e7225f8 to 6324ba0 Compare September 14, 2020 01:00
@frankdjx
Copy link
Contributor Author

@weltling Hi, could you help to review this also? Some phar code are using CRC32 macro which can do on;y one char computing based on lookup table, this commit change them to use a new bulk method which can benefit from the SIMD crc32. The SIMD computing is available on both x86 and arm platforms.

@mvorisek
Copy link
Contributor

mvorisek commented Jun 2, 2021

What is the performance impact?

@frankdjx
Copy link
Contributor Author

frankdjx commented Jun 3, 2021

What is the performance impact?

I don't have one benchmark for it. But it should expect similar speed up as shown in #6018

Copy link
Contributor

@weltling weltling left a comment

Choose a reason for hiding this comment

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

@jianxind thanks a lot for the patch, and looks like i completely overslept your ping. I'm also reviving an RP4 to do some test on ARM, should be able to finish this weekend.

There are some minor nits from my side, otherwise LGTM. Could you also rebase please, after you've checked?

Thanks!

@weltling weltling self-requested a review June 7, 2021 11:50
@ramsey ramsey added this to the PHP 8.1 milestone Jun 9, 2021
Benefit from the hardware crc32 computing.

Signed-off-by: Frank Du <frank.du@intel.com>
Signed-off-by: Frank Du <frank.du@intel.com>
for (loc = 0;loc < mytime; ++loc) {
CRC32(newcrc32, php_stream_getc(file));
}
crc32_stream_bulk_update(&newcrc32, file, entry->uncompressed_filesize);
entry->crc32 = ~newcrc32;
Copy link
Contributor Author

@frankdjx frankdjx Jun 17, 2021

Choose a reason for hiding this comment

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

Seems we don't need check the return as it just generate a crc value here.

Copy link
Contributor

Choose a reason for hiding this comment

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

This might be another plus to return the processed length and compare with uncompressed_filesize for a better security. Otherwise might make sense to (void) to silence possible static analyzer warnings.

thanks.

for (loc = 0;loc < entry->uncompressed_filesize; ++loc) {
CRC32(newcrc32, php_stream_getc(efp));
}
crc32_stream_bulk_update(&newcrc32, efp, entry->uncompressed_filesize);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same here.

*crc = crc32_bulk_update(*crc, buf, n);
handled += n;
} else { /* EOF */
return FAILURE;
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT EOF might be not directly an error, since it loops and EOL might be delivered not in the first iteration. Probably ok if it's only about local files, but stream can be anything (also remote). Perhaps it's better to return handled or EOF. Anyway this does the job and we don't export.

Thanks!

Copy link
Contributor

@weltling weltling left a comment

Choose a reason for hiding this comment

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

LGTM

@weltling weltling merged commit 28a1a6b into php:master Jun 19, 2021
@frankdjx frankdjx deleted the phar_crc32 branch June 21, 2021 00:28
@frankdjx
Copy link
Contributor Author

Thanks.

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.

4 participants