locked
Parallel processing RRS feed

  • Question

  • User-1101168317 posted

    I want to improve my application performance. 

    i have a function GetDistanceTime function which takes parameters.

    the function is called many many times depending upon the number of employees.

    for example if i have 3 employees the function is called 3 times i.e for emp1-> emp2 , emp1->emp3 , emp2->emp3.

    for now i have taken only 3 employees but i want this count for almost 5000. so the number of times the function will be called is very very high.

    i want to know what i can do to speed up this operation. i am not aware of threading can we do using it.?

    or any parallel processing possible???

    Thursday, May 27, 2010 8:55 AM

Answers

  • User-525215917 posted

    You have three options and you should try out each one of them to see which one performs best for you:

    1. use serial calls to make calculations
    2. use threads to make calculations
    3. use Parallel Extensions to make calculations

    Handling threading issues manually may not be best thing to do although you may achieve very good results. The other edge of this sword is that threading issues are usually hard to debug and sometimes it is very hard even to reproduce problems related to threading (Clean Code by Robert C. Martin has excellent appendix about threading issues).

    Parallel Extensions, imho, will give you the best results, bacause you have large number of operations. Make sure that calcucation functions does not use same instances of objects because this way you may end up with chaos. I have seen that Parallel Extensions perform not so good compared to serial processing if the number of operations is small.

    On Parallel Extensions you may find my blog posting .NET Framework 4.0: Comparing LINQ and PLINQ performance to be informative and interesting reading (the example here was favorite one in my sessions serie about .NET Framework 4.0).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 29, 2010 2:06 PM

All replies

  • User-2004844803 posted

    I sounds like you yet havnt tested your method with the amount off users you are aiming for but you are already worried for the performance? My suggestion is to first test and see if there is a performance problem with the the amount off calls you are aiming for and then search for a solution. Dont "overdo" things and dont try to fix a problem that you dont have yet...


    Thursday, May 27, 2010 10:15 AM
  • User-525215917 posted

    You have three options and you should try out each one of them to see which one performs best for you:

    1. use serial calls to make calculations
    2. use threads to make calculations
    3. use Parallel Extensions to make calculations

    Handling threading issues manually may not be best thing to do although you may achieve very good results. The other edge of this sword is that threading issues are usually hard to debug and sometimes it is very hard even to reproduce problems related to threading (Clean Code by Robert C. Martin has excellent appendix about threading issues).

    Parallel Extensions, imho, will give you the best results, bacause you have large number of operations. Make sure that calcucation functions does not use same instances of objects because this way you may end up with chaos. I have seen that Parallel Extensions perform not so good compared to serial processing if the number of operations is small.

    On Parallel Extensions you may find my blog posting .NET Framework 4.0: Comparing LINQ and PLINQ performance to be informative and interesting reading (the example here was favorite one in my sessions serie about .NET Framework 4.0).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 29, 2010 2:06 PM