Stackless Python 2.5
As you may well know, your favorite space-game owes its existence to the programming language Python and particularly, a variant thereof called Stackless Python. When EVE was released in 2003 it had version 2.1 under the hood and a year later we upgraded this to a brand new version 2.3, skipping version 2.2 in the process. Since the move to version 2.3 not much has happened, or at least as far as Stackless and EVE are concerned.
That was not the case for the Python community though. The man behind Stackless, Christian Tismer, rewrote the internals of Stackless for version 2.3, which we called Stackless 2.3.1. This would form the platform for Stackless in the later versions of Python, including 2.4 and 2.5. At that point, we had a difficult decision to make because the logistics of maintaining a large software project made it difficult for us to make a large core change in the binaries. Facing questionable benefits and a risky deployment, should we make the jump?
Then several things changed:
- Python moved on. Version 2.4 was released and version 2.5 started in development.
- An increased focus on performance became apparent within the Python community, which culminated in the NeedForSpeed sprint in Reykjavík in the spring of 2006, of which CCP was a co-sponsor.
- Microsoft released Visual Studio 2005, which includes improved optimization, particularly Profile Guided Optimization, and honed it with a service pack earlier this year.
All of this meant that there was now a good reason for us to upgrade to Stackless Python 2.5.
From a programmer's perspective, the changes were not that great. On the C++ level, we needed to make minor adjustments to the low-level API of Python, as well as a revamped API for Stackless. Since we were doing C-level changes, we decided to separate the Stackless runtime out into a DLL and standardize the bindings to it. This also simplifies the process of running the Profile Guided Optimization step during the build process.
The Python programmer sees only minor changes, as all old code continues to work. The biggest change, which did cause some problems, was that Exception objects have been changed to be so-called "new style" instances, and behave slightly different. However, the Python programmer will benefit from some brand new cool features in 2.5 that weren't present in the old version, including:
- A Ternary operator
- Function decorators
- Generators and Generator comprehensions
The associated changes were performed in a separate branch and thoroughly tested. We have seen a considerable performance increase. This increase is primarily due to two things:
- Python itself has been carefully optimized and common operations made faster, and
- Profile Guided Optimization of the Python DLL works really well.
An additional logistical benefit is now that we're back to using the cutting edge version of Stackless Python (2.5.1 to be precise), it is much easier for us to keep in step with future Python developments, including the forthcoming version 2.6.
Integration back into the main branch has been performed and counter to the associated risks, all tests indicate that the upgrade will result in a juicy performance boost.