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

Optimize non-strict equality check of binaries differing in size #1708

Merged
merged 1 commit into from
Feb 21, 2018

Conversation

philipstears
Copy link
Contributor

This commit brings the perform of a non-strict equality check of
binaries into the same range as strict ones.

Currently, these checks can be significantly slower because they go
through the general comparison code which doesn't have an optimization
to check the size before comparing contents in the case that it's
checking equality.

--

Hopefully I've got this right, there were two things that were unclear to me from the contribution guidelines.

Firstly, this isn't really a bug fix or an enhancement (in the way it's described), so I wasn't sure what the testing requirement is. In any case, I've run the complete test suite before and after the change and the results are the same either way.

Secondly, the whitespace in this file is unusual to me, it's a mixture of tabs and spaces on the same line - I've configured my editor locally according to the contribution guidelines (two spaces, no tabs), so of course this all aligns nicely in my editor, but not so much in a diff - naturally I'm happy to reformat if that's appropriate.

@CLAassistant
Copy link

CLAassistant commented Feb 6, 2018

CLA assistant check
All committers have signed the CLA.

@sverker sverker self-assigned this Feb 8, 2018
@sverker sverker added team:VM Assigned to OTP team VM enhancement labels Feb 8, 2018
@@ -3152,6 +3152,9 @@ Sint erts_cmp_compound(Eterm a, Eterm b, int exact, int eq_only)
int cmp;
byte* a_ptr;
byte* b_ptr;
if (eq_only && a_size != b_size) {
RETURN_NEQ(a_size - b_size);
}
Copy link
Contributor

@sverker sverker Feb 8, 2018

Choose a reason for hiding this comment

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

Thanks for trying, but I don't think you got the indentation right.
Tabs should be 8 spaces (if used).
Identation is usually 4 spaces, which it is in this code.

edit: removed my faulty statement about RETURN_NEQ

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. The indentation should now match the surrounding code (two 8-wide tabs, followed by blocks of 4 spaces).

This commit brings the perform of a non-strict equality check of
binaries into the same range as strict ones.

Currently, these checks can be significantly slower because they go
through the general comparison code which doesn't have an optimization
to check the size before comparing contents in the case that it's
checking equality.
@sverker sverker added the testing currently being tested, tag is used by OTP internal CI label Feb 8, 2018
@sverker sverker merged commit 1540a07 into erlang:master Feb 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants