-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove nsync #20413
Remove nsync #20413
Conversation
I hit a blocker in Web CI pipeline. Then Yulong and I had a meeting and discussed it. We found the root cause, but the fix is non-trivial. Instead, I will wait his ES6 change getting merged first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General comment.
It would save us a lot of refactoring and preserve lots of flexibility if we simply refactored OrtMutex or typedefed as absl::Mutex. Also could continue to use std::lock_guard. Then most of the code would remain the same, and we could change it to something else as the circumstances require.
d1f00f6
to
ce962d9
Compare
I updated this PR to use std::mutex instead. Originally I tried to use absl::mutex. |
/azp run ONNX Runtime Web CI Pipeline |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run Windows CPU CI Pipeline |
Azure Pipelines successfully started running 1 pipeline(s). |
I reworked the PR. absl::Mutex cannot be used with std::lock_guard. So I changed the type to std::mutex . As we no longer use a custom type of mutex, I think we no longer need to have an extra typedef . Though this PR changed 110 files. All the changes were done by a simple bash script. If in the future we want to introduce a custom mutex type back, I volunteer to help. |
For reference, the code changes were generated by the following commands: git rm include/onnxruntime/core/platform/ort_mutex.h -f
git rm onnxruntime/core/platform/posix/ort_mutex.cc -f
find . -type f -exec sed -i 's/onnxruntime::OrtMutex/std::mutex/g' {} \;
find . -type f -exec sed -i 's/OrtMutex/std::mutex/g' {} \;
find . -type f -exec sed -i 's/onnxruntime::OrtCondVar/std::condition_variable/g' {} \;
find . -type f -exec sed -i 's/OrtCondVar/std::condition_variable/g' {} \;
find . -type f -exec sed -i 's/#include "core\/platform\/ort_mutex.h"/#include <mutex>/g' {} \;
find . -type f -exec sed -i 's/#include <core\/platform\/ort_mutex.h>/#include <mutex>/g' {} \;
|
### 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 microsoft#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 microsoft#21005 , which is no longer needed since conda has updated its msvc runtime DLL. This PR unblocks microsoft#22173 and resolves microsoft#22092 . We have a lot of open issues with nsync. This PR can resolve all of them.
Description
absl::Mutexstd::mutex.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.