Parallelization and PLINQ

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ธ.ค. 2024

ความคิดเห็น • 21

  • @CodingTutorialsAreGo
    @CodingTutorialsAreGo  2 ปีที่แล้ว +3

    Want more on PLINQ? Leave a message.
    Source code available at: github.com/JasperKent/Parallelization
    Remember to subscribe at th-cam.com/channels/qWQzlUDdllnLmtgfSgYTCA.html
    And if you liked the video, click the 👍.

    • @finwwwfinwww4669
      @finwwwfinwww4669 2 ปีที่แล้ว +1

      Could you please make a video of Task vs thread

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo  2 ปีที่แล้ว

      @@finwwwfinwww4669 I'll put it on the list.

  • @根本花里子
    @根本花里子 ปีที่แล้ว +3

    Thank you very much for adding subtitles! It's very helpful for non-native speakers💛

  • @Praveen.Kumar.
    @Praveen.Kumar. 2 ปีที่แล้ว +1

    Happy Friday Sir! Fair and simple into.

  • @LuciferTheBloody
    @LuciferTheBloody 2 ปีที่แล้ว +1

    Good explanation, would be interesting if you went further into performance, as the overhead from Parallel can make it perform slower in many cases.

  • @foudilbenouci482
    @foudilbenouci482 6 หลายเดือนก่อน +1

    Parallel.ForEach(values, (value, _) =>
    {
    results[value] = Factoriel(value % 20 + 1);
    usage.AddOrUpdate(Environment.CurrentManagedThreadId, 1, (_, count) => count + 1);
    }
    );
    is working fine (value is the index) i didn't understand why you introduced the concurentBag collection for this loop

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo  6 หลายเดือนก่อน

      The 'results' array has to be pre-allocated to the number of results, which in this case, we happen to know. In other circumstances, we might not know the final size, and if we want the collection to expand to fit, it has to be thread safe.

    • @foudilbenouci482
      @foudilbenouci482 6 หลายเดือนก่อน +1

      @@CodingTutorialsAreGo clear thank you

  • @paultannenberg4432
    @paultannenberg4432 2 ปีที่แล้ว +2

    Great explanation!

  • @foudilbenouci482
    @foudilbenouci482 6 หลายเดือนก่อน +1

    The parellisation of the average() method doesn't give the same result : with parallelisation the result is 228150401,23158336 without parallelisation the method the result is 228150401,3512809.So an error is introduced

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo  6 หลายเดือนก่อน +2

      I think that's related to the rounding errors one can get with doubles. Without parallelization, the rounding error is consistent, whereas with parallelization there is a degree of randomization, but neither is correct.
      If you do this with decimals instead of doubles, you consistently get the result 228,150,401.25. This is because the decimal type is explicitly designed to avoid rounding errors.
      We can verify this is the correct result by looking at the Sum() and Count() of the results, which are:
      114,075,200,625,000,000
      500,000,000
      Cancelling the zeros gives:
      114,075,200,625
      500
      I'm not going to do the full long division, but it's evident this ends in exactly .25.

    • @foudilbenouci482
      @foudilbenouci482 6 หลายเดือนก่อน +1

      @@CodingTutorialsAreGo Yes it is related the rounding errors one can get with doubles . If you chunk the list depending on the chunks and their order you wont get nécessarily the exact same result . Thank you

  • @abelwodulo7365
    @abelwodulo7365 2 ปีที่แล้ว +1

    thanks for the guide.

  • @davidwhite2011
    @davidwhite2011 2 ปีที่แล้ว +2

    Another Friday made better with a Coding Tutorials tutorial.

  • @benwardle3766
    @benwardle3766 2 ปีที่แล้ว +1

    very nice!

  • @djedsonsantos7582
    @djedsonsantos7582 2 ปีที่แล้ว

    hard. The soft soft interface is quite friendly

  • @taddeustentakel8598
    @taddeustentakel8598 ปีที่แล้ว +1

    Hey great video man! I would only love to ask something in addition, is it SOMEHOW possible to use "Paralell.ForEach(..)" with the newly added "RegexSrcGenerator" so because when i do this code here:
    Paralell.ForEach(regex.EnumerateMatches(mySpan), (match, _) =>
    {
    //error cant do that because of it returning an "ValueMatchEnumerator"....
    });

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo  ปีที่แล้ว +1

      Not something I know off the top of my head. I'll take a look if I have time.

    • @taddeustentakel8598
      @taddeustentakel8598 ปีที่แล้ว

      @@CodingTutorialsAreGo thx brother! have a good time