[Python-Dev] Python 2.4, VS 2005 & Profile Guided Optmization

Trent Nelson tnelson at onresolve.com
Sun Jul 23 19:42:59 CEST 2006


Hi,

Has anyone else built Python with Visual Studio 2005 and played around
with Profile Guided Optimization?  I had to build Python from source w/
VS 2005 as I had a few .pyd's built with VS 2005 that I wanted to load;
I ended up playing around with Profile Guided Optimization, running
``python.exe pystones.py'' to collect call-graph data after
python.exe/Python24.dll had been instrumented, then recompiling with the
optimizations fed back in.  

Results were interesting, an average speedup of around 33% was
noticeable:

ActiveState 2.4.3 python.exe:

    C:\Python24>python.exe Lib\test\pystone.py
    Pystone(1.1) time for 50000 passes = 0.980119 This machine
benchmarks at
    51014.2 pystones/second

The python compiled from branches/release24-maint with VS 2005 + profile
guided optimization:

    C:\Python24>python.exe Lib\test\pystone.py
    Pystone(1.1) time for 50000 passes = 0.73261 This machine benchmarks
at
    68249.2 pystones/second

Is there any motivation in the Win32 Python dev camp to switch from VC6
to VS 2005?

FWIW, although there were a shed-load of warnings when compiling python
and pythoncore (and a lot more errors when compiling other modules), I
only had to apply one patch to get it working well enough to run
pystone.py.  Without this patch, the VC8 CRT aborts at runtime as soon
as an invalid signal is passed to signal(); which is inevitable given
the current code in the initsignal() method:

	for (i = 1; i < NSIG; i++) {
		void (*t)(int);
		t = PyOS_getsig(i);


Regards,

	Trent.

--
http://www.onresolve.com


Index: signalmodule.c
===================================================================
--- signalmodule.c	(revision 47196)
+++ signalmodule.c	(working copy)
@@ -280,7 +280,21 @@
 	{NULL,			NULL}		/* sentinel */
 };
 
+#define WIN32VS2005HACK
+#ifdef WIN32VS2005HACK
+#include <stdio.h>
+#include <stdlib.h>
+#include <crtdbg.h> 
+void dummy_handler(const wchar_t *exp,
+                   const wchar_t *fn,
+                   const wchar_t *file,
+                   unsigned int line,
+                   uintptr_t reserved)
+{
 
+}
+#endif
+
 PyDoc_STRVAR(module_doc,
 "This module provides mechanisms to use signal handlers in Python.\n\
 \n\
@@ -339,6 +353,12 @@
                 goto finally;
 	Py_INCREF(IntHandler);
 
+#ifdef WIN32VS2005HACK
+        (void)_set_invalid_parameter_handler(&dummy_handler);
+        _CrtSetReportMode(_CRT_ASSERT, 0);
+#endif
+
+
 	Handlers[0].tripped = 0;
 	for (i = 1; i < NSIG; i++) {
 		void (*t)(int);


More information about the Python-Dev mailing list