Tuesday July 12, 2011

[Time] NameMessage
[00:31] gpfreitas Can someone point me out to the closest example of the following: two clients, one server. Clients have a pile of integers that they send to the server. Main loop in the server: server gets on integer from client 1, one integer from client 2, adds them, and returns the sum to the clients.
[00:32] gpfreitas By closest example, I mean code that is close to the application just described.
[00:33] whack gpfreitas: look for examples of REQ/REP sockets
[00:34] gpfreitas I tried to do this, but it did not work. Let me post the code:
[00:34] whack sounds like you'll have two clients (req) and one server (rep), you'll need read one message each from the clients and reply to both clients at the same time
[00:34] whack but I think you will need two rep sockets for that
[00:34] gpfreitas Hmmmm... I thought the reply from the server would be a PUB
[00:35] whack well, that can work too
[00:35] whack it's up to you, clients can send with REQ/REP and receve the real result from a pubsub
[00:35] gpfreitas Server code:
[00:36] gpfreitas Clients code:
[00:37] gpfreitas Server code ran fine, I don't know if it works, but it didn't crash.
[00:37] gpfreitas Client's code crashed with the following message:
[00:37] gpfreitas File "", line 53, in client1out out_socket2.send(str(d)) File "socket.pyx", line 385, in zmq.core.socket.Socket.send (zmq/core/socket.c:3523) File "socket.pyx", line 438, in zmq.core.socket.Socket._send_copy (zmq/core/socket.c:4054) zmq.core.error.ZMQError: Operation cannot be accomplished in current state
[00:39] whack gpfreitas: a few problems; you never send a reply to the request
[00:39] gpfreitas Sorry, I know this must be a very newbie question. I'm not a programmer really, I am an economist, and I want to run experiments of my models (like auctions, etc.) at university, and I know Python... I saw a tutorial on ZMQ and it seemed simple enough.
[00:39] whack (server)
[00:39] gpfreitas (correction: I'm a graduate student in economics)
[00:39] gpfreitas Ok, let me see.
[00:40] gpfreitas whack: ok. So I should do something like send a reply like "received" to the client, at which point the client sends a new number. Is that all right?
[00:40] whack gpfreitas: you have some copy paste errors, too
[00:40] whack line 1 def client1out():
[00:41] whack should be def client2out(): no?
[00:41] gpfreitas Yes. Very sorry about that.
[00:41] whack no worries, everybody makes typos :)
[00:42] gpfreitas I just feel bad asking someone to "debug" code for me (as simple as it is) for free. So thanks.
[00:42] gpfreitas Now,
[00:42] gpfreitas when you said, you never send a reply to the request
[00:43] whack yeah, req/rep. When you send a request with the client, server receives with a REP socket, you must reply always
[00:43] whack even if it's an empty message
[00:43] whack but that's a bug on your server, not the client, still reading your client code to see why it's crashing
[00:43] whack oooh
[00:43] gpfreitas Ok. I'll get back to that later.
[00:43] whack hah yeah, what I said.
[00:43] whack your data array has 5 elements
[00:43] gpfreitas The lack of reply?
[00:43] whack yeah
[00:44] whack your server can just reply "OK" or something silly, have your client receive and drop the reply
[00:44] gpfreitas That's the state thing that it is complaining about.
[00:44] whack yup!
[00:44] gpfreitas I see.
[00:44] whack you are essentially doing two sends in a row on the same socket without processing a reply
[00:44] whack and req/rep requires a request and reply each :)
[00:44] whack hope this helps
[00:44] gpfreitas thanks man
[00:45] gpfreitas and an empty message is an empty string, or just nothing at all
[00:45] gpfreitas like
[00:45] gpfreitas socket.send('')
[00:45] gpfreitas or socket.send()
[00:45] gpfreitas ?
[00:45] whack I'd try empty string first
[00:45] whack ''
[00:45] gpfreitas Ok.
[00:45] gpfreitas If you don't mind, I'll ask some other questions!
[00:45] gpfreitas :)
[00:45] whack go ahead :)
[00:45] gpfreitas Is it possible to send Python objects, instead of strings?
[00:46] gpfreitas Well, that's probably a bad idea anyway. Better to send some representation of the object, right?
[00:46] whack I believe you'll have to serialize it somehow
[00:46] gpfreitas (For portability reasons, I guess.)
[00:46] gpfreitas Ok.
[00:47] whack well, if it's always python to python
[00:47] gpfreitas JSON, YAML, something.
[00:47] whack you can use python's marshal feature
[00:47] gpfreitas marshal?
[00:47] gpfreitas Ok, I'll check that
[00:47] whack gpfreitas: yeah json or yaml will also suffice
[00:47] whack
[00:47] gpfreitas whack, thanks a lot.
[00:47] gpfreitas Really.
[00:47] gpfreitas I have found one nice pyzmq tutorial
[00:47] gpfreitas and the examples in the zmq trunk, and the pyzmq trunk
[00:48] gpfreitas (the nice tutorial was . This actually made me want to learn the thing.)
[00:48] whack gpfreitas: yeah, marshal.dumps(some object) and send the resulting string; then marshal.loads(message) to load it up
[00:48] gpfreitas whack: cool!
[00:48] gpfreitas thanks again man.
[00:48] gpfreitas Back to docs
[00:48] gpfreitas the examples in the zmq and pyzmq trunks don't have a lot of comments
[00:48] gpfreitas so they are not as helpful as they can be. Still very helpful, but, anyway.
[00:48] whack nod. The ZMQ guide is pretty good about explaining how/why/what to do with zeromq
[00:49] gpfreitas Ok. I'll check that.
[00:49] whack most of the guide has examples in C, but the concepts are universal
[00:49] gpfreitas Ok.
[00:49] whack <-- guide
[00:49] whack good luck :)
[00:49] gpfreitas Thanks again.
[00:49] gpfreitas I might come back to bother you guys again!
[00:49] gpfreitas So far, I really like the simplicity of the whole thing, and I know I'm just scratching the surface.
[00:49] whack soon you'll be conquering economic models before you know it
[00:49] gpfreitas Haha
[00:50] whack I was an econ minor :)
[00:50] gpfreitas It's really cool to be able to implement an abstract concept like that of a "economic mechanism" in a bunch of server/clients... Really, really cool.
[00:50] gpfreitas Cool.
[00:50] whack the one econ class I wanted to take extra before graduation was game theory, but it was always over-full
[00:50] gpfreitas Ah, pity.
[00:50] gpfreitas It's really cool.
[00:51] whack nod, I studied it briefly on my own; took labor and a bunch of other ones, too
[00:51] gpfreitas I don't know labor econ at all. My field is mainly "reverse game theory" (mechanism design).
[00:51] gpfreitas We design games so that the equilibria are what we want to happen.
[00:52] whack cool :)
[00:52] gpfreitas These games can be implemented in real life through things like ZMQ.
[00:52] gpfreitas Like an auction.
[00:52] gpfreitas Or a voting procedure.
[00:52] gpfreitas Or a market.
[00:53] gpfreitas And if I can implement these things quickly, then I don't have to rely on the programmers here, that are always so busy (and of course, the professors have priority over us when it comes to their time)
[00:53] gpfreitas All right. whack, thanks once more. You are very helpful, man.
[00:53] gpfreitas Take care.
[00:53] whack later :)
[01:01] gpfreitas whack: you still there?
[01:01] gpfreitas New server code did not work. You can see I added the empty messages.
[01:01] whack checking
[01:02] whack did you update your clients to receive as well?
[01:02] gpfreitas (client code, again:
[01:02] gpfreitas Oh.
[01:02] whack you have this:
[01:02] whack out_socket1.send(str(d))
[01:02] gpfreitas I suppose they do not receive things automatically. :|
[01:02] whack but need to out_socket1.recv() or whatnot :)
[01:02] gpfreitas Gosh. Sorry.
[01:02] whack no worries
[01:02] gpfreitas Thanks, gain man.
[01:03] gpfreitas again
[01:03] whack this particular model *might* fit best without req/rep
[01:03] gpfreitas how would the clients send the result then?
[01:03] whack pubsub from client->server would fit your model, maybe; depending on where you are taking this program
[01:04] gpfreitas I mean, in general, the model I have in mind is: each client `i` sends a message `m_i` and server applies a function `f` on `(m_1, ..., m_n)` obtaining a result `r` that it broadcasts to all the clients.
[01:05] whack nod, what you have now (assuming you handle empty replies and such) is fine; alternately you can have each client publish m_i with pubsub
[01:05] whack totally your call; try both and maybe see what fits you better
[01:08] gpfreitas pubsub does not require this "you need to reply" bureaucracy?
[01:09] whack yup
[01:09] whack your clients would simply send each number (publish) to the server
[01:09] whack and server would pull one message from each client (like it does now), do some computation, then publish result to all clients
[01:09] gpfreitas Ok. That's better.
[01:09] gpfreitas I'll try that.
[01:10] whack you'll still need one 'sub' on the server per client
[01:10] whack just so you can identify which messages are from what client
[01:10] gpfreitas yeah
[01:11] gpfreitas whack: well, thank you very much. Again!
[01:11] gpfreitas I'll work on this later. Need to go to a meeting. Thanks, whack.
[01:11] gpfreitas See you later!
[01:11] whack later :)
[02:10] xristos does zmq use select or epoll internally?
[02:10] xristos i'm hitting the select fd > 1024 issue
[02:11] whack xristos: strace will show you
[02:16] xristos well it shouldn't matter, the question is why is it having issues with > fds open
[02:16] xristos *1024
[02:40] Silly I thought 1024 was a limitation of the linux kernel from the last time I looked into opening more than that...
[02:40] Silly maybe I just had a weird system...
[02:52] reuben Silly, it is, you can change that limit
[02:52] reuben xristos, ^
[03:08] xristos reuben: you mean FD_SETSIZE?
[03:09] xristos that needs kernel recompilation
[03:23] reuben xristos, nono, it's a runtime configuration
[03:24] reuben xristos, /etc/sysctl.conf
[03:24] reuben fs.file-max
[03:26] xristos i have that changed to 500k
[03:26] reuben xristos, or just ulimit -n NUM
[03:26] reuben on bash
[03:26] xristos ulimit -n
[03:26] xristos is 1 100k
[03:26] xristos so thats not it
[03:27] xristos if zeromq is using select then it's a known problem
[03:27] xristos i call zmq_poll
[03:27] xristos don't know what that does underneath
[03:28] xristos but the way it manifests is i have a pull socket
[03:28] xristos > 1024 clients connect and do push
[03:28] xristos and i've called poll
[03:29] xristos well actually it's more like 500 clients
[03:29] xristos so one client connection uses more than 1 fd
[03:51] sustrik xristos: what OS are you on?
[03:51] sustrik select is being used only for windows and openvms iirc
[03:52] xristos linux 2.6
[03:52] sustrik hm
[03:52] sustrik what's the actual assert?
[03:54] xristos dont have it right now, i'm at home
[03:55] sustrik write an email to the list later on then
[03:55] sustrik or fill in a bug report
[03:55] sustrik with test program attached
[03:55] xristos i'll ask here tomorrow
[03:55] xristos from work
[03:56] sustrik ok
[07:33] minsa I am reading the zmq internal paper.
[07:33] minsa when objects inside an I/O threads register a file descriptor, does it use the poller_t in the io_thread_t ?
[07:34] minsa I know that poller_t in the io_thread_t receives commands from other threads.
[07:35] minsa but I wasn't sure whether that is the same poller_t used for the file descriptors from the objects inside that I/O thread.
[08:28] sustrik minsa: yes, it's the same poller
[10:28] pieter_hintjens sustrik: hi
[10:29] pieter_hintjens just doing some tests on 3.0...
[10:29] sustrik morning
[10:29] sustrik any problems?
[10:29] pieter_hintjens getsockopt doesn't seem to return consistent results in some cases
[10:29] pieter_hintjens if I set the rcvhwm on a dealer socket and then try to get it back that works
[10:30] pieter_hintjens if I do the same on a sub socket, it doesn't work
[10:30] pieter_hintjens if I set affinity and try to get it back I don't get the same value back
[10:30] pieter_hintjens this used to work in 3.0, something's changed
[10:31] sustrik strange
[10:31] sustrik do you have a test program?
[10:32] pieter_hintjens it's in czmq but I can make a plain one, sure
[10:32] pieter_hintjens 30 secs...
[10:39] pieter_hintjens sustrik: minimal test case is here:
[10:39] sustrik let me see
[10:41] sustrik pieter_hintjens: works ok here
[10:41] sustrik what computer is that on?
[10:41] sustrik 32bit one?
[10:41] pieter_hintjens ubuntu
[10:41] pieter_hintjens 64-bit one
[10:41] sustrik hm, same here
[10:41] pieter_hintjens it returns zero
[10:42] pieter_hintjens i'll do some more checking... just built & installed 3.0 from master
[10:42] sustrik testing on master as well...
[10:43] sustrik does getsockopt succeed??
[10:43] sustrik the result is not checked
[10:43] pieter_hintjens have checked that, getsockopt succeeds fine
[10:43] sustrik hm
[10:44] pieter_hintjens I'll debug it, can't be so difficult
[10:44] sustrik ok
[10:47] pieter_hintjens sustrik: it never seems to call getsockopt (in options.cpp) at all
[10:47] pieter_hintjens sorry
[10:47] sustrik just step into the function
[10:47] pieter_hintjens I meant, it never calls setsockopt
[10:48] pieter_hintjens it does call getsockopt and the value is (still) zero
[10:48] sustrik zmq_setsocopt?
[10:48] pieter_hintjens int zmq::options_t::setsockopt
[10:48] pieter_hintjens that is never called
[10:48] sustrik try stepping inside the function
[10:48] sustrik in gdb
[10:48] pieter_hintjens ok
[10:48] sustrik it should look like this:
[10:49] sustrik zmq_setsockopt()
[10:49] sustrik zmq::socket_t::setsockopt()
[10:49] sustrik zmq::options_t::setsockopt()
[10:49] pieter_hintjens agh, doorbell & meeting, will have to continue later
[10:51] sustrik cya
[11:02] sustrik pieter_hintjens: found the proble
[11:03] sustrik let me fix it
[11:07] CIA-32 libzmq: 03Martin Sustrik 07master * r57c1342 10/ src/sub.cpp : Bug with setting options on SUB socket fixed ...
[11:11] sustrik done
[11:29] mpales just a quick question about REP sockets
[11:30] mpales i bind one, start polling and receive an event right away, although no REQ is connected yet
[11:30] mpales is it ok?
[11:31] mpales recv on the socket then blocks
[11:32] sustrik mpales: no
[11:32] reuben no, that's not ok...
[11:32] sustrik it's a bug
[11:33] sustrik mpales: what version of 0mq is that?
[11:56] mpales sustrik: it's 2.1.7
[12:20] sustrik ok, let me try
[12:20] sustrik mpalse: ah, btw, what event is that?
[12:20] sustrik POLLOUT
[12:20] sustrik ?
[12:20] sustrik that should be ok
[12:28] mpales it's POLLIN
[12:29] mpales i use a normal system select on socket's fd
[12:29] mpales not zmq::poll
[13:15] pieter_hintjens re
[13:16] sustrik pieter_hintjens: the problem is fixed
[13:16] sustrik try the new version
[13:16] pieter_hintjens sustrik: yes, saw that, will retest now... thanks!
[13:19] pieter_hintjens sustrik: fix confirmed, thanks!
[13:27] pieter_hintjens sustrik: question, why is ZMQ_AFFINITY a uint64_t?
[13:42] sustrik pieter_hintjens: it's the biggest interger type availble
[13:42] sustrik should be a bitmap of course
[13:42] sustrik TODO
[13:42] pieter_hintjens sustrik: ah, bitmap
[13:43] pieter_hintjens stupid of me, I missed that, but eventually it should be a blob, yes
[13:43] pieter_hintjens also MAXMSGSIZE might better be an int
[13:43] sustrik yeah, the API is capable of that
[13:43] sustrik but the implementation is lousy
[13:44] pieter_hintjens perhaps just an 8-byte blob?
[13:44] sustrik random sized blob
[13:44] sustrik not a big problem
[13:44] pieter_hintjens later then
[13:44] sustrik yes
[13:44] pieter_hintjens I'm removing the debian packaging as mato requested
[13:44] sustrik sure
[13:44] pieter_hintjens ok
[14:13] pieter_hintjens zeromq/3.0.0 has been officially packaged & released
[14:13] pieter_hintjens go break it, guys!
[14:15] mikko as a stable?
[14:16] pieter_hintjens heh, sure
[14:16] pieter_hintjens I spent all night writing comprehensive test ... oh, hang on, that was a dream
[14:16] pieter_hintjens no mikko, as unstable...
[14:17] pieter_hintjens mikko: you'll be real happy to know I cloned the repo again
[14:55] sustrik pieter_hintjens: you should announce it on zeromq-dev as well
[14:56] pieter_hintjens sustrik: did that
[14:56] pieter_hintjens did the email not show up?
[14:56] sustrik ah, there it is
[14:56] sustrik sorry, missed it
[14:56] pieterh its pretty simple, the packaging process...
[14:56] pieterh one thing we might do, remove the old tags from master
[14:57] sustrik you mean pre 2-1?
[14:57] pieterh yes
[14:57] sustrik they should be *somewhere*
[14:57] sustrik given there's no 2-9
[14:57] sustrik 2=0
[14:57] pieterh they're in the zeromq2-0 repo
[14:57] sustrik i see
[14:57] sustrik no idea how to remove them though
[14:57] pieterh
[14:57] pieterh all there
[14:57] pieterh well, I'll remove them if you approve
[14:58] sustrik sure, go on
[14:58] pieterh great, that'll help, there's always this risk now of fetching all the tags by mistake
[14:59] pieterh a|i: yes, afaik
[14:59] pieterh there are a lot of Lua examples in the Guide
[14:59] pieterh including examples of polling (which is what you want)
[15:00] pieterh search for poll
[15:00] pieterh it applies to sub sockets as well as other types
[15:04] pieterh a|i: poll works by waiting for a socket to be ready (for input, or output as you specify), then telling you
[15:05] pieterh sustrik: done, removed, the tags will remain in cloned copies of the repo until manually deleted there
[15:05] pieterh a|i: the question makes little sense... please read the Guide a little more...
[15:06] sustrik pieterh: thanks
[15:06] sustrik any idea how to remove outdated topic branches btw?
[15:06] pieterh a|i: it's not a coroutine, your thread is suspended until there's activity for it to work on
[15:06] pieterh sustrik: kind of the same, you remove locally and/or remotely as separate operations
[15:07] pieterh a|i: yes... but if you read the Guide as I suggest you would know all this
[15:07] pieterh sustrik: to delete a remote branch is the same as deleting a remote tag, you push 'nothing' to it...
[15:08] pieterh git push origin :branchname
[15:08] sustrik ok, let me try
[15:08] pieterh to delete a local branch, git branch -d branchname
[15:10] sustrik works!
[15:10] pieterh :-)
[15:11] pieterh yes, much cleaner now
[15:11] pieterh we can delete the maint branch too IMO
[15:11] pieterh it's not used, not maintained
[15:11] sustrik true
[15:12] sustrik done
[15:12] pieterh i really like this process we're using, it's light and simple
[15:54] sustrik mpales: still there?
[15:54] sustrik i've created following test program:
[15:54] sustrik
[15:54] sustrik it seems to work ok
[15:54] sustrik can you give it a try?
[19:42] fintler does anyone know of anyone doing a compare and contrast of zeromq to mrnet?
[19:43] fintler or anyone using zeromq in HPC for that matter?
[19:46] fintler on another note, the zeromq examples kick ass
[19:46] fintler amazing work
[21:46] mikko pieterh: here?
[22:05] mikko or sustrik
[23:59] smanek hi there. I have a a server which creates a 0mq PUB socket, and several clients connect to the socket. Things work well, but well for the first few minutes, but then all the clients stop seeing any messages (even though the server logs show that it is 'sending' them over the socket). Both the server and clients are using pyzmq. Any ideas?