ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I saw the results, and I don't see huge improvement.
I'm looking for any improvement, but you are right.. not huge.
As I wrote in my original post. On a normal system this file contains about 600 lines.
There's no need for improvement then (0.01 second)
Code:
# time wc -l /proc/net/ip_conntrack
1498 /proc/net/ip_conntrack
real 0m0.009s
user 0m0.000s
sys 0m0.008s
But on that popular server we're talking about +/- 38000 lines which takes 10 seconds.
If I could bring this down to 6 seconds I'll be more happy than I am already.
This code is being used by a monitoring server which executes this every minute.
I don't want it to become an extra burden on such an already stressed system.
Quote:
Originally Posted by H_TeXMeX_H
As for /proc/sys/net/ip_conntrack, I don't have the file, so I didn't know.
Sorry, it's /proc/net/ip_conntrack
You will probably have it.
Quote:
Originally Posted by H_TeXMeX_H
But then, how does wc -l work if the file has no size ?
It works fine ;-)
BTW, today I got an email with those C-programs I wrote more than 25 years ago which I published later as shareware on fidonet. Just found them on the Internet. http://pastebin.com/37UncgHf
This soundex function was done by Nantucket in assembly language using a complete different algorithm.
I wrote it in my own way in C (I found assembly too cumbersome) and made it 3 times as fast returning a 5 byte code instead of 4. Speed was a necessity because the function was used as an index key for a database.
Although I was an experienced programmer in Clipper, the only things I did in C were these little functions. All original work as I had no-one I could learn from (I didn't even know there was a thing called Internet). Later in my life I created some functions in 'C' managing sets (union, intersection...) (http://en.wikipedia.org/wiki/Set_%28mathematics%29).
You went and changed the benchmark! For 1.3GB.txt, it looks like most of the time is spent waiting for the disk since sys+user is much less than real time. I would suggest that you on test ip_conntrack since that is what you are actually interested in.
You went and changed the benchmark! For 1.3GB.txt, it looks like most of the time is spent waiting for the disk since sys+user is much less than real time. I would suggest that you on test ip_conntrack since that is what you are actually interested in.
I would never have done this if I had a choice in this. I have no access to that server nor will I ever have.
I don't have any server at my disposal that handles that many connections.
conntrack provides a full featured userspace interface to the netfilter connection tracking system that is intended to replace the old /proc/net/ip_conntrack interface.
Might be a faster method of listing connections if you have it installed on your server.
So it turns out increasing the buffer size doesn't help, I rewrote lc.c to use open() and read(), and discovered that it doesn't read() more than 4096 bytes at a time.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.