From: Eric Dumazet <dada1@cosmosbay.com>
To: Zacco <zacco@fw.hu>
Cc: David Miller <davem@davemloft.net>,
baruch@ev-en.org, netdev@vger.kernel.org
Subject: Re: many sockets, slow sendto
Date: Tue, 20 Mar 2007 23:48:38 +0100 [thread overview]
Message-ID: <460064C6.5030302@cosmosbay.com> (raw)
In-Reply-To: <4600592E.80605@fw.hu>
Zacco a écrit :
> Hi,
>
> David Miller wrote:
>> From: Zacco <zacco@fw.hu>
>> Date: Tue, 20 Mar 2007 00:10:19 +0100
>>
>>
>>> As you recommended, I used oprofile and it turned out that the
>>> __udp4_lib_lookup function spent most of the time. There is a udp
>>> hash table and the sockets are sought based on the 7 LSBs of the
>>> destination port number. So what happened is now quite obvious: I had
>>> many thousands of sockets, all with the same destination port, thus
>>> linked in the same slot of this hash table. I tried using different
>>> ports and it
>>> was much faster then.
>>>
>>
>> There isn't much we can do here. I bet your destination address
>> is unchanging just like your destination ports.
>>
> As I'm simulating independent users on one host, each user has a
> different IP address, but each with the same port. So unlike the port,
> the address is changing, basically it's a huge A-class range.
>
>> UDP apps can and do bind to specific destination addresses and
>> ports, but the source side is usually wild-carded.
>>
> Right, usually it is, but in my case the source addresses are also
> bound, otherwise the source address would be the primary address of the
> physical interface; however, I need to simulate users as if they were on
> separate hosts.
>> Are both the source address and port fully specified for your
>> sockets? Maybe we can do something using if that's the case...
>>
> You made me curious. :) What do you have in mind?
Currently, udp_hash[UDP_HTABLE_SIZE] is using a hash function based on dport
number only.
In your case, as you use a single port value, all sockets are in a single slot
of this hash table :
To find the good socket, __udp4_lib_lookup() has to search in a list with
thousands of elements. Not that good, isnt it ? :(
As udp_hash is protected by a single rw_lock, I guess we could convert the
hash table to a RB-tree, with a key being : (dport, daddr)
At lookup time, we could do :
1) A full lookup with (dport, daddr)
2) if not found, a lookup with wildcard : (dport, 0)
I dont know if this is OK, because I dont know if it is possible to have
several UDP sockets with the same (dport, daddr)
It would be more scalable. But still the rw_lock is not very SMP friendly...
next prev parent reply other threads:[~2007-03-20 22:48 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-06 15:08 many sockets, slow sendto Zaccomer Lajos
2007-03-06 18:20 ` Baruch Even
2007-03-19 23:10 ` Zacco
2007-03-19 23:16 ` David Miller
2007-03-20 21:59 ` Zacco
2007-03-20 22:48 ` Eric Dumazet [this message]
2007-03-21 21:53 ` Zacco
2007-03-21 22:24 ` Eric Dumazet
2007-03-21 23:26 ` Eric Dumazet
2007-03-22 1:14 ` David Miller
2007-03-21 22:12 ` Eric Dumazet
2007-03-22 1:15 ` David Miller
2007-03-22 6:43 ` Eric Dumazet
2007-03-29 19:24 ` Zacco
2007-03-30 13:10 ` Eric Dumazet
2007-04-22 12:34 ` Zacco
2007-04-30 7:26 ` David Miller
2007-04-30 10:56 ` YOSHIFUJI Hideaki / 吉藤英明
2007-04-30 12:47 ` Eric Dumazet
2007-04-30 19:43 ` YOSHIFUJI Hideaki / 吉藤英明
2007-04-30 19:59 ` Eric Dumazet
2007-03-06 19:23 ` Andi Kleen
2007-03-06 21:28 ` Zacco
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=460064C6.5030302@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=baruch@ev-en.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=zacco@fw.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.