Repository navigation
rsyslog: stop omuxsock reopening its socket for every message - #20637
Muhammad Falak R Wani (mfrw) wants to merge 1 commit into
Conversation
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. |
omuxsock calls doTryResume() before every message, and doTryResume() closes the socket and opens a new one each time. So each forwarded message costs close() + socket() + sendto() instead of a single sendto(). At tens of thousands of messages per second, that is a large share of rsyslog's CPU. Backport item (d) of upstream PR rsyslog/rsyslog#5630, released in 8.2512.0: only open the socket when none is open. The socket is an unconnected SOCK_DGRAM socket, and each sendto() names the destination, so delivery and error handling do not change. The rest of that PR adds new omuxsock features, which are not needed for this fix, and neither are its follow-ups. Tested 8.2308.0-9 against the same spec without the patch (8.2308.0-8), both built with the same toolchain, in Azure Linux 3.0 containers (imuxsock -> omuxsock -> Unix datagram receiver): - Socket syscalls per forwarded message drop from 3 to 1. - rsyslogd CPU is 10-23% lower at 10,000-100,000 msg/s. Maximum throughput rises from 161,775 to 300,843 msg/s, with 42% less CPU per message. - No messages were lost or duplicated across 144 million messages, including a 60-minute soak. A receiver that restarts, stalls or is missing, repeated SIGHUP and an rsyslog restart all behave as before. - Upstream uxsock_simple.sh and the imuxsock tests give the same results with and without the patch. Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
rsyslog omuxsock: stop reopening the socket for every message (Azure Linux 3.0) — stress test reportChange: rsyslog Summary
The change static rsRetVal doTryResume(instanceData *pData)
{
DEFiRet;
- DBGPRINTF("omuxsock trying to resume\n");
- closeSocket(pData);
- iRet = openSocket(pData);
+ if(pData->sock == INVLD_SOCK) {
+ DBGPRINTF("omuxsock trying to resume\n");
+ iRet = openSocket(pData);
- if(iRet != RS_RET_OK) {
- iRet = RS_RET_SUSPENDED;
+ if(iRet != RS_RET_OK) {
+ iRet = RS_RET_SUSPENDED;
+ }
}
RETiRet;
}
The rest of PR 5630 adds new features: abstract socket names, network namespaces and connected socket types. It builds on PR 6121, which adds the network namespace APIs, and PR 6750 later fixed message loss in those new connected modes. None of that is needed for this fix, and none of it is included. azurelinux PR 18262 backports all three; this change takes only the fix the requesting team asked for. How it was tested
ResultsSyscalls per forwarded message (strace -f -c, 20,000 messages)
Socket churn (20,000 msg/s for 10 s, /proc sampled every 200 ms)
CPU and latency at fixed message rates (200-byte messages, 30 s per run, 3 runs each)
Maximum throughput (2,000,000 messages from 2 unpaced senders, 3 runs)
Total CPU is slightly higher with the patch here only because it moves 86% more messages per second; per message it uses 42% less. The baseline's p99 latency is high because its queue stays full. Message size sweep (25,000 msg/s, 20 s, 2 runs)
Concurrency and multiple outputs
Fault injection (20,000 msg/s)
Soak (60 minutes at 30,000 msg/s, both variants side by side)
The soak ran while other test jobs, the x86_64 emulated build and the upstream test build, were using the same VM. So its latency tail and absolute CPU figures are noisier than in the dedicated runs above. Both builds saw the same conditions. Loss accounting across the 66 runs that should not lose messages: baseline delivered 144,220,000 of 144,220,000, patched delivered 144,220,000 of 144,220,000. Regression, packaging and upgrade
Something we already ship today (not changed here)
|
fd1d8e9 to
fce2c14
Compare
omuxsock calls doTryResume() before every message, and doTryResume()
closes the socket and opens a new one each time. So each forwarded
message costs close() + socket() + sendto() instead of a single
sendto(). At tens of thousands of messages per second, that is a
large share of rsyslog's CPU.
Backport item (d) of upstream PR rsyslog/rsyslog#5630, released in
8.2512.0: only open the socket when none is open. The socket is an
unconnected SOCK_DGRAM socket, and each sendto() names the destination,
so delivery and error handling do not change. The rest of that PR adds
new omuxsock features, which are not needed for this fix, and neither
are its follow-ups.
Tested 8.2308.0-9 on Azure Linux 3.0 (imuxsock -> omuxsock):
calls. With 8.2308.0-7 they took 5000 socket(), 5001 close() and
5000 sendto().
about 1.5 s.
receiving.
BuddyBuild: link
Fixes: https://mariner-org.visualstudio.com/mariner/_workitems/edit/25606
Signed-off-by: Muhammad Falak R Wani falakreyaz@gmail.com