perf: make max and min dollar variables thread-local#807
perf: make max and min dollar variables thread-local#807jodavies wants to merge 1 commit intoform-dev:masterfrom
Conversation
Use thread-local dollar variables for ModuleOption minimum and maximum dollars. With this change they work exactly like ModuleOption local, except at the end of the module the final value is computed and put into the global dollar value.
|
This also fixes/works around a regression due to #797 , which I found when trying to add HyperFORM tests to the CI. The problem is, that now we lock the min/max doillars over the larger region, in case they themselves appear on a RHS. This can cause deadlocks, in case of With this PR each thread has its own dollar, and we don't lock in that region, avoiding the issue. Possible a problem is still present for MODSUM. The "proper fix" probably would be to use a recursive pthreads mutex, so that a thread can call that lock for a second time. |
|
Using recursive locks for dollar variables (on the master branch) is about a 1% performance regression. This PR of course means we don't need them for MODMAX and MODMIN, but I think MODSUM can still deadlock (and always could, but I think people don't really use them...?) |
Use thread-local dollar variables for ModuleOption minimum and maximum dollars. With this change they work exactly like ModuleOption local, except at the end of the module the final value is computed and put into the global dollar value.
For some "real-world" tests which use ModuleOption minimum/maximum there is reasonable speedup. It is more obvious at higher worker counts, but not if there are too many workers for any real scaling. The "mincer-exact" test seems to have a small regression; for now I am not sure why. "mincer" really likes this change...
In the following benchmark which is targeted specifically at the dollar-variable locks, the speedup is much larger: