High context switches on FreeBSD
I'm a simple iterative web server for a small project. This web server uses regular read(2) and write(2) to both read file from the drive and write it to the socket. When I tested this web server on my FreeBSD 5.2.1 box, on a P IV 3 Ghz Processor and 1 GB memory, I'm getting an enormous number of context switches, as you can see below: # vmstat 1 procs memory pagedisks faults cpu r b w avmfre flt re pi po fr sr da0 da1 in sy cs us sy id 0 0 0 119644 7363322 0 0 0 2 0 0 0 2970 212 0 0 100 0 0 0 119644 7363324 0 0 0 4 0 0 0 2940 200 0 0 100 0 0 0 119644 7363320 0 0 0 0 0 1 0 2980 209 0 0 100 0 0 0 119644 7363480 0 0 0 4 0 4 0 3080 303 0 1 99 0 0 0 119644 7363480 0 0 0 0 0 0 0 3010 221 0 0 100 0 0 0 119644 7363480 0 0 0 0 0 0 0 3000 215 0 0 100 1 0 0 121336 736092 82 0 0 0 19 0 0 0 92030 50953 9 18 73 1 0 0 121336 736040 13 0 0 0 0 0 0 0 183150 130743 14 46 40 0 0 2 121336 735984 14 0 0 0 0 0 0 0 185140 128537 18 41 41 1 0 0 121336 735928 14 0 0 0 0 0 0 0 203780 103812 15 40 45 0 0 2 121336 735868 15 0 0 0 0 0 2 0 200290 107131 14 40 45 0 0 2 121336 735804 16 0 0 0 0 0 4 0 220320 79700 17 33 50 1 0 0 121336 735744 15 0 0 0 0 0 0 0 216450 87448 16 35 49 0 0 1 121336 735684 15 0 0 0 0 0 0 0 201950 10 17 39 44 0 0 2 121336 735620 16 0 0 0 0 0 0 0 221290 81349 19 31 50 0 0 1 121336 735564 14 0 0 0 0 0 5 0 201340 106842 19 36 45 0 0 0 118992 736576 12 0 0 0 265 0 0 0 82830 58152 7 18 75 0 0 0 118992 7365760 0 0 0 0 0 0 0 2950 197 0 1 99 0 0 0 118992 7365760 0 0 0 0 0 0 0 2970 206 0 0 100 0 0 0 118992 7365760 0 0 0 0 0 0 0 2960 201 0 0 100 0 0 0 118992 7365760 0 0 0 0 0 0 0 3010 208 0 0 100 0 0 0 118992 7365760 0 0 0 0 0 0 0 2940 198 0 0 100 0 0 0 118992 7365760 0 0 0 0 0 0 0 3010 210 0 1 99 ^C # When I run the same code on a Linux box, I'm only getting at most 33000 context per second, thus it gives a better performance. My question now is, is there a way I can trace the source of these context switches, network, or disk? I'm thinking it may be disk, though it is also possible that it is caused because of network. Also, I tried testing the web server by using ramdisk, and the result is still the same. The context switches stays around 100,000 at peak. I'm hoping by reducing the number of context switches, I can increase my web server performance. Oh by the way, again this web server is my own, and I just use read(2), and write(2) to read and write to the socket, and to read the file from the disk. Thanks ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
High context switches on FreeBSD
I'm a simple iterative web server for a small project. This web server uses regular read(2) and write(2) to both read file from the drive and write it to the socket. When I tested this web server on my FreeBSD 5.2.1 box, on a P IV 3 Ghz Processor and 1 GB memory, I'm getting an enormous number of context switches, as you can see below: # vmstat 1 procs memory pagedisks faults cpu r b w avmfre flt re pi po fr sr da0 da1 in sy cs us sy id 0 0 0 119644 7363322 0 0 0 2 0 0 0 2970 212 0 0 100 0 0 0 119644 7363324 0 0 0 4 0 0 0 2940 200 0 0 100 0 0 0 119644 7363320 0 0 0 0 0 1 0 2980 209 0 0 100 0 0 0 119644 7363480 0 0 0 4 0 4 0 3080 303 0 1 99 0 0 0 119644 7363480 0 0 0 0 0 0 0 3010 221 0 0 100 0 0 0 119644 7363480 0 0 0 0 0 0 0 3000 215 0 0 100 1 0 0 121336 736092 82 0 0 0 19 0 0 0 92030 50953 9 18 73 1 0 0 121336 736040 13 0 0 0 0 0 0 0 183150 130743 14 46 40 0 0 2 121336 735984 14 0 0 0 0 0 0 0 185140 128537 18 41 41 1 0 0 121336 735928 14 0 0 0 0 0 0 0 203780 103812 15 40 45 0 0 2 121336 735868 15 0 0 0 0 0 2 0 200290 107131 14 40 45 0 0 2 121336 735804 16 0 0 0 0 0 4 0 220320 79700 17 33 50 1 0 0 121336 735744 15 0 0 0 0 0 0 0 216450 87448 16 35 49 0 0 1 121336 735684 15 0 0 0 0 0 0 0 201950 10 17 39 44 0 0 2 121336 735620 16 0 0 0 0 0 0 0 221290 81349 19 31 50 0 0 1 121336 735564 14 0 0 0 0 0 5 0 201340 106842 19 36 45 0 0 0 118992 736576 12 0 0 0 265 0 0 0 82830 58152 7 18 75 0 0 0 118992 7365760 0 0 0 0 0 0 0 2950 197 0 1 99 0 0 0 118992 7365760 0 0 0 0 0 0 0 2970 206 0 0 100 0 0 0 118992 7365760 0 0 0 0 0 0 0 2960 201 0 0 100 0 0 0 118992 7365760 0 0 0 0 0 0 0 3010 208 0 0 100 0 0 0 118992 7365760 0 0 0 0 0 0 0 2940 198 0 0 100 0 0 0 118992 7365760 0 0 0 0 0 0 0 3010 210 0 1 99 ^C # When I run the same code on a Linux box, I'm only getting at most 33000 context per second, thus it gives a better performance. My question now is, is there a way I can trace the source of these context switches, network, or disk? I'm thinking it may be disk, though it is also possible that it is caused because of network. Also, I tried testing the web server by using ramdisk, and the result is still the same. The context switches stays around 100,000 at peak. I'm hoping by reducing the number of context switches, I can increase my web server performance. Oh by the way, again this web server is my own, and I just use read(2), and write(2) to read and write to the socket, and to read the file from the disk. Thanks ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: High context switches on FreeBSD
In the last episode (Apr 01), Irwan Hadi said: When I tested this web server on my FreeBSD 5.2.1 box, on a P IV 3 Ghz Processor and 1 GB memory, I'm getting an enormous number of context switches, as you can see below: # vmstat 1 procs memory pagedisks faults cpu r b w avmfre flt re pi po fr sr da0 da1 in sy cs us sy id 0 0 0 119644 7363480 0 0 0 4 0 4 0 3080 303 0 1 99 0 0 0 119644 7363480 0 0 0 0 0 0 0 3010 221 0 0 100 0 0 0 119644 7363480 0 0 0 0 0 0 0 3000 215 0 0 100 1 0 0 121336 736092 82 0 0 0 19 0 0 0 92030 50953 9 18 73 1 0 0 121336 736040 13 0 0 0 0 0 0 0 183150 130743 14 46 40 0 0 2 121336 735984 14 0 0 0 0 0 0 0 185140 128537 18 41 41 1 0 0 121336 735928 14 0 0 0 0 0 0 0 203780 103812 15 40 45 Horrible word-wrap fixed. You might want to rebuild your vmstat binary, since it looks like it's not counting syscalls at all. When I run the same code on a Linux box, I'm only getting at most 33000 context per second, thus it gives a better performance. My question now is, is there a way I can trace the source of these context switches, network, or disk? I'm thinking it may be disk, though it is also possible that it is caused because of network. Also, I tried testing the web server by using ramdisk, and the result is still the same. The context switches stays around 100,000 at peak. I'm hoping by reducing the number of context switches, I can increase my web server performance. Oh by the way, again this web server is my own, and I just use read(2), and write(2) to read and write to the socket, and to read the file from the disk. I don't think my numbers are quite that high, but I am seeing a high number of context switches also, even when idle (~200, just like the above output). An idle 4.8 box does ~10/sec, and even a busy server rarely goes above 3000. A simple du on a -current machine bumps the cs rate to 6000 (4BSD scheduler). -- Dan Nelson [EMAIL PROTECTED] ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]