Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
26520fe1
Commit
26520fe1
authored
Apr 10, 2017
by
bjovke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zmq::socket_poller_t speed improvement for constructor and wait() function.
parent
a7977a5e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
5 deletions
+21
-5
socket_poller.cpp
src/socket_poller.cpp
+21
-5
No files found.
src/socket_poller.cpp
View file @
26520fe1
...
@@ -46,9 +46,18 @@ zmq::socket_poller_t::socket_poller_t () :
...
@@ -46,9 +46,18 @@ zmq::socket_poller_t::socket_poller_t () :
#endif
#endif
{
{
#if defined ZMQ_POLL_BASED_ON_SELECT
#if defined ZMQ_POLL_BASED_ON_SELECT
#if defined ZMQ_HAVE_WINDOWS
// On Windows fd_set contains array of SOCKETs, each 4 bytes.
// For large fd_sets memset() could be expensive and it is unnecessary.
// It is enough to set fd_count to 0, exactly what FD_ZERO() macro does.
FD_ZERO
(
&
pollset_in
);
FD_ZERO
(
&
pollset_out
);
FD_ZERO
(
&
pollset_err
);
#else
memset
(
&
pollset_in
,
0
,
sizeof
(
pollset_in
));
memset
(
&
pollset_in
,
0
,
sizeof
(
pollset_in
));
memset
(
&
pollset_out
,
0
,
sizeof
(
pollset_in
));
memset
(
&
pollset_out
,
0
,
sizeof
(
pollset_out
));
memset
(
&
pollset_err
,
0
,
sizeof
(
pollset_in
));
memset
(
&
pollset_err
,
0
,
sizeof
(
pollset_err
));
#endif
#endif
#endif
}
}
...
@@ -585,10 +594,14 @@ int zmq::socket_poller_t::wait (zmq::socket_poller_t::event_t *events_, int n_ev
...
@@ -585,10 +594,14 @@ int zmq::socket_poller_t::wait (zmq::socket_poller_t::event_t *events_, int n_ev
// Wait for events. Ignore interrupts if there's infinite timeout.
// Wait for events. Ignore interrupts if there's infinite timeout.
while
(
true
)
{
while
(
true
)
{
memcpy
(
&
inset
,
&
pollset_in
,
sizeof
(
fd_set
));
memcpy
(
&
outset
,
&
pollset_out
,
sizeof
(
fd_set
));
memcpy
(
&
errset
,
&
pollset_err
,
sizeof
(
fd_set
));
#if defined ZMQ_HAVE_WINDOWS
#if defined ZMQ_HAVE_WINDOWS
// On Windows we don't need to copy the whole fd_set.
// SOCKETS are continuous from the beginning of fd_array in fd_set.
// We just need to copy fd_count elements of fd_array.
// We gain huge memcpy() improvement if number of used SOCKETs is much lower than FD_SETSIZE.
memcpy
(
&
inset
,
&
pollset_in
,
sizeof
(
pollset_in
.
fd_count
)
+
sizeof
(
*
(
pollset_in
.
fd_array
))
*
pollset_in
.
fd_count
);
memcpy
(
&
outset
,
&
pollset_out
,
sizeof
(
pollset_out
.
fd_count
)
+
sizeof
(
*
(
pollset_out
.
fd_array
))
*
pollset_out
.
fd_count
);
memcpy
(
&
errset
,
&
pollset_err
,
sizeof
(
pollset_err
.
fd_count
)
+
sizeof
(
*
(
pollset_err
.
fd_array
))
*
pollset_err
.
fd_count
);
int
rc
=
select
(
0
,
&
inset
,
&
outset
,
&
errset
,
ptimeout
);
int
rc
=
select
(
0
,
&
inset
,
&
outset
,
&
errset
,
ptimeout
);
if
(
unlikely
(
rc
==
SOCKET_ERROR
))
{
if
(
unlikely
(
rc
==
SOCKET_ERROR
))
{
errno
=
zmq
::
wsa_error_to_errno
(
WSAGetLastError
());
errno
=
zmq
::
wsa_error_to_errno
(
WSAGetLastError
());
...
@@ -596,6 +609,9 @@ int zmq::socket_poller_t::wait (zmq::socket_poller_t::event_t *events_, int n_ev
...
@@ -596,6 +609,9 @@ int zmq::socket_poller_t::wait (zmq::socket_poller_t::event_t *events_, int n_ev
return
-
1
;
return
-
1
;
}
}
#else
#else
memcpy
(
&
inset
,
&
pollset_in
,
sizeof
(
fd_set
));
memcpy
(
&
outset
,
&
pollset_out
,
sizeof
(
fd_set
));
memcpy
(
&
errset
,
&
pollset_err
,
sizeof
(
fd_set
));
int
rc
=
select
(
maxfd
+
1
,
&
inset
,
&
outset
,
&
errset
,
ptimeout
);
int
rc
=
select
(
maxfd
+
1
,
&
inset
,
&
outset
,
&
errset
,
ptimeout
);
if
(
unlikely
(
rc
==
-
1
))
{
if
(
unlikely
(
rc
==
-
1
))
{
errno_assert
(
errno
==
EINTR
||
errno
==
EBADF
);
errno_assert
(
errno
==
EINTR
||
errno
==
EBADF
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment