|
|
> -----Original Message-----
> From: Warp [mailto:war### [at] tagpovrayorg]
> Chambers <ben### [at] pacificwebguycom> wrote:
> > Boost isn't slow. Mutexing is slow (relatively).
>
> Boost mutexes are actually the slowest I have tried, although not by
> a
> very large margin.
> (interesting stuff about mutexing snipped)
Yes, I'm aware of different designs for mutexes. In fact, the fastest
way to deal with them is to design your container such that they aren't
even needed. However, the only paper I've seen that said such a thing
advocated using immutable state instead.
That is, once a variable is created it cannot be modified. In the case
of a container, you don't actually change the container; you make a
copy, set the reference to point to the modified data, and dump the
original data.
I was so impressed that I implemented a few tests of the idea just to
get a feel for it. It CAN be extremely fast, and threading CAN work
effectively with it, but generally it's a pain in the a** and, if done
wrong, you can screw up your data or get a big slowdown. And you're
still faced with the race conditions when radiosity samples depend on
other radiosity samples (that is, the result of sampling depends on what
other samples are taken - but in a threaded environment, we don't know
what samples will be taken first).
Would it be faster if different threads rarely accessed the same locked
data? We could split the sample tree into several smaller trees
(sub-trees, if you will) based on scene geography (grouping close
samples in the same tree). Then, when performing sampling, a thread
would be most likely to only need access to a few of the sub-trees
(those nearest), and rarely the sub-trees further away. If you only
have a few threads, then the chances of multiple threads needing the
same sub-tree at the same time are minimized. Having more threads would
add more overhead, of course, because thread collision is more likely.
Or, depending on the implementation of the tree, you wouldn't need to
lock the whole tree, just one particular node and all it's sub-nodes.
Of course, I don't even know if such a thing would speed things up at
all, or if it's a pointless optimization.
...Ben Chambers
www.pacificwebguy.com
Post a reply to this message
|
|