[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] pypy?



Hello,

It's been really interesting to see VMs over the last couple of years.

Now there are emulators, and virtualisers which are capable of running
x86 really quickly.  The processors themselves don't run x86 natively
anymore, it's a VM.

Now Apple are using x86, and x86 is getting more common in the
embedded world too.

So now, rather than creating a VM like python does it seems to make
sense to use the standard VM, and that is x86.  Of course x86 is
really complex, and still fairly slow to emulate on slow hardware.  So
using a simpler VM still has its advantages.

However writing directly to the most common VM has its advantages too.
You can make software which is 400 bytes big which can do almost the
same as a program 8000 byte program.  That's a 10x saving in program
size.  The same program will run in 12KiB of memory, instead of 1.7MiB
of memory.  That's a 141x memory usage saving.  Because the code size,
and memory size is so much smaller you can get a lot more done with
the same amount of memory.  You can run an entire OS and programs in
less memory than a python process uses on debian linux.  You can also
use a lot more of these tiny processes.  eg. for a single purpose
webserver you can handle 40,000 connections using fork and separate
processes in around 640MiB of ram with a duron 850.  Or 100
connections using 1.6MiB, which is less than a single apache process.

I find it very interesting, and think that assumptions about
processors and architectures that I learned 10 years ago are perhaps
changing.  The standard thinking is that fork is slow, and that you
should use event driven async for high speed.  Well it's not slow if
your processes are only 800 bytes worth of code.  Just enough code to
do the exact task at hand.

Communication between processes has become really quick now.  With
system calls on linux like slice, tee, and vmsplice you can get two
sockets transfering data directly without having to read data into
user space.  So you can take the output of a mpeg encoder and send it
directly to a file on the HD not even copying the data, at the same
time send it out on a socket through the network card.  All without
going into user space.

Processes and VMs can be transported between machines.  Mosix can move
processes amongst machines.  With emulators you can store the whole
state of the system in a file.  You can store your x86 system image in
a file, and move it to a different machine.

Then there's all this GPU general purpose computing stuff.  You can
run batch processes at 100x the speed of a cpu on these things.
There's still a lot of science being done to find good ways to
reimplement algorithms that work well, but lots has already been
learnt.  With the internet I think they have progressed much more
quickly than in the 50s-70s.  Chips like those found in the GP2X have
multiple cpus, DSPs, and all their IO devices all on the same chip.

- tiny programs.  http://asm.sourceforge.net/asmutils.html
- emulators and virtualisers http://fabrice.bellard.free.fr/qemu/
http://www.thefreecountry.com/emulators/pc.shtml
- mosix, distributing processes. http://www.mosix.org/
- general purpose computing use of GPUs http://www.gpgpu.org/
- tee, splice, and vmsplice in linux 2.6.17 http://kerneltrap.org/node/6505

There's lots to be excited about with the new ways people are
approaching VMs and computing.




On 8/30/06, James Hofmann <jwhinfinity@xxxxxxxxx> wrote:


--- Timothy Fitz <TimothyFitz@xxxxxxxxx> wrote:

> On 8/29/06, Kris Schnee <kschnee@xxxxxxxxxx> wrote:
> > Will I be able to use PyPy to build a Python emulator?
>
> What do you mean here by emulator?
>

"Python emulator" is kind of the wrong term to use, I think, because emulator
implies a complete system like a piece of hardware, wheras a programming
language is incomplete without the context of the platform, runtime
environment, implementation, etc. So a project like WINE counts as an
emulator(despite the title) because Windows is a software platform for x86
hardware. But languages are more "fuzzy" in their behavior and can't guarantee
a 100% compatible behavior when communication with the OS or hardware is
necessary. So we talk of varying implementations of a language and how they
compare with each other - Python has a de-facto standard, CPython, and a couple
of others, including PyPy.

So the answer to the original question is "sort of," since PyPy can build
itself, and build it to be functionally equivalent, but that doesn't mean it's
equivalent to CPython.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com