Skip to content

Conversation

acogoluegnes
Copy link
Contributor

@acogoluegnes acogoluegnes commented Jul 4, 2025

A couple of optimizations when sending chunks to readers:

  • Change the signature of the sendfile callback. The callback is used in RabbitMQ to send the frame header. The callback expects now a binary result to send it along the chunk header. This saves a system call and improves performance with small chunks.
  • Try to read the whole chunk with its header if the previous one was small enough. This can avoid using sendfile (and save a syscall) for stream with small chunks.

acogoluegnes added a commit to rabbitmq/rabbitmq-server that referenced this pull request Jul 4, 2025
This saves a system call by sending the frame header and the chunk
header at the same time.

References rabbitmq/osiris#192
acogoluegnes added a commit to rabbitmq/rabbitmq-server that referenced this pull request Jul 23, 2025
This saves a system call by sending the frame header and the chunk
header at the same time.

References rabbitmq/osiris#192
@acogoluegnes acogoluegnes force-pushed the send-file-improvements branch 5 times, most recently from c5572f0 to bda8f17 Compare July 24, 2025 10:07
acogoluegnes added a commit to rabbitmq/rabbitmq-server that referenced this pull request Jul 24, 2025
This saves a system call by sending the frame header and the chunk
header at the same time.

References rabbitmq/osiris#192
@acogoluegnes acogoluegnes changed the title Update send_file callback to save a system call Optimizations for readers Jul 24, 2025
@kjnilsson kjnilsson force-pushed the send-file-improvements branch from c16bed9 to b50de25 Compare July 29, 2025 15:15
acogoluegnes added a commit to rabbitmq/rabbitmq-server that referenced this pull request Aug 1, 2025
This saves a system call by sending the frame header and the chunk
header at the same time.

References rabbitmq/osiris#192
acogoluegnes added a commit to rabbitmq/rabbitmq-server that referenced this pull request Aug 4, 2025
This saves a system call by sending the frame header and the chunk
header at the same time.

References rabbitmq/osiris#192
acogoluegnes added a commit to rabbitmq/rabbitmq-server that referenced this pull request Aug 4, 2025
This saves a system call by sending the frame header and the chunk
header at the same time.

References rabbitmq/osiris#192
acogoluegnes added a commit to rabbitmq/rabbitmq-server that referenced this pull request Aug 18, 2025
This saves a system call by sending the frame header and the chunk
header at the same time.

References rabbitmq/osiris#192
acogoluegnes added a commit to rabbitmq/rabbitmq-server that referenced this pull request Aug 21, 2025
This saves a system call by sending the frame header and the chunk
header at the same time.

References rabbitmq/osiris#192
@acogoluegnes acogoluegnes force-pushed the send-file-improvements branch from 3827fac to b561e82 Compare August 22, 2025 08:16
acogoluegnes added a commit to rabbitmq/rabbitmq-server that referenced this pull request Aug 22, 2025
This saves a system call by sending the frame header and the chunk
header at the same time.

References rabbitmq/osiris#192
@kjnilsson kjnilsson force-pushed the send-file-improvements branch 2 times, most recently from 8cce6ed to ec17a39 Compare August 26, 2025 09:29
kjnilsson pushed a commit to rabbitmq/rabbitmq-server that referenced this pull request Aug 26, 2025
This saves a system call by sending the frame header and the chunk
header at the same time.

References rabbitmq/osiris#192
acogoluegnes added a commit to rabbitmq/rabbitmq-server that referenced this pull request Sep 1, 2025
This saves a system call by sending the frame header and the chunk
header at the same time.

References rabbitmq/osiris#192
@kjnilsson kjnilsson force-pushed the send-file-improvements branch from ec17a39 to 182cb04 Compare September 1, 2025 14:07
@acogoluegnes acogoluegnes force-pushed the send-file-improvements branch from 208e5d7 to 48bc4ee Compare September 3, 2025 06:29
acogoluegnes added a commit to rabbitmq/rabbitmq-server that referenced this pull request Sep 4, 2025
This saves a system call by sending the frame header and the chunk
header at the same time.

References rabbitmq/osiris#192
acogoluegnes and others added 5 commits September 4, 2025 08:48
The callback is used in RabbitMQ to send the frame header. This commit
changes the callback to expect a binary result and to send it along the
chunk header. This saves a system call and improves performance with
small chunks.
Reading a chunk header then using the sendfile syscall to send the chunk
data is not optimal for small chunks, as it amounts to 2 system calls
for a small amount of bytes.

This commit uses the size of the last chunk to try to read the whole
chunk when the library reads the chunk header. If the last chunk data
size was under 4096 bytes, the library does not only read the chunk
header, but reads ahead to try to read the whole and thus to save the
sendfile call later.

This optimization should improve the read throughput for streams with
small chunks, e.g. streams with 1-message chunks.
acogoluegnes and others added 7 commits September 4, 2025 08:48
Start with default filter size and use actual size after non-zero value
has been read.

Attempt to read ahead from parse_header instead of returning the header
and no data. The decision is based on the availability of previous read
ahead data.
@acogoluegnes acogoluegnes force-pushed the send-file-improvements branch from 5084a4f to 647e470 Compare September 4, 2025 08:49
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.

2 participants