Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions .github/scripts/frozen_scope_control.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Fixed ABBA replay of run 42772012652 ScopeOnly images, never a gate retry."""
"""Fixed ABBA replay of retained scope benchmark images, never a gate retry."""
import argparse
import json
import os
Expand All @@ -15,7 +15,9 @@
BENCHMARK = "Relayer.Benchmarks.ConsumePipelineBenchmarks.ScopeOnly"


def executable(root, scoped):
def executable(root, scoped, method="ScopeOnly"):
if method not in ("ScopeOnly", "ScopeAndHandlerResolution"):
raise ValueError("Unsupported retained scope benchmark")
root = Path(root).resolve()
files = {item["path"] for item in json.loads((root / "inventory-sha256.json").read_text())["files"]}
sources = list(root.glob("builds/*/Relayer.Benchmarks-DefaultJob-*/*.notcs"))
Expand All @@ -25,9 +27,9 @@ def executable(root, scoped):
runners = re.findall(r"public unsafe class Runnable_(\d+) : global::Relayer\.Benchmarks\.ConsumePipelineBenchmarks\s*\{(.*?)(?=public unsafe class Runnable_|\Z)", source.read_text(), re.S)
parameter = "instance.ScopedHandler = " + str(scoped).lower() + ";"
matches = [(identity, body) for identity, body in runners
if parameter in body and "AwaitHelper.GetResult(ScopeOnly())" in body]
if parameter in body and f"AwaitHelper.GetResult({method}())" in body]
if len(matches) != 1:
raise ValueError("Expected one original ScopeOnly runner for selected parameter")
raise ValueError("Expected one original selected scope runner for selected parameter")
identity, body = matches[0]
if "OperationsPerInvoke = 1," not in body or "MeasureExtraStats = true," not in body:
raise ValueError("Expected original one-operation GC-stat job")
Expand Down Expand Up @@ -62,17 +64,28 @@ def main():
help="Separate code-capture experiment; its timings are not performance evidence")
parser.add_argument("--tiered-compilation", choices=("default", "off"), default="default",
help="Diagnostic runtime control; off uses native DOTNET_TieredCompilation=0")
parser.add_argument("--method", choices=("ScopeOnly", "ScopeAndHandlerResolution"),
default="ScopeOnly", help="Select the original generated benchmark runner")
parser.add_argument("--jit-method", default="*",
help="Native DOTNET_JitDisasm method filter; requires --jit-disassembly")
args = parser.parse_args()
if args.jit_method != "*" and not args.jit_disassembly:
parser.error("--jit-method requires --jit-disassembly")
if not args.jit_method.strip():
parser.error("--jit-method must not be empty")
benchmark = BENCHMARK.rsplit(".", 1)[0] + "." + args.method
builds = args.artifact.resolve() / "performance-builds"
commits = {side: verify(builds / side) for side in SIDES}
runners = {(side, scoped): executable(builds / side, scoped)
runners = {(side, scoped): executable(builds / side, scoped, args.method)
for side in SIDES for scoped in (True, False)}
args.output.mkdir(parents=True, exist_ok=False)
protocol = {"commits": commits, "benchmark": BENCHMARK,
protocol = {"commits": commits, "benchmark": benchmark,
"plan": "Scoped ABBA, then unscoped ABBA; A2 reuses first baseline image",
"engine": "Original Default job, native NoAcknowledgementConsoleHost without anonymous-pipe parent",
"limits": "New host/process executions, not historical reconstruction. Image-associated differences do not identify a production defect; absent differences do not prove equivalence. No threshold changes or gate pass claim.",
"jitDisassembly": args.jit_disassembly,
"jitMethod": args.jit_method if args.jit_disassembly else None,
"captureLimits": "Method filtering reduces concurrent listing output; it does not serialize JIT compilation. Missing, interleaved or precompiled methods remain limitations, not evidence of equality.",
"tieredCompilation": args.tiered_compilation,
"runtimeControlLimits": "Disabling tiering changes execution, not production configuration. Cross-condition timing is diagnostic only; host/process order remains a confound.",
"timingUse": "Excluded: JIT diagnostics perturb execution" if args.jit_disassembly else "New ABBA experiment only",
Expand All @@ -81,7 +94,7 @@ def main():
for side in LAUNCHES:
image, identity = runners[side, scoped]
protocol["launches"].append({"side": side, "scoped": scoped,
"command": ["dotnet", str(image), "--benchmarkName", BENCHMARK,
"command": ["dotnet", str(image), "--benchmarkName", benchmark,
"--job", "Default", "--benchmarkId", identity]})
(args.output / "protocol.json").write_text(json.dumps(protocol, indent=2) + "\n")
outcomes = []
Expand All @@ -97,7 +110,7 @@ def main():
if key in environment}
disassembly = (args.output / f"{index}-{launch['side']}-{launch['scoped']}.asm").resolve()
if args.jit_disassembly:
environment.update(DOTNET_JitDisasm="*", DOTNET_JitDisasmDiffable="1",
environment.update(DOTNET_JitDisasm=args.jit_method, DOTNET_JitDisasmDiffable="1",
DOTNET_JitStdOutFile=str(disassembly))
outcome["diagnosticEnvironment"] = {key: environment[key] for key in
("DOTNET_JitDisasm", "DOTNET_JitDisasmDiffable", "DOTNET_JitStdOutFile")}
Expand Down
76 changes: 71 additions & 5 deletions .github/scripts/test_frozen_scope_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ def test_selects_parameter_and_rejects_wrong_job_and_missing_inventory(self):
with self.assertRaises(ValueError):
executable(root, True)

def test_resolution_selection_uses_its_original_runner_and_rejects_scope_only(self):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
source, image = original_tests.OriginalRunnerTests().fixture(root, '7')
original = source.read_text().replace('EndToEndBenchmarks', 'ConsumePipelineBenchmarks').replace('ConcurrentRoundTrip()', 'ScopeAndHandlerResolution()').replace('OperationsPerInvoke = 8', 'OperationsPerInvoke = 1').replace('{ Operations', '{ instance.ScopedHandler = true; Operations')
source.write_text(original)
self.assertEqual(executable(root, True, 'ScopeAndHandlerResolution'), (image.resolve(), '7'))
with self.assertRaises(ValueError):
executable(root, True)
with self.assertRaises(ValueError):
executable(root, False, 'ScopeAndHandlerResolution')
with self.assertRaises(ValueError):
executable(root, True, 'Other')

def test_all_launches_attempted_and_unfavorable_results_retained_after_failure(self):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
Expand All @@ -51,7 +65,7 @@ def execute(command, **kwargs):

with patch('sys.argv', ['control', directory, str(root / 'output')]), \
patch('frozen_scope_control.verify', return_value='commit') as verify, \
patch('frozen_scope_control.executable', side_effect=lambda path, scoped: (path / 'runner.dll', '4' if scoped else '0')), \
patch('frozen_scope_control.executable', side_effect=lambda path, scoped, method="ScopeOnly": (path / 'runner.dll', '4' if scoped else '0')), \
patch('frozen_scope_control.subprocess.run', side_effect=execute):
with self.assertRaises(SystemExit):
main()
Expand Down Expand Up @@ -79,16 +93,19 @@ def execute(command, **kwargs):
Path(environment['DOTNET_JitStdOutFile']).write_text(
'; Assembly listing for method Example:ScopeOnly()\n')

with patch('sys.argv', ['control', directory, str(root / 'output'), '--jit-disassembly']), \
with patch('sys.argv', ['control', directory, str(root / 'output'), '--jit-disassembly', '--method', 'ScopeAndHandlerResolution']), \
patch('frozen_scope_control.verify', return_value='commit') as verify, \
patch('frozen_scope_control.executable', side_effect=lambda path, scoped: (path / 'runner.dll', '4' if scoped else '0')), \
patch('frozen_scope_control.executable', side_effect=lambda path, scoped, method="ScopeOnly": (path / 'runner.dll', '4' if scoped else '0')), \
patch('frozen_scope_control.subprocess.run', side_effect=execute):
if emit_code:
main()
else:
with self.assertRaises(SystemExit):
main()
self.assertEqual(len(environments), 8)
protocol = json.loads((root / 'output/protocol.json').read_text())
self.assertTrue(protocol['benchmark'].endswith('.ScopeAndHandlerResolution'))
self.assertTrue(all(launch['command'][3] == protocol['benchmark'] for launch in protocol['launches']))
self.assertEqual(verify.call_count, 6)
self.assertEqual(len({env['DOTNET_JitStdOutFile'] for env in environments}), 8)
outcomes = json.loads((root / 'output/outcomes.json').read_text())
Expand All @@ -113,7 +130,7 @@ def execute(command, **kwargs):
with patch('sys.argv', ['control', directory, str(root / 'output'), '--tiered-compilation', setting]), \
patch('frozen_scope_control.os.environ', parent), \
patch('frozen_scope_control.verify', return_value='commit'), \
patch('frozen_scope_control.executable', side_effect=lambda path, scoped: (path / 'runner.dll', '4')), \
patch('frozen_scope_control.executable', side_effect=lambda path, scoped, method="ScopeOnly": (path / 'runner.dll', '4')), \
patch('frozen_scope_control.subprocess.run', side_effect=execute):
main()
expected = '0' if setting == 'off' else '1'
Expand Down Expand Up @@ -143,7 +160,7 @@ def execute(command, **kwargs):
'--tiered-compilation', 'off', '--jit-disassembly']), \
patch('frozen_scope_control.os.environ', parent), \
patch('frozen_scope_control.verify', return_value='commit') as verify, \
patch('frozen_scope_control.executable', side_effect=lambda path, scoped: (path / 'runner.dll', '4')), \
patch('frozen_scope_control.executable', side_effect=lambda path, scoped, method="ScopeOnly": (path / 'runner.dll', '4')), \
patch('frozen_scope_control.subprocess.run', side_effect=execute):
main()
self.assertEqual(verify.call_count, 6)
Expand All @@ -161,6 +178,55 @@ def execute(command, **kwargs):
self.assertEqual(protocol['tieredCompilation'], 'off')
self.assertTrue(protocol['jitDisassembly'])

def test_method_filter_reaches_every_child_without_changing_parent_or_results(self):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
environments = []
listing = ('; Assembly listing for method Dispatcher1:GetService()\n'
'; Total bytes of code 7\n')

def execute(command, **kwargs):
environment = kwargs['env']
environments.append(environment)
kwargs['stdout'].write(COMPLETE)
# Repeated compilations are raw evidence; never deduplicate them.
Path(environment['DOTNET_JitStdOutFile']).write_text(listing * 2)

parent = {'DOTNET_JitDisasm': '*'}
with patch('sys.argv', ['control', directory, str(root / 'output'),
'--jit-disassembly', '--jit-method', 'VisitScopeCache GetService']), \
patch('frozen_scope_control.os.environ', parent), \
patch('frozen_scope_control.verify', return_value='commit') as verify, \
patch('frozen_scope_control.executable', return_value=(root / 'runner.dll', '4')), \
patch('frozen_scope_control.subprocess.run', side_effect=execute):
main()
self.assertEqual(verify.call_count, 6)
self.assertEqual(len(environments), 8)
self.assertTrue(all(env['DOTNET_JitDisasm'] == 'VisitScopeCache GetService' for env in environments))
self.assertEqual(parent, {'DOTNET_JitDisasm': '*'})
protocol = json.loads((root / 'output/protocol.json').read_text())
self.assertEqual(protocol['jitMethod'], 'VisitScopeCache GetService')
outcomes = json.loads((root / 'output/outcomes.json').read_text())
self.assertTrue(all(item['diagnosticEnvironment']['DOTNET_JitDisasm'] == 'VisitScopeCache GetService'
for item in outcomes))
self.assertTrue(all('error' not in item and 'meanNs' not in item and
'bytesPerOperation' not in item for item in outcomes))
self.assertEqual(len(list((root / 'output').glob('*.asm'))), 8)
self.assertTrue(all(path.read_text() == listing * 2
for path in (root / 'output').glob('*.asm')))

def test_invalid_filter_never_launches_or_verifies_inputs(self):
for options in (['--jit-method', 'Resolve'],
['--jit-disassembly', '--jit-method', ' ']):
with self.subTest(options=options), \
patch('sys.argv', ['control', 'inputs', 'output'] + options), \
patch('frozen_scope_control.verify') as verify, \
patch('frozen_scope_control.subprocess.run') as execute:
with self.assertRaises(SystemExit):
main()
verify.assert_not_called()
execute.assert_not_called()

def test_invalid_archive_never_launches(self):
with tempfile.TemporaryDirectory() as directory, \
patch('sys.argv', ['control', directory, str(Path(directory) / 'output')]), \
Expand Down
27 changes: 20 additions & 7 deletions .github/workflows/frozen-scope-control.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Frozen scope throughput control
name: Frozen filtered handler-resolution code capture

# New historical-input experiment, never a rerun of the performance gate.
on:
Expand All @@ -18,6 +18,12 @@ jobs:
control:
runs-on: ubuntu-24.04
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
# Native method-name filters: each family gets separate ABBA processes.
# Keep output narrow: whole-process output interleaved in run 42788193160.
method: [Resolve, GetRequiredService, GetService, "VisitScopeCache GetService", Dispose, DisposeAsync, WorkloadActionNoUnroll, WorkloadActionUnroll]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
Expand All @@ -33,17 +39,24 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
run: |
gh run download 42772012652 --name performance-42772012652-1 --dir inputs
# Timing controls are retained in run 42779203851. Inspect native code in
# the unfavorable tiering-off condition; diagnostic timings are excluded.
- name: Capture native code with tiered compilation disabled
gh run download 42774764169 --name performance-42774764169-1 --dir inputs
# Separate diagnostic execution; retain every ABBA attempt, never gate timing.
# https://github.com/dotnet/runtime/blob/v10.0.14/docs/design/coreclr/jit/viewing-jit-dumps.md#note-about-multi-threaded-applications
# Filtering reduces output contention; it does not synchronize compilations.
# Run 42790849618 confirmed VisitScopeCache has no unscoped listing.
# Native space-separated filters retain it alongside the common GetService
# caller. Absence of VisitScopeCache is not equality across scope modes.
# Missing listings still fail; malformed output still requires strict audit.
- name: Capture one method family without tier transitions
if: success() || failure()
run: python3 .github/scripts/frozen_scope_control.py inputs results/tiering-off-code --tiered-compilation off --jit-disassembly
env:
JIT_METHOD: ${{ matrix.method }}
run: python3 .github/scripts/frozen_scope_control.py inputs results/code --method ScopeAndHandlerResolution --tiered-compilation off --jit-disassembly --jit-method "$JIT_METHOD"
- name: Retain all outcomes and executable inputs
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: frozen-scope-control-${{ github.run_id }}-${{ github.run_attempt }}
name: frozen-handler-resolution-${{ matrix.method }}-${{ github.run_id }}-${{ github.run_attempt }}
path: |
results/
inputs/
Expand Down
Loading