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
545cacf5
Commit
545cacf5
authored
Apr 10, 2017
by
Doron Somech
Committed by
GitHub
Apr 10, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2518 from bjovke/master
Reworked zmq::proxy() for improved performance.
parents
2b543e7a
26520fe1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
5 deletions
+21
-5
proxy.cpp
src/proxy.cpp
+0
-0
socket_poller.cpp
src/socket_poller.cpp
+21
-5
No files found.
src/proxy.cpp
View file @
545cacf5
This diff is collapsed.
Click to expand it.
src/socket_poller.cpp
View file @
545cacf5
...
...
@@ -46,9 +46,18 @@ zmq::socket_poller_t::socket_poller_t () :
#endif
{
#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_out
,
0
,
sizeof
(
pollset_in
));
memset
(
&
pollset_err
,
0
,
sizeof
(
pollset_in
));
memset
(
&
pollset_out
,
0
,
sizeof
(
pollset_out
));
memset
(
&
pollset_err
,
0
,
sizeof
(
pollset_err
));
#endif
#endif
}
...
...
@@ -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.
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
// 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
);
if
(
unlikely
(
rc
==
SOCKET_ERROR
))
{
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
return
-
1
;
}
#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
);
if
(
unlikely
(
rc
==
-
1
))
{
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