On Sun, 8 Nov 2020 21:43:00 GMT, David Holmes <dhol...@openjdk.org> wrote:
>> How about this: >> static MonitorList _in_use_list; >> // The ratio of the current _in_use_list count to the ceiling is used >> // to determine if we are above MonitorUsedDeflationThreshold and need >> // to do an async monitor deflation cycle. The ceiling is increased by >> // AvgMonitorsPerThreadEstimate when a thread is added to the system >> // and is decreased by AvgMonitorsPerThreadEstimate when a thread is >> // removed from the system. >> // Note: If the _in_use_list max exceeds the ceiling, then >> // monitors_used_above_threshold() will use the in_use_list max instead >> // of the thread count derived ceiling because we have used more >> // ObjectMonitors than the estimated average. >> static jint _in_use_list_ceiling; > > Thanks for the comment. So instead of checking the threshhold on each OM > allocation we use this averaging technique to estimate the number of monitors > in use? Can you explain how this came about rather than the simple/obvious > check at allocation time. Thanks. I'm not sure I understand your question, but let me that a stab at it anyway... We used to compare the sum of the in-use counts from all the in-use lists with the total population of ObjectMonitors. If that ratio was higher than MonitorUsedDeflationThreshold, then we would do an async deflation cycle. Since we got rid of TSM, we no longer had a population of already allocated ObjectMonitors, we had a max value instead. However, when the VMs use of ObjectMonitors is first spinning up, the max value is typically very close to the in-use count so we would always be asking for an async-deflation during that spinning up phase. I created the idea of a ceiling value that is tied to thread count and the AvgMonitorsPerThreadEstimate to replace the population value that we used to have. By comparing the in-use count against the ceiling value, we no longer exceed the MonitorUsedDeflationThreshold when the VMs use of ObjectMonitors is first spinning up so we no longer do async deflations continuously during that phase. If the max value exceeds the ceiling value, then we're using a LOT of ObjectMonitors and, in that case, we compare the in-use count against the max to determine if we're exceeding the MonitorUsedDeflationThreshold. Does this help? ------------- PR: https://git.openjdk.java.net/jdk/pull/642