Repository-Metriken
- Stars
- (17.886 Stars)
- PR-Merge-Metriken
- (Durchschn. Merge 12T 11h) (661 gemergte PRs in 30 T)
Beschreibung
Most JIT COMPlus variables are either:
- enabled for all methods,
- enabled for all methods that match a class/method pattern, or a method hash
Altjit is a little tricky, as it "takes over" some of the variables, thus the settings apply to the altjit compiler, and the non-altjit compiler leaves the variables disabled (e.g., COMPlus_JitDump).
Often, I find myself wanting to enable a variable for a set of methods (which actually can be done for those that take a pattern, although it's cumbersome for more than a few, since they're all specified on the same line).
JITMinOpts has some additional magic, to allow for binary searching by method count, if you can figure out the magic hex numbers to use, and the function method count remains stable and less than 0x1000 (see Compiler::compSetOptimizationLevel()).
There is some other ad-hoc code to implement ranges: look for minoptshashlo, minoptshashhi, JitStressRegsHashLo/JitStressRegsHashHi, etc.
I needed to do a binary search with a new COMPlus variable. I implemented a new mechanism as follows:
- set COMPlus_JitFunctionFile to the name of a file that contains entries kind of like what JitFunctionTrace emits:
System.CLRConfig:GetBoolValue(ref,byref):bool (MethodHash=3c54d35e)
-- use the MethodHash, not the function name
System.CLRConfig:GetBoolValue(ref,byref):bool
-- use just the name
Also, there are leading comment characters.
- Then, made my new variable first check this list. If no list, use the default behavior. If there is a list, check to see if the method being compiled is in this list of "active" functions, then apply the variable only to those functions.
- Then I could easily binary search by editing the file.
I was thinking if we could have a more general solution, that could conditionalize any variable in a number of ways (I'm sure there will be exceptions to "any"). E.g., conditionalize based on a file, like above. Or conditionalize based on method count, like JITMinOpts does. One possible syntax:
COMPlus_JitConditionalizeFile=file.txt COMPlus_foo=1 -- only set COMPlus_foo=1 for functions that match in file.txt COMPlus_JitConditionalizeMethodCnt=1-10,60-1000,2000- COMPlus_bar=1 -- only set COMPlus_bar=1 for function counts in the specified ranges.
Comments?
@dotnet/jit-contrib
category:implementation theme:jit-coding-style skill-level:beginner cost:small