Skip to content

Conversation

@snnn
Copy link
Contributor

@snnn snnn commented Feb 10, 2020

Description:

Provide alternative std::mutex implementation on Windows. OrtMutex is no longer an alias of std::mutex.

Motivation and Context

  • Why is this change required? What problem does it solve?
  1. This new thing is faster and much much simpler.
  2. Static constructors are considered harmful. We should avoid such thing as possible as we can.

This PR is only for changing the implementation of OrtMutex. In a following PR I'll show how it will simplify things.

  • If it fixes an open issue, please link to the issue here.

@snnn snnn requested a review from a team as a code owner February 10, 2020 22:45
Changming Sun added 3 commits February 10, 2020 14:49
option(onnxruntime_ENABLE_MEMLEAK_CHECKER "Experimental: Enable memory leak checker in Windows debug build" OFF)
option(onnxruntime_USE_CUDA "Build with CUDA support" OFF)
option(onnxruntime_USE_OPENVINO "Build with OpenVINO support" OFF)
option(onnxruntime_USE_NSYNC "Build with NSYNC support. This option only takes effect on Linux" OFF)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is nsync going to be ON by default? If yes, do we still need #ifdef USE_NSYNC?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO. We can remove the ifdef

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR sent: #3052

@snnn snnn force-pushed the snnn/nsync branch 2 times, most recently from c6a1804 to d94262a Compare February 11, 2020 02:20
skottmckay
skottmckay previously approved these changes Feb 11, 2020
Copy link
Contributor

@skottmckay skottmckay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@pranavsharma
Copy link
Contributor

Description:

Provide alternative std::mutex implementation on Windows. OrtMutex is no longer an alias of std::mutex.

Motivation and Context

  • Why is this change required? What problem does it solve?
  1. This new thing is faster and much much simpler.
  2. Static constructors are considered harmful. We should avoid such thing as possible as we can.

This PR is only for changing the implementation of OrtMutex. In a following PR I'll show how it will simplify things.

  • If it fixes an open issue, please link to the issue here.

Can you paste some perf numbers that show the advantage of this mutex? This will set an example for future PR authors who want to submit perf fixes. Thanks.

@snnn
Copy link
Contributor Author

snnn commented Feb 11, 2020

Can you paste some perf numbers that show the advantage of this mutex? This will set an example for future PR authors who want to submit perf fixes. Thanks.

Sent you an email.

@snnn snnn merged commit abb626f into master Feb 11, 2020
@snnn snnn deleted the snnn/nsync branch February 11, 2020 19:46
@snnn snnn mentioned this pull request Feb 20, 2020
This was referenced Oct 18, 2024
snnn pushed a commit that referenced this pull request Oct 21, 2024
### Description
1. Remove the onnxruntime::OrtMutex class and replace it with
~absl::Mutex~ std::mutex.
2. After this change, most source files will not include <Windows.h>
indirectly.


### Motivation and Context
To reduce the number of deps we have, and address some Github issues
that are related to build ONNX Runtime from source.
In PR #3000 , I added a custom implementation of std::mutex . It was
mainly because at that time std::mutex's default constructor was not
trivial on Windows. If you had such a mutex as a global var, it could
not be initialized at compile time. Then VC++ team fixed this issue.
Therefore we don't need this custom implementation anymore.

This PR also removes nsync. I ran several models tests on Linux. I
didn't see any perf difference.
This PR also reverts PR #21005 , which is no longer needed since conda
has updated its msvc runtime DLL.

This PR unblocks #22173 and resolves #22092 . We have a lot of open
issues with nsync. This PR can resolve all of them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants