Left 4 Dead 2 Runs Faster on Linux than Windows

Left 4 Dead 2 Runs Faster on Linux than Windows

If you have been living under a rock, Valve has been working on porting the Source Engine, Games based on the Source Engine and the full Steam client to Linux.

Now, if you’re wondering why they’re doing it, Gabe Newell, the co-founder and managing director at Valve believes that “Windows 8 is a catastrophe for everyone in the PC market.”

“We want to make it as easy as possible for the 2,500 games on Steam to run on Linux as well. It’s a hedging strategy. I think Windows 8 is a catastrophe for everyone in the PC space. I think we’ll lose some of the top-tier PC/OEMs, who will exit the market. I think margins will be destroyed for a bunch of people. If that’s true, then it will be good to have alternatives to hedge against that eventuality,” he shared when he made an appearance at Casual Connect, an annual video game conference in Seattle.

When Valve realized they needed to get games running on Linux, they started working on porting games built on the Source Engine.

Hardware

  • Intel Core i7 3930k
  • NVIDIA GeForce GTX 680
  • 32 GB RAM

Software

  • Windows 7 Service Pack 1 64-bit
  • Left 4 Dead 2
  • Ubuntu 12.04 32-bit

On a typical Windows machine, Left 4 Dead 2 scored around 270 FPS. The initial version of Left 4 Dead 2 on Linux ran at 6 FPS – basically just a reference that the port was successful.

Valve then focused on optimizing the game’s performance by working towards the following improvements,

  • Modifying our game to work better with the kernel
  • Modifying our game to work better with OpenGL
  • Optimizing the graphics driver

“An example of the first category would be changing our memory allocator to use more appropriate Linux functions. This was achieved by implementing the Source engine small block heap to work under Linux. The second category would include reducing overhead in calling OpenGL, and extending our renderer with new interfaces for better encapsulation of OpenGL and Direct3D.”

“The third category is especially interesting because it involves working with hardware manufacturers to identify issues in their drivers and, as a result, improving the public driver which benefits all games. Identifying driver stalls and adding multithreading support in the driver are two examples of changes that were the result of this teamwork.”

After all of this work, Left 4 Dead 2 is now running at an amazing 315FPS on Linux.

“Linux version running faster than the Windows version (270.6) seems a little counter-intuitive, given the greater amount of time we have spent on the Windows version. However, it does speak to the underlying efficiency of the kernel and OpenGL. Interestingly, in the process of working with hardware vendors we also sped up the OpenGL implementation on Windows. Left 4 Dead 2 is now running at 303.4 FPS with that configuration.”

After careful investigation to understand how an OpenGL version of the game is running faster than the Direct3D on Windows 7, Valve found that Direct3D in Windows suffers a few microseconds overhead per batch which does not affect OpenGL on Windows. Of course, they’ve also realized that hardware is capable of more performance and will work towards mitigating this effect for games running on Direct3D.

Source: Official Valve Blog