Skip to content

Commit e544a76

Browse files
committed
Add OSR switches
1 parent de40c1a commit e544a76

File tree

3 files changed

+257
-9
lines changed

3 files changed

+257
-9
lines changed

Antigen/Config/EnvVarOptions.cs

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System.Collections.Generic;
6+
using System.Diagnostics;
67
using System.Linq;
78

89
namespace Antigen.Config
@@ -36,9 +37,18 @@ internal static void Initialize(List<ComplusEnvVarGroup> baselineEnvVars, List<C
3637
/// Returns a random EnvVarGroup depending on the weight.
3738
/// </summary>
3839
/// <returns></returns>
39-
private static ComplusEnvVarGroup GetRandomTestGroup()
40+
private static ComplusEnvVarGroup GetRandomOsrTestGroup()
4041
{
41-
return PRNG.WeightedChoice(s_testGroupWeight);
42+
return PRNG.WeightedChoice(s_testGroupWeight.Where(tg => tg.Data.IsOsrSwitchGroup()));
43+
}
44+
45+
/// <summary>
46+
/// Returns a random EnvVarGroup depending on the weight.
47+
/// </summary>
48+
/// <returns></returns>
49+
private static ComplusEnvVarGroup GetRandomNonOsrTestGroup()
50+
{
51+
return PRNG.WeightedChoice(s_testGroupWeight.Where(tg => !tg.Data.IsOsrSwitchGroup()));
4252
}
4353

4454
/// <summary>
@@ -62,14 +72,12 @@ public static Dictionary<string, string> BaseLineVars()
6272
/// Returns random set of test environment variables.
6373
/// </summary>
6474
/// <returns></returns>
65-
public static Dictionary<string, string> TestVars()
75+
public static Dictionary<string, string> TestVars(bool includeOsrSwitches)
6676
{
67-
var envVars = new Dictionary<string, string>()
68-
{
69-
{ "COMPlus_TieredCompilation", "0"}
70-
};
77+
var envVars = new Dictionary<string, string>();
7178

7279
var defaultGroup = s_testGroups.First(tg => tg.Name == "Default");
80+
7381
// default variables
7482
var usedEnvVars = new HashSet<string>();
7583
var defaultVariablesCount = PRNG.Next(1, 8);
@@ -86,6 +94,23 @@ public static Dictionary<string, string> TestVars()
8694
envVars[$"COMPlus_{envVar.Name}"] = envVar.Values[PRNG.Next(envVar.Values.Length)];
8795
}
8896

97+
// OSR switches
98+
if (includeOsrSwitches)
99+
{
100+
var osrstressGroup = GetRandomOsrTestGroup();
101+
// Unique OSR group found. Add all switches and move on.
102+
foreach (var osrSwitch in osrstressGroup.Variables)
103+
{
104+
Debug.Assert(osrSwitch.Values.Length == 1);
105+
envVars[$"COMPlus_{osrSwitch.Name}"] = osrSwitch.Values[0];
106+
}
107+
}
108+
else
109+
{
110+
envVars["COMPlus_TieredCompilation"] = "0";
111+
}
112+
113+
// stress switches
89114
var stressVariablesCount = PRNG.Next(1, 4);
90115
for (var i = 0; i < stressVariablesCount; i++)
91116
{
@@ -94,7 +119,7 @@ public static Dictionary<string, string> TestVars()
94119
// Avoid duplicate variables
95120
do
96121
{
97-
var stressGroup = GetRandomTestGroup();
122+
var stressGroup = GetRandomNonOsrTestGroup();
98123
envVar = stressGroup.GetRandomVariable();
99124
} while (!usedEnvVars.Add(envVar.Name));
100125

@@ -165,5 +190,10 @@ public override string ToString()
165190
{
166191
return $"{Name}: {Variables.Count}";
167192
}
193+
194+
public bool IsOsrSwitchGroup()
195+
{
196+
return Name.Contains("OSR") || Name.Contains("PartialCompile");
197+
}
168198
}
169199
}

