lkml.org 
[lkml]   [2001]   [Nov]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: PROPOSAL: dot-proc interface [was: /proc stuff]
On Sun, Nov 04, 2001 at 07:27:16PM +0100, Tim Jansen wrote:
> On Sunday 04 November 2001 18:41, you wrote:
> > The "fuzzy parsing" userland has to do today to get useful information
> > out of many proc files today is not nice at all.
>
> I agree, but you dont need a binary format to achieve this. A WELL-DEFINED
> format is sufficient. XML is one of them, one-value-files another one. The
> "fuzzy parsing" only happens because the files try to be friendly for human
> readers.

You need syntax or "transport", and then you need semantics. My approach
is identical to XML except it doesn't give you kilobytes of human-unreadable
text.

You could use text, with binary you save the extra conversions along with
errors from parsers or bad use of sscanf()/sprintf()/... K.I.S.S. :)

I see a good point in using one-value-files though, except I think there's
some type information missing.

>
>
> > It eats CPU, it's error-prone, and all in all it's just "wrong".
>
> How much of your CPU time is spent parsing /proc files?

[albatros:joe] $ time vmstat 1
procs memory swap io system cpu
r b w swpd free buff cache si so bi bo in cs us sy id
0 0 0 113908 3184 1892 130584 1 1 3 3 61 43 9 5 86
1 0 0 113908 3064 1896 130700 0 0 8 0 2301 1148 8 2 90
0 0 0 113908 3064 1896 130700 0 0 0 0 2026 893 7 2 91
0 0 0 113908 3064 1896 130700 0 0 0 0 1877 829 3 4 93
0 0 0 113908 3068 1896 130696 0 0 0 0 1946 942 5 3 92
0 0 0 113908 3072 1896 130696 0 0 0 0 2009 1034 7 5 88
0 0 0 113908 3064 1896 130704 0 0 0 0 3706 2336 4 5 90
0 0 0 113908 3064 1900 130688 0 0 0 0 2341 1671 10 3 87
0 0 0 113908 3064 1900 130736 0 0 0 0 2431 1869 15 5 79
2 0 0 113908 3064 1900 130764 0 0 0 88 2346 1440 12 3 85
^C

real 0m9.486s
user 0m0.070s
sys 0m0.120s

[albatros:joe] $


A *very* simple program (top is probably a lot worse!) uses 1% on my Dual 1.4
GHz Athlon.

Those TEN lines of status output cost me 336 MILLION clock cycles.

>
>
> > However - having a human-readable /proc that you can use directly with
> > cat, echo, your scripts, simple programs using read(), etc. is
> > absolutely a *very* cool feature that I don't want to let go. It is just
> > too damn practical.
>
> You shouldn't use them in scripts because they are likely to break. That's
> the whole point. At least not when you want to distribute the scripts to
> others. And BTW the one-value-files are much easier to parse for scripts than
> any other solution that I have seen so far, including the current /proc
> interface.

I agree that there's some really good points in using single-value files.


--
................................................................
: jakob@unthought.net : And I see the elder races, :
:.........................: putrid forms of man :
: Jakob Østergaard : See him rise and claim the earth, :
: OZ9ABN : his downfall is at hand. :
:.........................:............{Konkhra}...............:
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

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