Original Post — Direct link
about 6 years ago - /u/RiotTony - Direct link

Originally posted by trc1234

It's C++, but I don't think any programmer should limit what jobs they can take by the languages they know. Languages are syntactically different, but the underlying concepts and design patterns are identical so new languages should be pretty easy to pick up (unless they are in a completely different paradigm of course). Especially since the field is changing so fast and many languages are no longer being used (for example VB6 is basically dead except a few crazy excel programmers use it) and many new languages are appearing.

This kind of assembly level optimisation the article was talking about is particularly niche topic which most programmers do not need to be too concerned about (this is probably true at Riot too). And I'm sure at Riot they use many different languages as well as hiring many different programming roles.

I totally agree that a programmer shouldn't limit themselves to a single language - the more you know, the more you know. And yes, Riot does use other languages in different roles.

The assembly is there to illustrate the cause of the slowdowns - you very rarely (if ever) need to drop down the assembly on modern HW, but it does help to understand what is going on under the hood which can in turn help you to write more performant code at the top level.

about 6 years ago - /u/RiotTony - Direct link

Originally posted by velrak

Am i understanding that image right and rendering the HUD takes about the same amount of time as the entire rest of the graphics? That seems crazy

There is a surprising amount of work going on in there: scaling, compositing, updating, animating - lots of triangles, lots of textures. That was not a release build either, so there is some extra work going on in there that doesn't happen in LIVE builds.

I agree though, it is a considerable portion of the frame and while some work has been done since that screen shot to improve that, there is more that we should be able to do to in the future.

about 6 years ago - /u/RiotTony - Direct link

Originally posted by [deleted]

If Im looking to work for Riot someday, how much of this sort of thing should I know, as far as this sort of code optimization and assembly? Im a CS major but honestly it feels like they never teach anything about practical real world software development :/

Depends on what you want to do there. If you want to do performance optimisation, then yeah, you'll should know it or be able to learn it on the job. But most of an engineers work is much higher level than this. Having said that, every engineer should be able to measure the performance of their code and understand how to speed it up if needed.

If your CS major isn't teaching yourself anything useful, you can always teach yourself. There is so much information out there for budding programmers and the best way to learn is to do. Build systems, write code for yourself. The more you code, the better you get.

about 6 years ago - /u/RiotTony - Direct link

Originally posted by C0ldSn4p

/u/RiotTony : Actually you can inline virtual function if you statically force the call of a precise function implementation

Here is a code sample:

// Compile with: icpc -std=c++11 -O2 main.cpp 
#include <stdio.h>

class Base {
  public:
    virtual int foo() {return 42;}
};


class Child : public Base {
  public:
    int foo() {return 69;}
};

void bar(Child c) {
  printf("%d", c.Child::foo());
}

void bar2(Child c) {
  printf("%d", c.Base::foo());
}

int main(){
  Child c;
  bar(c);
  bar2(c);
}

If you run it you will get the output 6942 showing that first foo from the child was called and the foo from the base (despite using a child object). Also if you look at the assembly (-S option at compilation) you can see in the method bar and bar2 that the values 42 and 69 are hardcoded proving that the correct foo methods were inlined despite being virtual one.

Ofc this is a very specific use case but still, virtual doesn't always mean that you have to give up performances and inlining

Yeah, there are ways around the virtual overhead, but the benefit of virtuals are that you don't need to know what it is that you're calling a given function on. Most use cases are just that - a collection of objects that are similar, but different enough to warrant different implementations of some of their parts. Another way to mitigate the cost of virtuals is to sort them by type. In that case you have far fewer I and D cache misses as you're usually calling the same functions. Modern HW is smart enough to predict the repeated branches.

about 6 years ago - /u/RiotTony - Direct link

Originally posted by LoLFirestorm

Will league ever get multithreaded without a complete game and graphics engine rework?
I'm no programmer but I believe the stuff like UI which is not super time sensitive down to tenths of a milisecond could be executed on a separate core just fine with some work and as far as I'm aware this doesn't take place right now.
My current system is very much an edge case but it's absolutely hilarious to me that I can run Doom 2016 at ultra settings and get 100-120FPS with dips to 80 and on the very same machine league will hover in 60-80 range after leaving the fountain and dip as low as 30 in super lategame teamfights. This is at a mix of medium and high settings btw but these seem to make basically no difference when the bottleneck is on the CPU side like in my case (I'm still running a Phenom II after all these years but I got myself an RX 480 before the mining boom).
I don't think it's alright that even proffesional streamers running pretty beastly builds and encoding on a separate computer with a capture card are often far from saturating a 144Hz monitor with frames during teamfights.

League is already partially multithreaded, although I'll be the first to admit that it could make far better use of more threads. It is something that we are working on - engine rework is ongoing, but with the game changing constantly, this is like rebuilding an airplane engine while its flying. We have to be very careful that we don't break anything as we go.

You have correctly surmised that the main performance issue is a CPU bottleneck - in a team fight we're dealing with a lot of particles, and this can be costly. In fact, there is a break down of the rendering pipeline here which will give you some idea of what's going on.