Antigen/Config/antigen.json

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,224 @@
626626
]
627627
}
628628
]
629+
},
630+
{
631+
"Name": "OSR",
632+
"Weight": 0.2,
633+
"Variables": [
634+
{
635+
"Name": "TC_OnStackReplacement",
636+
"Weight": "0", /* intentially zero */
637+
"Values": [ "1" ]
638+
},
639+
{
640+
"Name": "TC_QuickJitForLoops",
641+
"Weight": "0", /* intentially zero */
642+
"Values": [ "1" ]
643+
},
644+
{
645+
"Name": "TieredCompilation",
646+
"Weight": "0", /* intentially zero */
647+
"Values": [ "1" ]
648+
}
649+
]
650+
},
651+
{
652+
"Name": "OSR_Stress",
653+
"Weight": 0.295,
654+
"Variables": [
655+
{
656+
"Name": "TC_OnStackReplacement",
657+
"Weight": "0", /* intentially zero */
658+
"Values": [ "1" ]
659+
},
660+
{
661+
"Name": "TC_QuickJitForLoops",
662+
"Weight": "0", /* intentially zero */
663+
"Values": [ "1" ]
664+
},
665+
{
666+
"Name": "TieredCompilation",
667+
"Weight": "0", /* intentially zero */
668+
"Values": [ "1" ]
669+
},
670+
{
671+
"Name": "TC_OnStackReplacement_InitialCounter",
672+
"Weight": "0", /* intentially zero */
673+
"Values": [ "1" ]
674+
},
675+
{
676+
"Name": "OSR_HitLimit",
677+
"Weight": "0", /* intentially zero */
678+
"Values": [ "1" ]
679+
}
680+
]
681+
},
682+
{
683+
"Name": "OSR_Stress_Random",
684+
"Weight": 0.28,
685+
"Variables": [
686+
{
687+
"Name": "TC_OnStackReplacement",
688+
"Weight": "0", /* intentially zero */
689+
"Values": [ "1" ]
690+
},
691+
{
692+
"Name": "TC_QuickJitForLoops",
693+
"Weight": "0", /* intentially zero */
694+
"Values": [ "1" ]
695+
},
696+
{
697+
"Name": "TieredCompilation",
698+
"Weight": "0", /* intentially zero */
699+
"Values": [ "1" ]
700+
},
701+
{
702+
"Name": "TC_OnStackReplacement_InitialCounter",
703+
"Weight": "0", /* intentially zero */
704+
"Values": [ "1" ]
705+
},
706+
{
707+
"Name": "OSR_HitLimit",
708+
"Weight": "0", /* intentially zero */
709+
"Values": [ "2" ]
710+
},
711+
{
712+
"Name": "JitRandomOnStackReplacement",
713+
"Weight": "0", /* intentially zero */
714+
"Values": [ "15" ]
715+
}
716+
]
717+
},
718+
{
719+
"Name": "OSR_PGO",
720+
"Weight": 0.25,
721+
"Variables": [
722+
{
723+
"Name": "TC_OnStackReplacement",
724+
"Weight": "0", /* intentially zero */
725+
"Values": [ "1" ]
726+
},
727+
{
728+
"Name": "TC_QuickJitForLoops",
729+
"Weight": "0", /* intentially zero */
730+
"Values": [ "1" ]
731+
},
732+
{
733+
"Name": "TieredCompilation",
734+
"Weight": "0", /* intentially zero */
735+
"Values": [ "1" ]
736+
},
737+
{
738+
"Name": "TieredPGO",
739+
"Weight": "0", /* intentially zero */
740+
"Values": [ "1" ]
741+
}
742+
]
743+
},
744+
{
745+
"Name": "PartialCompile",
746+
"Weight": 0.25,
747+
"Variables": [
748+
{
749+
"Name": "TC_PartialCompilation",
750+
"Weight": "0", /* intentially zero */
751+
"Values": [ "1" ]
752+
},
753+
{
754+
"Name": "TC_QuickJitForLoops",
755+
"Weight": "0", /* intentially zero */
756+
"Values": [ "1" ]
757+
},
758+
{
759+
"Name": "TieredCompilation",
760+
"Weight": "0", /* intentially zero */
761+
"Values": [ "1" ]
762+
}
763+
]
764+
},
765+
{
766+
"Name": "PartialCompile_PGO",
767+
"Weight": 0.25,
768+
"Variables": [
769+
{
770+
"Name": "TC_PartialCompilation",
771+
"Weight": "0", /* intentially zero */
772+
"Values": [ "1" ]
773+
},
774+
{
775+
"Name": "TC_QuickJitForLoops",
776+
"Weight": "0", /* intentially zero */
777+
"Values": [ "1" ]
778+
},
779+
{
780+
"Name": "TieredCompilation",
781+
"Weight": "0", /* intentially zero */
782+
"Values": [ "1" ]
783+
},
784+
{
785+
"Name": "TieredPGO",
786+
"Weight": "0", /* intentially zero */
787+
"Values": [ "1" ]
788+
}
789+
]
790+
},
791+
{
792+
"Name": "OSR_PartialCompile",
793+
"Weight": 0.258,
794+
"Variables": [
795+
{
796+
"Name": "TC_OnStackReplacement",
797+
"Weight": "0", /* intentially zero */
798+
"Values": [ "1" ]
799+
},
800+
{
801+
"Name": "TC_PartialCompilation",
802+
"Weight": "0", /* intentially zero */
803+
"Values": [ "1" ]
804+
},
805+
{
806+
"Name": "TC_QuickJitForLoops",
807+
"Weight": "0", /* intentially zero */
808+
"Values": [ "1" ]
809+
},
810+
{
811+
"Name": "TieredCompilation",
812+
"Weight": "0", /* intentially zero */
813+
"Values": [ "1" ]
814+
}
815+
]
816+
},
817+
{
818+
"Name": "OSR_PartialCompile_PGO",
819+
"Weight": 0.256,
820+
"Variables": [
821+
{
822+
"Name": "TC_OnStackReplacement",
823+
"Weight": "0", /* intentially zero */
824+
"Values": [ "1" ]
825+
},
826+
{
827+
"Name": "TC_PartialCompilation",
828+
"Weight": "0", /* intentially zero */
829+
"Values": [ "1" ]
830+
},
831+
{
832+
"Name": "TC_QuickJitForLoops",
833+
"Weight": "0", /* intentially zero */
834+
"Values": [ "1" ]
835+
},
836+
{
837+
"Name": "TieredCompilation",
838+
"Weight": "0", /* intentially zero */
839+
"Values": [ "1" ]
840+
},
841+
{
842+
"Name": "TieredPGO",
843+
"Weight": "0", /* intentially zero */
844+
"Values": [ "1" ]
845+
}
846+
]
629847
}
630848
],
631849
"Configs": [

Antigen/TestCase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public TestResult Verify()
107107
}
108108
#endif
109109
var baselineVariables = EnvVarOptions.BaseLineVars();
110-
var testVariables = EnvVarOptions.TestVars();
110+
var testVariables = EnvVarOptions.TestVars(includeOsrSwitches: PRNG.Decide(0.3));
111111

112112
// Execute test first and see if we have any errors/asserts
113113
var test = s_testRunner.Execute(compileResult, testVariables, 30);

0 commit comments

Comments
 (0)