oneTBB icon indicating copy to clipboard operation
oneTBB copied to clipboard

Replace semaphore_t on dispatch_semaphore_t on macOS

Open pavelkumbrasev opened this issue 2 years ago • 2 comments

Signed-off-by: pavelkumbrasev [email protected]

Description

To enable ThreadSanitizer on APPLE (basically on macOS) replaced semaphore_t on dispatch_semaphore_t which supports via ThreadSanitizer. In accordance to scenarios where and how we use semaphore the performance should not change, but still need to prove this.

Fixes # - #358

  • [x] - git commit message contains an appropriate signed-off-by string (see CONTRIBUTING.md for details)

Type of change

Choose one or multiple, leave empty if none of the other choices apply

Add a respective label(s) to PR if you have permissions

  • [ ] bug fix - change that fixes an issue
  • [x] new feature - change that adds functionality
  • [ ] tests - change in tests
  • [ ] infrastructure - change in infrastructure and CI
  • [ ] documentation - documentation update

Tests

  • [ ] added - required for new features and some bug fixes
  • [x] not needed

Documentation

  • [ ] updated in # - add PR number
  • [ ] needs to be updated
  • [x] not needed

Breaks backward compatibility

  • [ ] Yes
  • [x] No
  • [ ] Unknown

Notify the following users

@phprus

Other information

pavelkumbrasev avatar Sep 18 '22 17:09 pavelkumbrasev

Does this change introduce any new dependencies for either compilation/link time or execution time which need to be documented?

Do we know that the dispatch semaphore has no spurious wakeups?

akukanov avatar Sep 19 '22 10:09 akukanov

Does this change introduce any new dependencies for either compilation/link time or execution time which need to be documented?

Do we know that the dispatch semaphore has no spurious wakeups?

I currently researching both questions. For now I checked that dispatch_semaphore_t introduced with macOS 10.6. Also I did not observe any new flags during the compilation. (I compiled example from #358 using dispatch_semaphore_t without any additional flags)

pavelkumbrasev avatar Sep 19 '22 10:09 pavelkumbrasev

It seems that from dispatch_semaphore_t documentation there should not be spurious wakeups during wait calls. Also from the implementation point of view they have similar while loop on case DISPATCH_TIME_FOREVER.

pavelkumbrasev avatar Sep 26 '22 09:09 pavelkumbrasev

Tested on mac os 12.6, and I can easily see that I don't have many false positives as I had without this patch.

natale-p avatar Oct 03 '22 14:10 natale-p

Hello, any news on this PR? Can it be merged?

natale-p avatar Oct 26 '22 08:10 natale-p

Hi @natale-p, we are going to merge it after we will satisfy all test requirements for it. (I hope it will be soon)

pavelkumbrasev avatar Oct 26 '22 08:10 pavelkumbrasev