lkml.org 
[lkml]   [2000]   [Oct]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subjectclose() slow on socketpairs?
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?

- Dan

#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <sys/types.h>
#include <sys/socket.h>
main()
{
int i;
int fds[16000];
int n = 8000;
time_t start = time(0);
for (i=0; i<n; i+= 2)
if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds + i))
exit(1);
printf("Opening %d socketpairs took %d seconds\n", n, time(0) - start);
start = time(0);
for (i=0; i<n; i+= 2)
if (close(fds[i]) || close(fds[i+1]))
exit(1);
printf("Closing %d pipes took %d seconds\n", n, time(0) - start);
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

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