Data-oriented design and C++

Programming applications for making music on Linux.

Moderators: MattKingUSA, khz

Post Reply
User avatar
sadko4u
Established Member
Posts: 986
Joined: Mon Sep 28, 2015 9:03 pm
Has thanked: 2 times
Been thanked: 359 times

Data-oriented design and C++

Post by sadko4u »

After discussion about C++ and It's good and bad facilities here:

Code: Select all

https://linuxmusicians.com/viewtopic.php?f=44&t=16069
I just want to share video from C++ Con 2014:
Mike Acton "Data-Oriented Design and C++"
https://www.youtube.com/watch?v=rX0ItVEVjHc

IMHO real-time audio processing stays near to game development in terms of performance.
So I share it because this lecture may be useful for all who writes audio processing software.
LSP (Linux Studio Plugins) Developer and Maintainer.
Lyberta
Established Member
Posts: 681
Joined: Sat Nov 01, 2014 8:15 pm
Location: The Internet
Been thanked: 1 time

Re: Data-oriented design and C++

Post by Lyberta »

Here's another good video: https://www.youtube.com/watch?v=boPEO2a ... h&index=17

Note how many modern C++ facilities is used in the slides.
User avatar
sadko4u
Established Member
Posts: 986
Joined: Mon Sep 28, 2015 9:03 pm
Has thanked: 2 times
Been thanked: 359 times

Re: Data-oriented design and C++

Post by sadko4u »

FaTony wrote:Here's another good video: https://www.youtube.com/watch?v=boPEO2a ... h&index=17
Yes, it's good, especially for those who start to writing audio processing code.
Note how many modern C++ facilities is used in the slides.
Not too much. No exceptions, no new/delete, no STL and Boost in real-time code.
Also I know the better way to implement exchange between threads rather than using shared_ptr and atomics. The only thing that is really needed is atomics. But they may be implemented in other way by writing 10-20 lines of corresponding assembly code.
LSP (Linux Studio Plugins) Developer and Maintainer.
tnovelli
Established Member
Posts: 277
Joined: Wed Apr 20, 2011 4:52 pm

Re: Data-oriented design and C++

Post by tnovelli »

Yeah, that's some good stuff. In a nutshell, use C++ for convenience, but basically write C.

Anecdote #1: I had a realtime C++ program with modest STL usage (vectors and judicious use of maps, strings, streams). Valgrind showed me that STL methods were burning up the cache. The program is fast enough but it could easily be twice as fast/efficient, which would be nice for slower machines (and laptop batteries).

Anecdote #2: I was porting some JS graphics code to C++, lots of point arrays like [ [x1, y1], [x2, y2], ... ] which is pretty inconvenient for plain C APIs like OpenGL. So I switched to flat interleaved arrays [ x1, y1, x2, y2, ... ] like you see in a lot of old graphics algorithms. That's an efficient format for CPUs/GPUs. It actually worked better in Javascript too; that language lacks pointers/references, but this way I can reference an x,y pair by array index.
Lyberta
Established Member
Posts: 681
Joined: Sat Nov 01, 2014 8:15 pm
Location: The Internet
Been thanked: 1 time

Re: Data-oriented design and C++

Post by Lyberta »

You can use a lot of C++ features without sacrificing performance. Some people write C++14 for the Commodore 64.
Post Reply