Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 09-03-2011, 01:09 PM   #1
LQ Newbie
Registered: Dec 2010
Posts: 2

Rep: Reputation: 0
Getting nr of open file descriptors in processes without loop over fd-directory.

Web search brought no direct hint if we can get the number of open file descriptors in a process without lopping over the content of /proc/#fd, what is a comparatively slow operation. The problem appeared so imminent to me when we attempted to collect performance metrics of a node under heavy load, say 1500-2000 processes, with open fd's counting 10,000 to 20,000.

We loop open /proc, go to each process sub directory, a pretty std stuff using readdir() etc. Generic in Linux, but CPU (kernel time) very expensive because the content of files like 'stat' is in ascii.

And even that's not all: No open FD value can be found! In order to get to it, inside of every process directory we are forced to open the fd subdirectory and lopp inside it again to get one lousy value!

So I am asking the Linux kernel or file-system gurus: Can we get that value without the loop, like read the dir internal descriptor, or even directly something in the process itself?
Old 09-04-2011, 01:55 PM   #2
Senior Member
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
I think this is what you are looking for.


directly, files, kernel, performance

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how kernel resolves file descriptors when you do open() or read() alankar Linux - Kernel 2 09-04-2009 01:35 AM
Max open file descriptors stuck at 1024? ravindra.j21 Linux - Newbie 1 06-12-2009 06:03 AM
POSIX-portable (i.e. glibc) way to list all open file descriptors? ta0kira Programming 2 07-22-2007 02:09 PM
Geting error loop QFike:getch: File not open QFile:atEnd: this file is not open badgerbox76 Linux - Newbie 6 01-07-2006 06:30 PM
How to find out the number of open file descriptors? skie_knite007 Programming 2 12-11-2005 11:23 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:28 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration