Wondered if I could get your thoughts on what I should do in this scenario.
Assume I have between 4 to 8 threads and I have a vector of values which will never be written to, only read by the threads.
I have the option of creating a copy of the vector for each thread and then no thread locking between the threads, trying to access a shared copy. Or, I could lock one copy of the vector and make all threads access that.
What is the latency of a thread lock, in comparison to copying the vector? How big would the vector have to be, to make the overhead of the lock faster than copying the vector?
If no thread ever writes to it, you can safely share it without any lock or copy. Data races can only occur if there are write accesses involved.