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 string decoding #11

Merged
merged 5 commits into from Feb 22, 2021
Merged

optimize string decoding #11

merged 5 commits into from Feb 22, 2021

Conversation

wbpcode
Copy link
Collaborator

@wbpcode wbpcode commented Feb 19, 2021

Optimized the decoding process for string. Reduced memory copy overhead by reading contiguous memory. Use branch-less method to determine the length of utf-8 strings.

Since a standard benchmark is missing, I can't determine the exact performance improvement.
However, from what I've seen in practice, it has reduced the string parsing overhead significantly.

wbpcode added 4 commits February 19, 2021 10:32
Signed-off-by: wbpcode <comems@msn.com>
Signed-off-by: wbpcode <comems@msn.com>
Signed-off-by: wbpcode <comems@msn.com>
@wbpcode
Copy link
Collaborator Author

wbpcode commented Feb 19, 2021

Some features of c++17 are used. Maybe we need to update the requested compiler version in README.

Copy link
Collaborator

@zyfjeff zyfjeff left a comment

Choose a reason for hiding this comment

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

Just some little nits

hessian2/basic_codec/string_codec.cc Show resolved Hide resolved

for (; i < out.size();) {
auto code = static_cast<uint8_t>(out[i]);
auto size = UTF_8_CHAR_LENGTHS[code >> 3];
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a nice optimization that improves performance by using shift operations and indexing operations instead of if and logical calculations.

hessian2/basic_codec/string_codec.cc Show resolved Hide resolved
Signed-off-by: wbpcode <comems@msn.com>
@zyfjeff zyfjeff merged commit 00aae46 into alibaba:main Feb 22, 2021
@wbpcode wbpcode deleted the string-perf branch February 22, 2021 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants