-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Odd REQ->recv Socket Performance #53
Comments
Isn't this just the usual Julia thing where the first time you call a function it takes some time to be compiled? |
That's what my first thought was, but while the first request is slow (I'd imagine from compilation) it's the second call here that is even slower: 10ms, 100ms, <1ms, <1ms .... |
@JeffBezanson, is there something in the memory subsystem that could cause a large latency like this in mid-computation, even though |
Looking at memory allocation along with the times:
So memory allocation seems to be the problem, and the fact that it is showing up in the second time through recv, and not the first makes me wonder if this is a ZMQ.jl problem rather than normal Julia compilation. And I also don't understand why unrolling the loop makes things worse for the first time through and while leaving the second slow. But other than being odd, I don't know if this is sufficiently worse than normal Julia initialization time to warrant further investigation, so I'd be okay if the maintainers decided to close this issue. |
Closing this because I cannot reproduce it on master and Julia 1.11: $ julia --project pongcl.jl
0.030095 seconds (30.87 k allocations: 1.598 MiB, 97.99% compilation time)
0.000221 seconds (8 allocations: 256 bytes)
0.000344 seconds (8 allocations: 256 bytes)
0.000254 seconds (8 allocations: 256 bytes)
0.000083 seconds (8 allocations: 256 bytes)
0.000071 seconds (8 allocations: 256 bytes)
0.000069 seconds (8 allocations: 256 bytes)
0.000116 seconds (8 allocations: 256 bytes)
0.000077 seconds (8 allocations: 256 bytes)
0.000069 seconds (8 allocations: 256 bytes)
0.000068 seconds (8 allocations: 256 bytes)
0.000067 seconds (8 allocations: 256 bytes)
0.000070 seconds (8 allocations: 256 bytes)
0.000067 seconds (8 allocations: 256 bytes)
0.000067 seconds (8 allocations: 256 bytes)
0.000067 seconds (8 allocations: 256 bytes)
0.000068 seconds (8 allocations: 256 bytes)
0.000067 seconds (8 allocations: 256 bytes)
0.000075 seconds (8 allocations: 256 bytes)
0.000070 seconds (8 allocations: 256 bytes) CodeServer: using ZMQ
s = Socket(ZMQ.REP)
ZMQ.bind(s, "tcp://*:7001")
while true
msg = ZMQ.recv(s)
ZMQ.send(s, "pong")
end Client: using ZMQ
s = Socket(ZMQ.REQ)
ZMQ.connect(s, "tcp://localhost:7001")
GC.enable(false)
for _ in 1:20
@time begin
ZMQ.send(s, "ping")
msg = ZMQ.recv(s)
end
end For me the first call takes much longer because of precompilation, then after a few more iterations it settles to something in the 10's of us range. I suppose after 10 years something was bound to have changed :) |
I've run a few simple ping/pong benchmarks and noticed some weird performance behavior of the REQ socket. Comparing performance to Python's pyzmq, the server (REP socket) performance is about the same, but for the Julia client, the request of the REQ socket reliably takes >100 milliseconds, whereas the first takes about 10ms, and all others are <1ms:
I've accounted here for garbage collection and whether the server is written in Julia or Python. The Python client has all requests handled in <1ms:
I further narrowed this extra time to the
recv
of the REQ socket by more narrowly bracketing my tic()/toc(), but things look remarkably similar in the code (both libraries are thin wrappings over zmq_msg_recv). And I didn't know where else to look.The text was updated successfully, but these errors were encountered: