craigcondit opened a new pull request, #835:
URL: https://github.com/apache/yunikorn-core/pull/835

   ### What is this PR for?
   
   Replaces sync.{RW}Mutex with internal logging.{RW}Mutex implementations. The 
new implementation wraps the go-deadlock library with logic to conditionally 
enable deadlock detection based on the presence of environment variables:
   
   To enable the feature:
   
   - DEADLOCK_DETECTION_ENABLED=true
   
   To customize the timeout before potential deadlocks are logged (default is 
60 seconds):
   
   - DEADLOCK_TIMEOUT_SECONDS=60
   
   See https://github.com/sasha-s/go-deadlock for more details.
   
   ### What type of PR is it?
   * [ ] - Bug Fix
   * [x] - Improvement
   * [ ] - Feature
   * [ ] - Documentation
   * [ ] - Hot Fix
   * [ ] - Refactoring
   
   ### Todos
   * [ ] - Task
   
   ### What is the Jira issue?
   https://issues.apache.org/jira/browse/YUNIKORN-2539
   
   ### How should this be tested?
   Added basic unit tests and benchmarks. A full t
   
   
   ### Impact
   Performance impact is negligible when the feature is disabled (~ 4 ns per 
lock). When enabled, locks are considerably slower due to the tracking 
required; however even on a 5-year old laptop I still see ~ 800,000 locks per 
second. This should still be usable for short periods of diagnosing even 
relatively busy clusters.
   
   ```
   goos: darwin
   goarch: amd64
   pkg: github.com/apache/yunikorn-core/pkg/locking
   cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
   
   # Baseline (sync.{RW}Mutex)
   BenchmarkSyncMutex-12                        100000000               10.83 
ns/op
   BenchmarkSyncRWMutexRead-12                  100000000               10.79 
ns/op
   BenchmarkSyncRWMutexWrite-12                 55220977                21.92 
ns/op
   
   # Go-Deadlock implementation
   BenchmarkGoDeadlockMutex-12                    908439              1321 ns/op
   BenchmarkGoDeadlockRWMutexRead-12              852348              1301 ns/op
   BenchmarkGoDeadlockRWMutexWrite-12             903925              1312 ns/op
   
   # Internal implementation (tracking disabled)
   BenchmarkUntrackedMutex-12                   83157864                14.32 
ns/op
   BenchmarkUntrackedRWMutexRead-12             87364526                14.31 
ns/op
   BenchmarkUntrackedRWMutexWrite-12            47517205                25.22 
ns/op
   
   # Internal implementation (tracking enabled)BenchmarkTrackedMutex-12         
          886326              1324 ns/op
   BenchmarkTrackedRWMutexRead-12                 886848              1306 ns/op
   BenchmarkTrackedRWMutexWrite-12                909826              1311 ns/op
   ```
   
   ### Questions:
   * [ ] - The licenses files need update.
   * [ ] - There is breaking changes for older versions.
   * [ ] - It needs documentation.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to