@@ -1913,6 +1913,60 @@ ModelPolicy::ModelPolicy(Compiler* compiler, bool isPrejitRoot)
1913
1913
// Empty
1914
1914
}
1915
1915
1916
+ // ------------------------------------------------------------------------
1917
+ // NoteInt: handle an observed integer value
1918
+ //
1919
+ // Arguments:
1920
+ // obs - the current obsevation
1921
+ // value - the value being observed
1922
+ //
1923
+ // Notes:
1924
+ // The ILSize threshold used here should be large enough that
1925
+ // it does not generally influence inlining decisions -- it only
1926
+ // helps to make them faster.
1927
+ //
1928
+ // The value is determined as follows. We figure out the maximum
1929
+ // possible code size estimate that will lead to an inline. This is
1930
+ // found by determining the maximum possible inline benefit and
1931
+ // working backwards.
1932
+ //
1933
+ // In the current ModelPolicy, the maximum benefit is -28.1, which
1934
+ // comes from a CallSiteWeight of 3 and a per call benefit of
1935
+ // -9.37. This implies that any candidate with code size larger
1936
+ // than (28.1/0.2) will not pass the threshold. So maximum code
1937
+ // size estimate (in bytes) for any inlinee is 140.55, and hence
1938
+ // maximum estimate is 1405.
1939
+ //
1940
+ // Since we are trying to short circuit early in the evaluation
1941
+ // process we don't have the code size estimate in hand. We need to
1942
+ // estimate the possible code size estimate based on something we
1943
+ // know cheaply and early -- the ILSize. So we use quantile
1944
+ // regression to project how ILSize predicts the model code size
1945
+ // estimate. Note that ILSize does not currently directly enter
1946
+ // into the model.
1947
+ //
1948
+ // The median value for the model code size estimate based on
1949
+ // ILSize is given by -107 + 12.6 * ILSize for the V9 data. This
1950
+ // means an ILSize of 120 is likely to lead to a size estimate of
1951
+ // at least 1405 at least 50% of the time. So we choose this as the
1952
+ // early rejection threshold.
1953
+
1954
+ void ModelPolicy::NoteInt (InlineObservation obs, int value)
1955
+ {
1956
+ // Let underlying policy do its thing.
1957
+ DiscretionaryPolicy::NoteInt (obs, value);
1958
+
1959
+ // Fail fast for inlinees that are too large to ever inline.
1960
+ // The value of 120 is model-dependent; see notes above.
1961
+ if (!m_IsForceInline &&
1962
+ (obs == InlineObservation::CALLEE_IL_CODE_SIZE) &&
1963
+ (value >= 120 ))
1964
+ {
1965
+ // Callee too big, not a candidate
1966
+ SetNever (InlineObservation::CALLEE_TOO_MUCH_IL);
1967
+ }
1968
+ }
1969
+
1916
1970
// ------------------------------------------------------------------------
1917
1971
// DetermineProfitability: determine if this inline is profitable
1918
1972
//
@@ -1980,10 +2034,24 @@ void ModelPolicy::DetermineProfitability(CORINFO_METHOD_INFO* methodInfo)
1980
2034
// frequency, somehow.
1981
2035
double callSiteWeight = 1.0 ;
1982
2036
1983
- if ((m_CallsiteFrequency == InlineCallsiteFrequency::LOOP) ||
1984
- (m_CallsiteFrequency == InlineCallsiteFrequency::HOT))
2037
+ switch (m_CallsiteFrequency)
1985
2038
{
1986
- callSiteWeight = 8.0 ;
2039
+ case InlineCallsiteFrequency::RARE:
2040
+ callSiteWeight = 0.1 ;
2041
+ break ;
2042
+ case InlineCallsiteFrequency::BORING:
2043
+ callSiteWeight = 1.0 ;
2044
+ break ;
2045
+ case InlineCallsiteFrequency::WARM:
2046
+ callSiteWeight = 1.5 ;
2047
+ break ;
2048
+ case InlineCallsiteFrequency::LOOP:
2049
+ case InlineCallsiteFrequency::HOT:
2050
+ callSiteWeight = 3.0 ;
2051
+ break ;
2052
+ default :
2053
+ assert (false );
2054
+ break ;
1987
2055
}
1988
2056
1989
2057
// Determine the estimated number of instructions saved per
0 commit comments