hrydgard/ppsspp

Reduce and align class-structs size for 64-bit CPU

GermanAizek opened this issue · 1 comments

It has strong performance effect on older CPU or modern CPU without L3 cache aka all Intel Atom or AMD A6-xxxx with AVX2 with release year 2018.

@hrydgard, Do you think it makes sense for me to do this? I understand that few people use old laptops, computers before 2008-2009 as an emulator. Back then, it was rare to have an L3 cache, it was considered expensive or it was on the motherboard. I also doubt that anyone is sitting on smartphones before 2014-2016. On modern processors, this will give maximum 10-20% performance for CPU, but there will be a lot of changes in code declare structures and classes.

I would like to have a discussion on this topic.

Optimization strat struct memory layout in CPU cachelines (64 bytes common) this reduce precission types (float to _Float16, int to short and etc), using bit-fields (for compact, and remove padding bytes) and align by 8 bytes (desirable to have size structures in multiples 64 bytes).

References about optimization method:

I'm not aware of any structs in the code base that are accessed in such a very hot way that this would matter at all - that also isn't already properly aligned with size-sorted fields.

So I don't think this is really something worth looking into much. If you have analyzed the code base and found a particular struct that's badly aligned and accessed a lot, maybe it's worth looking at that one, but going over it in general is not worth it - there are a huge amount of structs that are only used very occasionally.