On Thu, 21 Mar 2024 at 13:24, Melih Mutlu <m.melihmu...@gmail.com> wrote: > What if I do a simple comparison like PqSendStart == PqSendPointer instead of > calling pq_is_send_pending() as Heikki suggested, then this check should not > hurt that much. Right? Does that make sense?
As I understand the code, there's no problem calling internal_flush_buffer() when the buffer is empty and I suspect that if we're sending a few buffers with "len > PqSendBufferSize" that it's just so unlikely that the buffer is empty that we should just do the function call and let internal_flush_buffer() handle doing nothing if the buffer really is empty. I think the chances of internal_flush_buffer() having to do exactly nothing here is less than 1 in 8192, so I just don't think the check is worthwhile. The reason I don't think the odds are exactly 1 in 8192 is because if we're sending a large number of bytes then it will be common that the buffer will contain exactly 5 bytes due to the previous flush and command prefix just having been added. It's worth testing both, however. I might be wrong. Performance is hard to predict. It would be good to see your test.sh script run with and without the PqSendStart == PqSendPointer condition. David