[lkml]   [2000]   [Oct]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: close() slow on socketpairs?
   Date: 	Mon, 16 Oct 2000 22:09:03 -0700
From: Dan Kegel <>

I wrote a little benchmark to call either pipe() or socketpair()
8000 times, then close() on all the fds produced by pipe or
socketpair. On both 2.2.14 and 2.2.16, pipe and socketpair are
nice and speedy. close() is fine for pipes, but at 8000
socketpairs, each call to close() takes 14 *milliseconds* at 100%
cpu usage. What's up with that?

OK, the first thing I did when I saw this was run your test program
under 2.4.0-test10-pre3 on my workstation which I believe to be a very
slow computer (170Mhz ultra-I) :-) It ran in under a second which is
the granularity of your programs measurements :-)

[root@pizda davem]# time ./sockp_test
Opening 8000 socketpairs took 0 seconds
Closing 8000 pipes took 0 seconds
Command exited with non-zero status 1
0.05user 0.39system 0:00.44elapsed 97%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (65major+16minor)pagefaults 0swaps
[root@pizda davem]#

(BTW: I just noticed that you need to add an exit(0) to the end of
main() to get a reliable zero exit status on success.)

I'll try it out under 2.2.x in a second but could you try it on 2.4.x
as well and let me know what kind of cpu we're talking about and
precisely what "time ./sockp_test" shows on your machine for both

I think it's just an AF_UNIX performance anomaly which the 2.4.x
kernel doesn't have. If so, it may or may not be easy to backport the
fix, we'll see.

David S. Miller
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

 \ /
  Last update: 2005-03-22 12:41    [W:0.040 / U:3.604 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site