Add PQsendSyncMessage() to libpq
От | Anton Kirilov |
---|---|
Тема | Add PQsendSyncMessage() to libpq |
Дата | |
Msg-id | CACV6eE5arHFZEA717=iKEa_OewpVFfWJOmsOdGrqqsr8CJVfWQ@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: Add PQsendSyncMessage() to libpq
Re: Add PQsendSyncMessage() to libpq |
Список | pgsql-hackers |
Hello, Recently I have been trying to use libpq's pipeline mode in a project, and in the process I have noticed that the PQpipelineSync() function has a deficiency (which, to be fair, could be an advantage in other situations): It combines the establishment of a synchronization point in a pipeline with a send buffer flush, i.e. a system call. In my use case I build up a pipeline of several completely independent queries, so a synchronization point is required between each of them, but performing a system call for each is just unnecessary overhead, especially if the system is severely affected by any mitigations for Spectre or other security vulnerabilities. That's why I propose to add an interface to libpq to establish a synchronization point in a pipeline without performing any further actions. I have attached a patch that introduces PQsendSyncMessage(), a function that is equivalent to PQpipelineSync(), except that it does not flush anything to the server; the user must subsequently call PQflush() instead. Alternatively, the new function is equivalent to PQsendFlushRequest(), except that it sends a sync message instead of a flush request. In addition to reducing the system call overhead of libpq's pipeline mode, it also makes it easier for the operating system to send as much of the pipeline as possible in a single TCP (or lower level protocol) packet when the database is running remotely. I would appeciate your thoughts on my proposal. Best wishes, Anton Kirilov
Вложения
В списке pgsql-hackers по дате отправления: