mirror of
https://github.com/transmission/transmission
synced 2024-12-27 01:57:52 +00:00
perf: remove cpu bottleneck in tr_peerIo::write() (#4258)
This commit is contained in:
parent
d8327949ac
commit
0efb96124b
2 changed files with 7 additions and 5 deletions
|
@ -796,11 +796,8 @@ size_t tr_peerIo::getWriteBufferSpace(uint64_t now) const noexcept
|
||||||
|
|
||||||
void tr_peerIo::write(libtransmission::Buffer& buf, bool is_piece_data)
|
void tr_peerIo::write(libtransmission::Buffer& buf, bool is_piece_data)
|
||||||
{
|
{
|
||||||
for (auto& ch : buf)
|
auto [bytes, len] = buf.pullup();
|
||||||
{
|
encrypt(len, bytes);
|
||||||
encrypt(1, &ch);
|
|
||||||
}
|
|
||||||
|
|
||||||
outbuf_info.emplace_back(std::size(buf), is_piece_data);
|
outbuf_info.emplace_back(std::size(buf), is_piece_data);
|
||||||
outbuf.add(buf);
|
outbuf.add(buf);
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,6 +266,11 @@ public:
|
||||||
return iov;
|
return iov;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] std::pair<std::byte*, size_t> pullup()
|
||||||
|
{
|
||||||
|
return { reinterpret_cast<std::byte*>(evbuffer_pullup(buf_.get(), -1)), size() };
|
||||||
|
}
|
||||||
|
|
||||||
void commit(Iovec iov)
|
void commit(Iovec iov)
|
||||||
{
|
{
|
||||||
evbuffer_commit_space(buf_.get(), &iov, 1);
|
evbuffer_commit_space(buf_.get(), &iov, 1);
|
||||||
|
|
Loading…
Reference in a new issue