mixxxdj / mixxx

Mixxx is Free DJ software that gives you everything you need to perform live mixes.
http://mixxx.org
Other
4.24k stars 1.24k forks source link

Optimize control code #13354

Open JoergAtGithub opened 2 weeks ago

JoergAtGithub commented 2 weeks ago

This PR collects several low level optimizations for our control code. See the single commit messages.

We have currently 36816 ControlDoublePrivate instances in Mixxx the memory realignment reduces the size from 464 byte to 448 byte, this translates to 0.5 MegaByte heap memory reduction. Furthermore the first fields are aligned to fit into a 128 byte SSE register. But I guess there are very few operation, which can benefit from an SSE copy etc. (in theory we could further optimize for SSE, by reducing ControlValueAtomic from 136byte to 128byte).

Old memory alignment: ControlDoublePrivateBefore

New memory alignment: ControlDoublePrivateThisPR

daschuer commented 2 weeks ago

The reason that ControlDoublePrivate is so big is a nasty regression. It should be only for bites. The fix is here: https://github.com/mixxxdj/mixxx/pull/13355

JoergAtGithub commented 1 week ago

I merged in the changes from #13355, but I noticed, that the memory consumption of ControlDoublePrivate is much bigger in this Main branch, than in the 2.4 branch.

2.4: grafik

Main: grafik

This PR: grafik

daschuer commented 1 week ago

I assume you build main with Qt6 and 2.4 with Qt5. Maybe the sizeof(QString) has changed due to the Small String Optimization?

JoergAtGithub commented 1 week ago

I assume you build main with Qt6 and 2.4 with Qt5.

Yes, I did!

daschuer commented 1 week ago

Qt6 has no SSO. The number increased due to the use of a common QArrayDataPointer with holding two pointers one the header for implicit sharing, one to the actual data and one to the size which is now also 64 bit. This allows faster read only access and allows to the store strings longer than 2.147.483.648 characters (more than 480 Bibles)