Solar Designer
unread,Mar 2, 2016, 5:39:08 AM3/2/16Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to onion-dev
Hi,
I found that libonion's hard-coded "#define MAX_EVENTS 10" in
src/onion/poller.c is often non-optimal. Specifically, when my program
needs a few milliseconds to produce a response, having maxevents > 1
results in the first few threads grabbing extra requests and keeping
other threads idle. When running with 32 threads on a machine with 32
logical CPUs and needing 2ms to 4ms to generate a dynamic response, and
having 32 clients talking to the machine from localhost or same LAN, the
default of MAX_EVENTS 10 results in only the first 4 to 8 threads
doing any useful work, and the rest never calling my handler. Reducing
MAX_EVENTS to 1 works around this, increasing the speed by a factor of
four or more. Having many more clients talk to the server (hundreds)
would also do the trick, but it's preferable to be able to utilize the
server's full capacity even with fewer concurrent clients.
I suppose MAX_EVENTS 1 defeats the purpose of using epoll over poll, but
that's sort of OK. A better architecture might be for me to queue up
the requests, handle them with separate 32 "compute threads", and
respond to them in the connection handling threads asynchronously (that
is, not blocking those threads for the duration of the computation), but
this doesn't appear to fit in libonion's APIs, so it's something I am
considering for a complete rewrite.
For now, my feature request is to be able to adjust maxevents from the
application.
Thanks,
Alexander