New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[needs testing] make distutils compile Cython extensions in parallel #4652
Comments
comment:1
Attachment: build_ext.py.gz Just out of curiosity, did you try to get this to work without modifying build_ext.py at all, but by simply changing stuff in that module at runtime, like I illustrate in #3765? Here's the diff of what you did:
|
comment:2
POSITIVE TESTING: I just want to comment that I used this a lot all day today on both OS X and Linux, and didn't have a single problem. I like it! |
comment:3
This has been in my tree for more than a week on a Mac OS X 10.5 machine. I have been doing some fairly heavy development, although most has not been in Cython. No problems to report; I say merge.
|
comment:4
There is a slight chicken and egg problem here since we build pyprocessing after python, so if someone sets the wrong environment variable the build of Python itself will blow up. To fix this:
Then this should work out of the box, even though we should still test this with a couple rounds of builds of Sage with a high parallel level to make sure we do not hit any race conditions. Cheers, Michael |
comment:5
After some chit chat with Craig we agreed that this should go into the enf of the pyprocessing spkg-install. That way everything is in place even for a fresh build. Cheers, Michael |
comment:6
The spkg at http://sage.math.washington.edu/home/mabshoff/release-cycles-3.2.2/alpha2/pyprocessing-0.52.p0.spkg contains the fix. I tested it in various configs and it works for me :) Cheers, Michael |
comment:7
This breaks at least the numpy and scipy build, so I am reverting for now. Cheers, Michael |
comment:8
Some more info: even unsetting SAGE_PARALLEL_DIST does not fix the problem, bot numpy and scipy fail in different work. So while this is useful when merging patches it breaks too easily on -upgrade or a build from scratch. Cheers, Michael |
Attachment: trac-4652-testing.patch.gz |
comment:9
Ok, new version of the code is up. This is done differently than last time; rather than patch our python, I'm simply inserting the code in our So, to test this, do the following:
If this seems to work for people, then we can try building Sage from scratch with it. (I'm going to try setting my machine to do that overnight with |
comment:10
Okay, I ran a build from scratch with this in place, and it worked fine. In particular, it doesn't cause scipy or numpy to fail at building, which was the goal. So I'm curious what other people say -- if everyone spoke up real fast, should we try to push this into 4.0.1? (I know several developers have been clamoring for it.) |
comment:11
I have certainly been clamoring but I'd really like to see this go through an alpha revision and get tested on multiple platforms before we ship it. Thanks for doing this, Craig! |
comment:12
I've merged trac-4652-testing.patch in 4.0.1.rc3. |
Merged: 4.0.1.rc3 |
Author: Craig Citro |
Currently, we've got excellent code to run Cython in parallel as part of the Sage build process. However, once we ask distutils to begin compiling that code, everything is done in serial, because distutils works solely in serial.
The Code
The attached file changes that. This (somewhat brutally) hacks distutils to dispatch the calls to build C/C++ extensions in parallel, using pyprocessing. (I totally jacked William's code from #3765 for this.) Here's how to put this code in place:
build_ext.py
)$SAGE_ROOT/local/lib/python2.5/distutils/command/build_ext.py
with the new version.Now, if you want to test the new code, do the following:
SAGE_PARALLEL_DIST
to something. (The code just checks to see if the variable is defined at all.)MAKE
toMAKE -j2
, where2
is replaced by the number of simultaneous build processes you want.Notes
If you want to test this, don't go around touching the
.pyx
files in the Sage library, since Cython is much slower thangcc
. Instead, simply go around touching the.c
and.cpp
files in$SAGE_ROOT/devel/sage/sage
. One of the cool features we added with the new build system is that these files get recompiled when they change.There is now a line that prints as part of the build process that looks like:
So try touching a bunch of files in the Sage library, and seeing what kind of speedups you get.
There are two caveats I want to offer with this code:
The Plan
So while this code is cool, and will definitely save a ton of CPU time on
sage.math
(cough mabshoff cough), the plan is not to maintain it as a part of the Sage Python spkg indefinitely. Instead, if it seems to work well, then we should try to clean this code up a bit more and upstream it, since pyprocessing is standard in Python 2.6.Component: build
Author: Craig Citro
Merged: 4.0.1.rc3
Issue created by migration from https://trac.sagemath.org/ticket/4652
The text was updated successfully, but these errors were encountered: