mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-27 07:31:03 +08:00
Problem: Windows performance is not optimal due to select().
Solution: Provide poll() for Windows as well. This is a build option that defaults to off as the resulting binary will only run on Windows Vista or newer. This is not tested with alternative Winsock service providers like VMCI, but the documentation for WSAPoll does not mention limitations. On my local machine, throughput improves by ~10 % (20 simultaneous remote_thr workes to one local_thr, 10 byte messages), while latency improves by ~30 % (measured with remote/local_lat).
This commit is contained in:
parent
8d8d32f4d0
commit
7a6ff07a01
@ -21,13 +21,15 @@
|
|||||||
<EnablePREfast>false</EnablePREfast>
|
<EnablePREfast>false</EnablePREfast>
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
<PrecompiledHeaderFile>precompiled.hpp</PrecompiledHeaderFile>
|
<PrecompiledHeaderFile>precompiled.hpp</PrecompiledHeaderFile>
|
||||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;FD_SETSIZE=16384;WIN32_LEAN_AND_MEAN;ZMQ_USE_SELECT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;FD_SETSIZE=16384;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<PreprocessorDefinitions Condition="'$(Option-tweet)' == 'true'">ZMQ_USE_TWEETNACL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions Condition="'$(Option-tweet)' == 'true'">ZMQ_USE_TWEETNACL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<PreprocessorDefinitions Condition="'$(Option-sodium)' == 'true'">ZMQ_USE_LIBSODIUM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions Condition="'$(Option-sodium)' == 'true'">ZMQ_USE_LIBSODIUM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<PreprocessorDefinitions Condition="'$(Option-tweet)' == 'true' Or '$(Option-sodium)' == 'true'">ZMQ_HAVE_CURVE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions Condition="'$(Option-tweet)' == 'true' Or '$(Option-sodium)' == 'true'">ZMQ_HAVE_CURVE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<PreprocessorDefinitions Condition="'$(Option-openpgm)' == 'true'">ZMQ_HAVE_OPENPGM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions Condition="'$(Option-openpgm)' == 'true'">ZMQ_HAVE_OPENPGM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<PreprocessorDefinitions Condition="'$(Option-gssapi)' == 'true'">HAVE_LIBGSSAPI_KRB5;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions Condition="'$(Option-gssapi)' == 'true'">HAVE_LIBGSSAPI_KRB5;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<PreprocessorDefinitions Condition="'$(Option-draftapi)' == 'true'">ZMQ_BUILD_DRAFT_API;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions Condition="'$(Option-draftapi)' == 'true'">ZMQ_BUILD_DRAFT_API;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<PreprocessorDefinitions Condition="'$(Option-usepoll)' == 'true'">ZMQ_USE_POLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<PreprocessorDefinitions Condition="'$(Option-usepoll)' != 'true'">ZMQ_USE_SELECT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<PreprocessorDefinitions Condition="'$(ConfigurationType)' == 'StaticLibrary'">ZMQ_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions Condition="'$(ConfigurationType)' == 'StaticLibrary'">ZMQ_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<PreprocessorDefinitions Condition="'$(ConfigurationType)' == 'DynamicLibrary'">DLL_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions Condition="'$(ConfigurationType)' == 'DynamicLibrary'">DLL_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@ -64,6 +66,7 @@
|
|||||||
<Message Text="Option-openpgm : $(Option-openpgm)" Importance="high"/>
|
<Message Text="Option-openpgm : $(Option-openpgm)" Importance="high"/>
|
||||||
<Message Text="Option-gssapi : $(Option-gssapi)" Importance="high"/>
|
<Message Text="Option-gssapi : $(Option-gssapi)" Importance="high"/>
|
||||||
<Message Text="Option-draftapi : $(Option-draftapi)" Importance="high"/>
|
<Message Text="Option-draftapi : $(Option-draftapi)" Importance="high"/>
|
||||||
|
<Message Text="Option-usepoll : $(Option-usepoll)" Importance="high"/>
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<Target Name="LinkageInfo" BeforeTargets="PrepareForBuild">
|
<Target Name="LinkageInfo" BeforeTargets="PrepareForBuild">
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
<Category Name="openpgm" DisplayName="openpgm" />
|
<Category Name="openpgm" DisplayName="openpgm" />
|
||||||
<Category Name="gssapi" DisplayName="gssapi" />
|
<Category Name="gssapi" DisplayName="gssapi" />
|
||||||
<Category Name="draftapi" DisplayName="draftapi" />
|
<Category Name="draftapi" DisplayName="draftapi" />
|
||||||
|
<Category Name="usepoll" DisplayName="usepoll" />
|
||||||
</Rule.Categories>
|
</Rule.Categories>
|
||||||
<Rule.DataSource>
|
<Rule.DataSource>
|
||||||
<DataSource Persistence="ProjectFile" ItemType="" />
|
<DataSource Persistence="ProjectFile" ItemType="" />
|
||||||
@ -31,5 +32,9 @@
|
|||||||
<EnumValue Name="" DisplayName="No" />
|
<EnumValue Name="" DisplayName="No" />
|
||||||
<EnumValue Name="true" DisplayName="Yes" />
|
<EnumValue Name="true" DisplayName="Yes" />
|
||||||
</EnumProperty>
|
</EnumProperty>
|
||||||
|
<EnumProperty Name="Option-usepoll" DisplayName="Enable poll() usage (Vista+ only)" Description="Use poll() instead of select() for waiting on incoming data. Increases performance, but the binary will only run on Windows Vista or later." Category="usepoll">
|
||||||
|
<EnumValue Name="" DisplayName="No" />
|
||||||
|
<EnumValue Name="true" DisplayName="Yes" />
|
||||||
|
</EnumProperty>
|
||||||
</Rule>
|
</Rule>
|
||||||
</ProjectSchemaDefinitions>
|
</ProjectSchemaDefinitions>
|
@ -32,8 +32,10 @@
|
|||||||
#if defined ZMQ_USE_POLL
|
#if defined ZMQ_USE_POLL
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#if !defined ZMQ_HAVE_WINDOWS
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
#endif
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "poll.hpp"
|
#include "poll.hpp"
|
||||||
|
@ -34,7 +34,9 @@
|
|||||||
#include "poller.hpp"
|
#include "poller.hpp"
|
||||||
#if defined ZMQ_USE_POLL
|
#if defined ZMQ_USE_POLL
|
||||||
|
|
||||||
|
#if !defined ZMQ_HAVE_WINDOWS
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
#endif
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
// definition of pollfd structure (AIX uses 'reqevents' and 'retnevents'
|
// definition of pollfd structure (AIX uses 'reqevents' and 'retnevents'
|
||||||
// instead of 'events' and 'revents' and defines macros to map from POSIX-y
|
// instead of 'events' and 'revents' and defines macros to map from POSIX-y
|
||||||
// names to AIX-specific names).
|
// names to AIX-specific names).
|
||||||
#if defined ZMQ_POLL_BASED_ON_POLL
|
#if defined ZMQ_POLL_BASED_ON_POLL && !defined ZMQ_HAVE_WINDOWS
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -35,7 +35,9 @@
|
|||||||
// instead of 'events' and 'revents' and defines macros to map from POSIX-y
|
// instead of 'events' and 'revents' and defines macros to map from POSIX-y
|
||||||
// names to AIX-specific names).
|
// names to AIX-specific names).
|
||||||
#if defined ZMQ_POLL_BASED_ON_POLL
|
#if defined ZMQ_POLL_BASED_ON_POLL
|
||||||
|
#if !defined ZMQ_HAVE_WINDOWS
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
#endif
|
||||||
#elif defined ZMQ_POLL_BASED_ON_SELECT
|
#elif defined ZMQ_POLL_BASED_ON_SELECT
|
||||||
#if defined ZMQ_HAVE_WINDOWS
|
#if defined ZMQ_HAVE_WINDOWS
|
||||||
#elif defined ZMQ_HAVE_HPUX
|
#elif defined ZMQ_HAVE_HPUX
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include "poller.hpp"
|
#include "poller.hpp"
|
||||||
|
|
||||||
#if defined ZMQ_POLL_BASED_ON_POLL
|
#if defined ZMQ_POLL_BASED_ON_POLL && !defined ZMQ_HAVE_WINDOWS
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -79,6 +79,10 @@ struct tcp_keepalive {
|
|||||||
#include <process.h>
|
#include <process.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ZMQ_USE_POLL
|
||||||
|
static inline int poll(struct pollfd *pfd, unsigned long nfds, int timeout) { return WSAPoll(pfd, nfds, timeout); }
|
||||||
|
#endif
|
||||||
|
|
||||||
// In MinGW environment AI_NUMERICSERV is not defined.
|
// In MinGW environment AI_NUMERICSERV is not defined.
|
||||||
#ifndef AI_NUMERICSERV
|
#ifndef AI_NUMERICSERV
|
||||||
#define AI_NUMERICSERV 0x0400
|
#define AI_NUMERICSERV 0x0400
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
// definition of pollfd structure (AIX uses 'reqevents' and 'retnevents'
|
// definition of pollfd structure (AIX uses 'reqevents' and 'retnevents'
|
||||||
// instead of 'events' and 'revents' and defines macros to map from POSIX-y
|
// instead of 'events' and 'revents' and defines macros to map from POSIX-y
|
||||||
// names to AIX-specific names).
|
// names to AIX-specific names).
|
||||||
#if defined ZMQ_POLL_BASED_ON_POLL
|
#if defined ZMQ_POLL_BASED_ON_POLL && !defined ZMQ_HAVE_WINDOWS
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user