Skip to content

Optimize ibverbs: batch CQ polling, eliminate heap allocation, fix branch hints, and correct gid_to_string off-by-one.#1162

Merged
poor-circle merged 2 commits intoalibaba:mainfrom
power-more:main
Apr 3, 2026
Merged

Optimize ibverbs: batch CQ polling, eliminate heap allocation, fix branch hints, and correct gid_to_string off-by-one.#1162
poor-circle merged 2 commits intoalibaba:mainfrom
power-more:main

Conversation

@power-more
Copy link
Copy Markdown
Contributor

Why

What is changing

  1. optimize CQ polling with batching
  2. correct gid_to_string value size
  3. correct wrong [[unlikely]] branch hints at ibv_reg_mr

Example

ib_device.hpp: ibv_reg_mr success path was incorrectly marked
[[unlikely]], causing CPU branch predictor to optimize for the
failure path. Changed to [[likely]] since registration normally
succeeds.

Signed-off-by: zhaoshang <zhaoshangsjtu@linux.alibaba.com>
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 27, 2026

CLA assistant check
All committers have signed the CLA.

The GID format "%02x%02x:..." produces exactly 39 characters, but
the string was resize(40), leaving an embedded '\0' at position 39.
This caused the returned std::string to carry a trailing null byte,
which could lead to subtle comparison or display issues downstream
(e.g. when used with asio::ip::make_address).

Also replaced sprintf with snprintf for buffer safety, explicitly
passing the buffer size (39 chars + null terminator = 40 bytes).

Signed-off-by: zhaoshang <zhaoshangsjtu@linux.alibaba.com>
@github-actions
Copy link
Copy Markdown

for detail, goto summary download Artifacts base-ylt-cov-report(base commit coverage report) and ylt-cov-report(current pull request coverage report)

@poor-circle
Copy link
Copy Markdown
Collaborator

@power-more 记得签下CLA

@power-more
Copy link
Copy Markdown
Contributor Author

@power-more 记得签下CLA

done

@poor-circle poor-circle merged commit 4272824 into alibaba:main Apr 3, 2026
30 of 31 checks passed
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.

3 participants