Remove resetGlobalScheduler calls from C API#3141
Conversation
It is not thread-safe for the C API to call resetGlobalScheduler because another thread may be in the middle of a Highs_ call.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## latest #3141 +/- ##
==========================================
+ Coverage 73.16% 73.17% +0.01%
==========================================
Files 430 430
Lines 103967 104034 +67
Branches 16718 16727 +9
==========================================
+ Hits 76069 76129 +60
- Misses 27622 27629 +7
Partials 276 276 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I managed to reproduce segfaults and other weird behaviour with a unit test that runs two separate Highs instances in separate threads. The bad behaviour disappears using this branch. |
|
Sorry for highjacking this but if resetGlobalScheduler is not thread safe how do I change the number of threads used by a HiGHS instance? |
|
It is not thread safe to call It is not possible to have multiple Highs instances running with different values of the |
If you're using HiGHS within a web server that serves more then one user you always have to assume that another HiGHS instance is running in parallel - or you keep track yourself how many highs instances are running and only set the thread call if this count is 0 and if not you can't set the thread count for the instance you are about to start... Which means that in my use case it's probably best disable the parallel mip solver and go for threads=1 all the time. |
|
You can set |
|
Ooops. Failing Julia tests were because I jumped the gun to make a change in HiGHS. I've reverted it for now: jump-dev/HiGHS.jl@c8a94c6 and restarted the tests. (I thought it would just silently ignore the option, not error.) |
It is not thread-safe for the C API to call resetGlobalScheduler because another thread may be in the middle of a Highs_ call.
Extracted from #3136
This should fix the random segfaults we are seeing with the Julia tests.
The Julia tests are a prime candidate for encountering this bug because they spawn many instances of HiGHS,
Highs_destroyis called when the instances are garbage collected, and Julia's garbage collector runs in a separate thread.