SOCK_DGRAM optimization needed...

Oliver Fromme olli at lurza.secnetix.de
Fri Aug 18 13:52:05 UTC 2006


Martin Eugen <martin.eugen at gmail.com> wrote:
 > I have a simple application, that deals with lots of dgram sockets (UDP).
 > Thousands of them. Basically, its purpose is to
 > maintain pairs of sockets and when data is received on one of the sockets it
 > peeks through it (doing some simple
 > statistic calculations) and then forwards it to the other socket.
 > Because of the hudge number of reads and writes (probably about a 10 packets
 > per second per socket pair) it generates a significant load
 > on the system, that I would like to minimize. I'm currently evaluating if it
 > would be possible to add simple 'routing' functionality in the socket layer
 > in the kernel, because frankly I'm not able to think of anything else.

You should consider using kqueue(2) instead of select(2)
or poll(2), because it's more efficient for large numbers
of descriptors.  Squid (from the ports collection) has
grown kqueue support on FreeBSD some time ago, and it's
definitely a win.  You can look at the squid sources to
see how it's done; it's not difficult.

Best regards
   Oliver

-- 
Oliver Fromme,  secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

"I started using PostgreSQL around a month ago, and the feeling is
similar to the switch from Linux to FreeBSD in '96 -- 'wow!'."
        -- Oddbjorn Steffensen


More information about the freebsd-hackers mailing list