Sage forker

67 views
Skip to first unread message

Jeroen Demeyer

unread,
Jan 15, 2011, 1:43:47 AM1/15/11
to sage-devel
This afternoon, William gave me a really cool idea of starting up Sage
using fork(). Essentially you have one mothersage which forks off
copies of Sage. Like this, you can get an instant Sage prompt because
Sage is already started. I actually implemented this and it seems to
work (at least under Linux, I haven't tested other systems).

I'm not sure how robust it is, but if you want to play with it, you can
find the code at http://sage.math.washington.edu/home/jdemeyer/forker/


First of all, you need to compile
$ gcc fsage.c -o fsage


Then, start up the mothersage:
$ sage
----------------------------------------------------------------------
| Sage Version 4.6.1, Release Date: 2011-01-11 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
sage: load "sage-forker.pyx"
Compiling ./sage-forker.pyx...
sage: sage_forker()


Now open a new terminal and watch the Sage prompt appear without delay:
$ ./fsage
----------------------------------------------------------------------
| Sage Version 4.6.1, Release Date: 2011-01-11 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
sage:


Have fun with it and who knows if this might actually be useful.

Jeroen.

Volker Braun

unread,
Jan 15, 2011, 1:19:24 PM1/15/11
to sage-...@googlegroups.com
Maybe combine it with a zeromq-based main loop for the worker Sage process. Then the notebook worker and the command line Sage would use the same codebase...

Of course this is just psychological and won't speed up any actual computation ;-)


Robert Bradshaw

unread,
Jan 15, 2011, 3:20:00 PM1/15/11
to sage-...@googlegroups.com

This is exactly what I was thinking about doing for the notebook
worker processes too. It would be a huge boon for testing as well.

- Robert

Ivan Andrus

unread,
Jan 15, 2011, 5:16:14 PM1/15/11
to sage-...@googlegroups.com
> This afternoon, William gave me a really cool idea of starting up Sage
> using fork(). Essentially you have one mothersage which forks off
> copies of Sage. Like this, you can get an instant Sage prompt because
> Sage is already started. I actually implemented this and it seems to
> work (at least under Linux, I haven't tested other systems).

FWIW it seems to work fine on OS X 10.6.

> I'm not sure how robust it is, but if you want to play with it, you can
> find the code at http://sage.math.washington.edu/home/jdemeyer/forker/
>
>
> First of all, you need to compile
> $ gcc fsage.c -o fsage
>
>
> Then, start up the mothersage:
> $ sage
> ----------------------------------------------------------------------
> | Sage Version 4.6.1, Release Date: 2011-01-11 |
> | Type notebook() for the GUI, and license() for information. |
> ----------------------------------------------------------------------
> sage: load "sage-forker.pyx"
> Compiling ./sage-forker.pyx...
> sage: sage_forker()
>
>
> Now open a new terminal and watch the Sage prompt appear without delay:
> $ ./fsage
> ----------------------------------------------------------------------
> | Sage Version 4.6.1, Release Date: 2011-01-11 |
> | Type notebook() for the GUI, and license() for information. |
> ----------------------------------------------------------------------
> sage:

Sort of a tty server instead of a notebook server.

> Have fun with it and who knows if this might actually be useful.
>
> Jeroen.

I'm not sure I completely understand the code, but it looks like this can't be used to speed up `sage -c`, is that right?

-Ivan

Reply all
Reply to author
Forward
0 new messages