Information Technology Reference
In-Depth Information
available to the consumer thread. You can request no buffering to make
results available immediately. You can request full buffering, which will
increase performance at a cost of higher latency. Auto Buffering, the
default, provides a balance between latency and performance. Buffering is
a hint, not a demand. PLINQ may ignore your request.
I'm not providing any specific guidance on which of these settings is best
for you because they will be highly dependent on your algorithm. How-
ever, you have those settings that you can change, and you should experi-
ment on a variety of target machines to see if these will help your
algorithms. If you don't have several different target machines to experi-
ment with, I'd recommend using the defaults.
PLINQ makes parallel computing much easier than it previously was. It's
an important time for these additions; parallel computing will continue to
become more important as more and more cores become commonplace
for desktop and laptop computers. It's still not easy. And poorly designed
algorithms may not see performance improvements from parallelization.
Yo u r t a s k i s t o l o o k f o r l o o p s a n d o t h e r t a s k s t h a t c a n b e p a r a l l e l i z e d . Ta k e
those algorithms and try the parallel versions. Measure the results. Work
on the algorithms to get better results on the performance. Realize that
some algorithms aren't easily parallelizable, and keep those serial.
Item 36: Understand How to Use PLINQ for I/O Bound
Operations
The Parallel Task Library looks like it would be optimized for CPU bound
operations. While that is a core mission for the library, it does work well
with I/O bound operations as well. In fact, the design of the Parallel Task
Library handles I/O bound operations rather well by default. It will update
the number of threads allocated to your algorithms based on the how busy
those threads are. More blocked threads (waiting for I/O operations) will
result in the ThreadPool allocating more threads to the tasks at hand.
As with other parallel extensions, you can use method calls, or LINQ query
syntax to opt into a parallel execution model. Parallel execution for I/O
bound operations behaves a little differently than CPU bound operations.
Yo u ' l l o f t e n w a n t m o r e t h r e a d s t h a n c o r e s , b e c a u s e t h e I / O b o u n d t h r e a d s
spend more of their time waiting for some external event. PLINQ provides
a framework for these idioms as well.
 
 
Search WWH ::




Custom Search