-
Notifications
You must be signed in to change notification settings - Fork 743
Refactor event pb #6235
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
Refactor event pb #6235
Conversation
|
⚪ |
|
⚪ |
|
⚪ |
| char buf[MaxNumberBytes]; | ||
| result += SerializeNumber(payload.size(), buf); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can compute count of needed bytes faster:
protocolbuffers/protobuf@7315f6d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#if (defined(__x86__) || defined(__x86_64__) || defined(_M_IX86) || \
defined(_M_X64)) && \
!(defined(__LZCNT__) || defined(__AVX2__))
// X86 CPUs lacking the lzcnt instruction are faster with the bsr-based
// implementation. MSVC does not define __LZCNT__, the nearest option that
// it interprets as lzcnt availability is __AVX2__.
#define EVENT_PB_PREFER_BSR 1
#else
#define EVENT_PB_PREFER_BSR 0
#endif
template<typename T>
inline size_t VarintSize(T value) {
#if EVENT_PB_PREFER_BSR
// Explicit OR 0x1 to avoid calling std::countl_zero(0), which
// requires a branch to check for on platforms without a clz instruction.
uint32_t log2value = (std::numeric_limits<T>::digits - 1) -
std::countl_zero(value | 0x1);
return static_cast<size_t>((log2value * 9 + (64 + 9)) / 64);
#else
uint32_t clz = std::countl_zero(value);
return static_cast<size_t>(
((std::numeric_limits<T>::digits * 9 + 64) - (clz * 9)) / 64);
#endif
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for advice, but it looks it is bette to rewrite the whole file using google::protobuf::io::CodedInputStream without manual serialization/deserialization.
But I don't have the strength for it.
|
⚪ |
|
⚪ |
|
⚪ |
|
⚪
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
|
⚪
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
|
⚪
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
|
⚪
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
Changelog entry
Changelog category
Additional information