#3,539 in Computers & technology books
Use arrows to jump to the previous/next product

Reddit mentions of C++ High Performance: Boost and optimize the performance of your C++17 code

Sentiment score: 1
Reddit mentions: 1

We found 1 Reddit mentions of C++ High Performance: Boost and optimize the performance of your C++17 code. Here are the top ones.

C++ High Performance: Boost and optimize the performance of your C++17 code
Buying options
View on Amazon.com
or
Specs:
Height9.25 Inches
Length7.5 Inches
Number of items1
Release dateJanuary 2018
Weight1.4109584768 Pounds
Width0.85 Inches

idea-bulb Interested in what Redditors like? Check out our Shuffle feature

Shuffle: random products popular on Reddit

Found 1 comment on C++ High Performance: Boost and optimize the performance of your C++17 code:

u/willf_dev ยท 2 pointsr/cpp_questions

Yes there are, in audio we use vectors all the time and we often access them in a lock-free way.


I highly suggest two resources:

https://www.amazon.co.uk/High-Performance-Boost-optimize-performance/dp/1787120953/ref=sr_1_1?ie=UTF8&qid=1540597989&sr=8-1&keywords=high+performance+c%2B%2B

https://www.youtube.com/watch?v=qdrp6k4rcP4


I am actually writing something with Peter Doumler on this exact subject but might as well answer your question now.

Basically making a lock-free data structure is a checklist.

  1. Use atomics correctly to avoid data races
  2. No memory reallocation
  3. No Locks

    You can use atomics on values that are small enough or trivially copyable. Atomics also require hardware support but that is the case for most modern systems. So you can get Atomics for int, bool, and * . This is actually sufficient. Some hardware does allow for atomic float but this is far from normal. So basically if you need atomic access to a float, you must use pointers. If you look at those resources then it will make sense.

    So basically you might want to consider making a custom data structure called a ring buffer. This is discussed in both of those resources. A ring buffer is essentially a vector with a read head and write head. The write head obviously writes data to the vector and the read head swaps empty for the value. In other words, that read head will take the value and replace it with nothing. These heads could be indeces but you could make a pointer to a value.

    When a ring buffer is made, it is of a fixed size. This size cannot change as that requires memory re-allocation which creates locks. The reader and writer increment through this fixed size buffer and when they get to the end of the vector they loop back around. If the buffer is full, then the read head is one behind the write head. If the buffer is empty, then the read head and the write head point to the same location. This ensures that there are no data races as:

  4. The only time you are accessing the same place in memory is when the vector is empty.
  5. You are only carrying out one operation on a places in memory at one time.

    It is possible to have more than one read head. However, most people just tend to use ring buffers in the way I described.

    Hope this helps.

    But you may not want to make a ring buffer yourself as there are some available already. Boost has one which was already linked to you.

    RingBuffer aka Lock-Free FIFO

    ​