summaryrefslogtreecommitdiff
path: root/src/vm/hillclimbing.cpp
diff options
context:
space:
mode:
authorKoundinya Veluri <kouvel@users.noreply.github.com>2017-10-18 20:51:30 -0700
committerGitHub <noreply@github.com>2017-10-18 20:51:30 -0700
commita589e3926a1780256fdb52376f8681fe047daf54 (patch)
tree2115b74f663d977b827dd1e8c47962617f47e767 /src/vm/hillclimbing.cpp
parent4984a8dffda3b3f58fc158c48fc798d02ab1b98e (diff)
downloadcoreclr-a589e3926a1780256fdb52376f8681fe047daf54.tar.gz
coreclr-a589e3926a1780256fdb52376f8681fe047daf54.tar.bz2
coreclr-a589e3926a1780256fdb52376f8681fe047daf54.zip
Fix hill climbing float overflow (#14505)
Fix hill climbing float overflow - When hill climbing finds that it wants to decrease the thread count but can't because the thread count is already the minimum, it instead tries to increase the sampling interval by a factor of up to 10 depending on how much it wanted to decrease the thread count - The ratio was being used incorrectly (used max instead of min), and sometimes the ratio can be so large that the conversion to int after the float math overflows - If something in the process enabled floating point exceptions, it may also crash - There doesn't appear to be a clean way to disable hill climbing, added a config variable that disables it in case a workaround is necessary for some other reason in the future - Fixed to avoid overflow in the math to what was probably intended - There may be another bug in GetWaveComponent() that causes values of such high magnitude to be generated, I'll leave that investigation for when that in particular becomes a real issue
Diffstat (limited to 'src/vm/hillclimbing.cpp')
-rw-r--r--src/vm/hillclimbing.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/vm/hillclimbing.cpp b/src/vm/hillclimbing.cpp
index 598ef3e8cd..196708a5e2 100644
--- a/src/vm/hillclimbing.cpp
+++ b/src/vm/hillclimbing.cpp
@@ -335,7 +335,7 @@ int HillClimbing::Update(int currentThreadCount, double sampleDuration, int numC
// we'll simply stay at minThreads much longer, and only occasionally try a higher value.
//
if (ratio.r < 0.0 && newThreadCount == ThreadpoolMgr::MinLimitTotalWorkerThreads)
- *pNewSampleInterval = (int)(0.5 + m_currentSampleInterval * (10.0 * max(-ratio.r, 1.0)));
+ *pNewSampleInterval = (int)(0.5 + m_currentSampleInterval * (10.0 * min(-ratio.r, 1.0)));
else
*pNewSampleInterval = m_currentSampleInterval;