LWN.net Logo

Still waiting for swap prefetch

Still waiting for swap prefetch

Posted Jul 26, 2007 8:28 UTC (Thu) by rsidd (subscriber, #2582)
In reply to: Still waiting for swap prefetch by pointwood
Parent article: Still waiting for swap prefetch

There's nothing wrong with python (or other high-level languages), and it worked fine on linux systems 10 years ago. C is faster only for CPU-bound tasks, which hardly any system tasks are. C may be less memory intensive (it depends on what libraries you're using, what your coding style is, and so on), but with C you have to be careful about all kinds of bugs and security holes (buffer overflows, memory leaks, etc) that even experts get bitten by, but don't occur with high-level languages.


(Log in to post comments)

Still waiting for swap prefetch

Posted Jul 26, 2007 12:23 UTC (Thu) by rwmj (subscriber, #5474) [Link]

Oh dear no there's _plenty_ wrong with Python. It's dynamic
typing nature means that simple objects have huge amounts of
baggage that they have to carry around, mostly never used.

C sucks for programming too, for the reasons you outline.

But guess what folks! C and Python are not the only programming
languages in the world!! You won't believe it, but other
programming languages have been invented.

My personal fave at the moment is OCaml. About as fast as C,
statically typed, no buffer overflows, small memory footprint,
access to Perl & Python libraries, and loads of native libs.

Rich.

Still waiting for swap prefetch

Posted Jul 27, 2007 11:56 UTC (Fri) by IkeTo (subscriber, #2122) [Link]

> C and Python are not the only programming
> languages in the world!! You won't believe it, but other
> programming languages have been invented.

> My personal fave at the moment is OCaml. About as fast as C,
> statically typed, no buffer overflows, small memory footprint,
> access to Perl & Python libraries, and loads of native libs.

Two suggestions. Suggestion 1: start lobbying people all around to start using OCaml: universities, companies, etc. If you are successful you have a bunch of people who *know* what it is (currently the people with that characteristics are so few that it doesn't matter). Or choose suggestion 2: start implementing some *real cool* thing in OCaml, making sure that developing the equivalent thing (e.g., with same performance, flexibility, etc) is so expensive that nobody can do *because of a choice of different language*. Then you serve as an example showing others the real benefit of the language.

Before you do so, accept that languages behaving the same way as in C or Python are those who know by those who work on creating applications. Problem is, money talks. If the industry do need C and Python, that's what's university courses teach, that's what's people know, and that's what applications will be written in.

Still waiting for swap prefetch

Posted Aug 2, 2007 7:40 UTC (Thu) by renox (subscriber, #23785) [Link]

My problem with Ocaml is its syntax and its functional mindset: I tried once to learn Ocaml and I disliked the syntax plus the PDF book I used insisted on using functional way to solve everything which is strange as Ocaml is said to support both imperative and functional style, why the book insisted so much on the functional style is beyond me, bleach.

So to be successful, Ocaml would need 2 things:
1) replace the current default syntax with a better one.
There is already an alternative syntax for Ocaml (so apparently I'm not the only one who don't like the default syntax), it's quite better and F# (an Ocaml clone for .Net) 's syntax looks even better.
2) improve tutorials book to teach both imperative style and functional style, without having such blatant bias towards functional style, it has its place but not for everything.

Somehow I doubt that will happen, so Ocaml is bound to stay in the limelight..

Still waiting for swap prefetch

Posted Jul 26, 2007 15:15 UTC (Thu) by arjan (subscriber, #36785) [Link]

> There's nothing wrong with python

... except that even a simple "hello world" seems to take 40 megabytes of memory. It's not about a few cpu cycles that kills you in performance, it's the enormous overhead that even simple programs get....

Still waiting for swap prefetch

Posted Jul 26, 2007 17:11 UTC (Thu) by vmole (guest, #111) [Link]

That is so much crap.
$ cat hello.py
import time
print "hello, world"
time.sleep(30)

% python hello.py &
[1] 25243
hello, world
$ ps l -C python
F   UID   PID  PPID PRI  NI    VSZ   RSS WCHAN  STAT TTY        TIME COMMAND
0  1000 25446  2688  17   0   3844  2256 -      S    pts/0      0:00 python hello.py

So that's 2M resident, 4M virtual. And it exagerates a simple "hello world" program, because I had to import the time module for sleep() so I could run ps. Most of it is the interpeter itself, so multiple python programs don't actually take 4M each.

Python isn't perfect - what language is? But don't make stuff up, it just ruins your argument.

Still waiting for swap prefetch

Posted Jul 26, 2007 19:01 UTC (Thu) by nevyn (subscriber, #33129) [Link]

Let's try longer than 30 secs, eh?

% ps ax -o cmd:50,vsz,rss,stime | egrep '[p]ython'
/usr/bin/python -E /usr/sbin/setroubleshootd       808024 12104 Jul06
python /usr/share/system-config-printer/applet.py  232764  6436 Jul06
/usr/bin/python -E /usr/bin/sealert -s             411728 18524 Jul06
python /usr/libexec/revelation-applet --oaf-activa 458328 55056 Jul06
python /usr/lib64/gdesklets/gdesklets-daemon       453980 65768 Jul23
python ./hpssd.py                                  171220  1176 Jul11

...that's 2_536_044 KB VSZ and 159_064 KB RSS, and as you can see I've rebooted gdesklets recently (it was roughly double that, I think).

Plus I'm not running pupplet/yum-updatesd atm. And for instance "revelation-applet" is just a text entry box 95% of the time.

I appreciate that the huge VSZ numbers are (hopefully) mostly unused shared libs. etc. but half a GB is still a lot for the OS to manage for a text box, and 40+MB of RSS for a simple GUI is far from "so much crap".

For comparison my webserver uses two processes with a VSZ of about 12MB each and RSS of about 1MB each, and I'd prefer that to be smaller.

Still waiting for swap prefetch

Posted Jul 26, 2007 19:24 UTC (Thu) by vmole (guest, #111) [Link]

You said "a simple hello world" program, and that's what I tested. Comparing GUI programs to a webserver is irrelevant. What you've mostly demonstrated is that that GNOME/GTK is huge. Blaming that on Python doesn't seem to make sense. I'd bet a Perl implemenation of the same programs would be equally huge.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds