Kilka tygodni temu, jeden z graczy PlanetSide 2 odkrył tajemniczy proces, który znacznie obciążał procesor. Po jego wyłączeniu, zużycie CPU spadało bez wpływu na samą grę.

To właśnie odkrycie zapoczątkowało „wewnętrzne śledztwo” przeprowadzane przez Joshue „Autenil” Kriegshauser – dyrektora technicznego PlanetSide 2, który być może odkrył z jakiego powodu następowały skoki obciążające procesor.

Naprawdę nie będę nawet próbować tłumaczyć jego zbyt-technicznego-jak-na-mój-gust wyjaśnienia i jeśli ktoś ma ochotę wytłumaczyć mi w prostych słowach to będę wdzięczna. Dość powiedzieć, że gdy poprawka będzie gotowa, zostanie ona od razu wprowadzona na serwery Live…

Technical details follow:

A threading library that we use was originally written for Linux, which made it effective for the PS4 since PS4 uses a BSD-based kernel. There was a bug in the Windows port of the library that was relying upon a feature that Linux has but isn’t as complete in Windows (select()) and another port of a BSD-only feature (kqueue). Things were similar enough that it would work, but it had a very bad degenerate case that we didn’t notice for a long time: a thread would busy-loop (tying up a whole CPU usually) while waiting for time to pass. Usually we try to write things so that threads sleep when waiting for time to pass, as this allows the system to do other things. We didn’t notice the problem right away because it’s buried deep inside a library that we didn’t write.

NOTE! Killing high-CPU threads in the game client is ill-advised at best! Likely bad things will happen! This /used/ to work though because this thread was busy-looping while waiting, so by killing it, you were killing off all of the things that we use these types of timers for, like garbage collection. So by killing off the thread, the game would run, but you would be leaking memory slowly over time. Now, however, that problem has been solved. So if you’re picking a high-CPU thread, it’s probably doing something super important, like updating actors, or rendering, or animation, etc.

Anyways, we’re not using this type of timer from the library anymore and I wrote one that accomplishes the same thing but sleeps nicely while waiting for timers to expire.

Oh btw, the threads in question were not Scaleform threads. Process Explorer doesn’t have symbols for the entire game (something that we keep internal), but it might have symbols for some of our third-party libraries. Since that’s the closest thing it could find, that’s what it named it (but with a HUGE offset; that’s how you know it’s not actually in the Scaleform code).