code::dive 2016 conference - Sean Parent - Better Code: Concurrency

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ก.ย. 2024
  • Lecture was held on code::dive conference on November 15-16, 2016, Wrocław, Poland

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

  • @dutiona
    @dutiona 7 ปีที่แล้ว +4

    This talk is awesome. Thanks for this blunt state of the art.

  • @pointyhairedboss1
    @pointyhairedboss1 5 ปีที่แล้ว +3

    On bad cow at 10:24, isn't if(object_m->count == 1) object_m->data_m = x; line itself open to a data race , m_count may have been 1 when it was loaded by the if statement, but another thread might have executed the copy ctor by the time assignment happens ?

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

    Here's the category he mentioned en.m.wikipedia.org/wiki/Kleisli_category

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

      but where and when did he speak about it previously ?

  • @n3whous3
    @n3whous3 5 ปีที่แล้ว

    44:12 - why it is a deadlock? If that task has just got into the queue, it won't do anything, unlike that task which on it calls get -> that one is in progress. So when the tasking system goes on and calls get, it should already get the result. What am I overlooking here?

    • @n3whous3
      @n3whous3 5 ปีที่แล้ว

      I got it, I mixed it up so the task which is already running shall not call some future get, because that might have been went into the same queue and THAT will not run down if we are killing the whole run with the blocking .get call.

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

    This is such a great talk it broke my heart to lose respect for him when I noticed he was using Apple products lol.

    • @dennisestenson7820
      @dennisestenson7820 10 หลายเดือนก่อน

      I am not an Apple user (I haven't used an apple product in this millennium). But I understand some people want the power of Linux/BSD while maintaining the "it just works" and elegant design of a consumer device. The bias in your ignorant comment is unjustified.

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

    Looking at the proposed fix at 12:10, doesn't it introduce another race condition potentially resulting in UB? I mean, the pre-decrement and comparison with zero are two separate operations even for atomic types, aren't they?

    • @SeanParent
      @SeanParent 7 ปีที่แล้ว +9

      The pre-decrement is equivalent to a fetch_sub(1) - 1, the fetch_sub() being the atomic operation. It isn't necessary that the comparison be part of the atomic, only the fetch and subtract happen as an atomic. That ensures that if this code path was the last owner at the time of the subtract, then the object is correctly deleted (otherwise another code path will be the last owner).

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

      Thank you. I mistakenly assumed the comparison would introduce another fetch.

  • @dosomething3
    @dosomething3 7 ปีที่แล้ว

    "The leak was hard to find" - not with proper unit testing.

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

      Uh, you have to be aware of the leak before writing a unit test. Blindly writing unit tests don't catch anything.

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

      kwanarchive as soon as you suspect a leak (which you should always test for even without a suspicion) you can run unit tests. That's how I've found all leaks in my life.

    • @kwanarchive
      @kwanarchive 7 ปีที่แล้ว +11

      You can't test that leak because it's random. You can't write unit tests that reliably inserts an operation - from another thread- between two atomic actions. The leak occurs once every few hours. Are you going to write a unit test that runs for hours on the off-chance it will catch a leak due to race conditions?

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

      kwanarchive good point. Why not create a unit test that creates multiple threads. And accesses the unit under test from these threads. You can easily recreate the leak in a split second. I've done this all my life.

    • @kwanarchive
      @kwanarchive 7 ปีที่แล้ว +6

      No, because you still have to trigger it in between the two lines of code. Doesn't matter how many threads you throw at it, it's still unreliable as a test.