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
45 changes: 45 additions & 0 deletions .github/scripts/frozen_release_control.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env python3
"""Run an existing frozen-image ABBA with one explicit native scheduling intervention."""
import argparse
import json
import os
from pathlib import Path
import subprocess
import sys


def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("arm", choices=("async", "sync"))
parser.add_argument("artifact", type=Path)
parser.add_argument("probe", type=Path)
parser.add_argument("output", type=Path)
parser.add_argument("--trace-tool", type=Path, required=True)
parser.add_argument("--profile-reader", type=Path, required=True)
parser.add_argument("--keep-traces", action="store_true", required=True)
args = parser.parse_args()
# Keep orchestration, verification, profiling, extraction and failures in their
# existing owner. The child-only variable cannot affect another experiment.
environment = dict(os.environ, RELAYER_FROZEN_RELEASE_CHANNEL=args.arm)
metadata = {
"arm": args.arm, "channel": "fixture Release only", "capacity": 8,
"fullMode": "Wait", "singleReader": False, "singleWriter": False,
"allowSynchronousContinuations": args.arm == "sync",
"completionBoundary": "original-BenchmarkDotNet-AwaitHelper.GetResult",
"limits": "Both arms replace the channel before setup and differ only in its native scheduling option. Scheduling and downstream execution change. New instrumented fixed-count executions are not historical allocation attribution, exact object counts, or permission for a production trade-off. Never subtract sampled weights or independent totals."
}
# Refuse overwrite before executing; retain the selected arm even on failure.
metadata_path = args.output.with_name(args.output.name + "-intervention.json")
metadata_path.parent.mkdir(parents=True, exist_ok=True)
with metadata_path.open("x") as output:
json.dump(metadata, output, indent=2)
output.write("\n")
command = [sys.executable, str(Path(__file__).with_name("frozen_concurrent_control.py")),
str(args.artifact), str(args.probe), str(args.output), "--bdn-await",
"--trace-tool", str(args.trace_tool), "--profile-reader", str(args.profile_reader),
"--keep-traces"]
subprocess.run(command, env=environment, check=True)


if __name__ == "__main__":
main()
45 changes: 45 additions & 0 deletions .github/scripts/test_frozen_release_control.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import json
import os
from pathlib import Path
import subprocess
import tempfile
import unittest
from unittest.mock import patch

from frozen_release_control import main


class ReleaseInterventionTests(unittest.TestCase):
def test_arms_use_existing_profile_launcher_and_child_only_environment(self):
for arm in ("async", "sync"):
with self.subTest(arm=arm), tempfile.TemporaryDirectory() as directory:
output = Path(directory) / "capture"
args = ["control", arm, "inputs", "probe.dll", str(output), "--trace-tool", "trace", "--profile-reader", "reader", "--keep-traces"]
with patch.dict(os.environ, {"RELAYER_FROZEN_RELEASE_CHANNEL": "inherited"}), patch("sys.argv", args), patch("frozen_release_control.subprocess.run") as run:
main()
self.assertEqual(os.environ["RELAYER_FROZEN_RELEASE_CHANNEL"], "inherited")
command = run.call_args.args[0]
self.assertTrue(command[1].endswith("frozen_concurrent_control.py"))
self.assertIn("--bdn-await", command)
self.assertIn("--keep-traces", command)
self.assertEqual(run.call_args.kwargs["env"]["RELAYER_FROZEN_RELEASE_CHANNEL"], arm)
metadata = json.loads(output.with_name("capture-intervention.json").read_text())
self.assertEqual(metadata["allowSynchronousContinuations"], arm == "sync")
self.assertEqual(metadata["capacity"], 8)

def test_failed_capture_retains_arm_metadata_and_propagates_failure(self):
with tempfile.TemporaryDirectory() as directory:
output = Path(directory) / "capture"
args = ["control", "sync", "inputs", "probe.dll", str(output), "--trace-tool", "trace", "--profile-reader", "reader", "--keep-traces"]
with patch("sys.argv", args), patch("frozen_release_control.subprocess.run", side_effect=subprocess.CalledProcessError(1, "capture")), self.assertRaises(subprocess.CalledProcessError):
main()
self.assertEqual(json.loads(output.with_name("capture-intervention.json").read_text())["arm"], "sync")

def test_rejects_unknown_arm_before_launch(self):
with patch("sys.argv", ["control", "unknown"]), patch("frozen_release_control.subprocess.run") as run, self.assertRaises(SystemExit):
main()
run.assert_not_called()


if __name__ == "__main__":
unittest.main()
82 changes: 82 additions & 0 deletions .github/workflows/frozen-release-scheduling-control.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Frozen release-channel scheduling control

# #537: intervene on the native owner family seen in net10 measured stacks.
# Separate instrumented executions; no historical attribution or production trade-off.
on:
pull_request:
paths:
- '.github/workflows/frozen-release-scheduling-control.yml'
workflow_dispatch:
inputs:
performance_run:
description: Retained net10 Performance run for release-channel scheduling intervention
type: string
default: "43124385683"

permissions:
contents: read
actions: read

jobs:
owners:
runs-on: ubuntu-24.04
timeout-minutes: 30
env:
PERFORMANCE_RUN: ${{ inputs.performance_run || '43124385683' }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
dotnet-version: |
10.0.403
11.0.100
- name: Record host and build net10 probe
run: |
mkdir -p results
dotnet --info > results/runtime.txt
uname -a > results/host.txt
python3 -m unittest discover -s .github/scripts -p test_frozen_release_control.py > results/launcher-tests.log 2>&1
# The global property overrides the probe's net11 default without changing
# historical tools or rebuilding any retained workload assembly.
dotnet restore tools/FrozenConcurrentProbe -p:TargetFramework=net10.0 > results/probe-restore.log 2>&1
dotnet build tools/FrozenConcurrentProbe -c Release -p:TargetFramework=net10.0 --no-restore > results/probe-build.log 2>&1
# The reader runs out of process; its framework does not select the probe runtime.
dotnet build tools/FrozenAllocationReader -c Release > results/reader-build.log 2>&1
dotnet tool install dotnet-trace --tool-path .diagnostic-tools --version 10.0.750501 > results/trace-install.log 2>&1
- name: Download exact original inputs
env:
GH_TOKEN: ${{ github.token }}
run: |
[[ "$PERFORMANCE_RUN" =~ ^[0-9]+$ ]] || { echo "Invalid run ID: $PERFORMANCE_RUN" >&2; exit 1; }
gh run download "$PERFORMANCE_RUN" --name "performance-$PERFORMANCE_RUN-1" --dir inputs
- name: Capture both native release-channel scheduling arms with the original waiter
if: always()
run: |
# Both arms replace only Release with capacity 8, Wait, multiple readers/writers.
# Vary only the native AllowSynchronousContinuations option. Profiles cover
# full delivery, including downstream execution affected by scheduling.
# Never subtract weighted samples or independent totals, infer historical
# ownership, or interpret this as permission for a production trade-off.
failed=0
for arm in async sync; do
python3 .github/scripts/frozen_release_control.py "$arm" inputs tools/FrozenConcurrentProbe/bin/Release/net10.0/FrozenConcurrentProbe.dll "results/release-$arm-profiled" --trace-tool .diagnostic-tools/dotnet-trace --profile-reader tools/FrozenAllocationReader/bin/Release/net11.0/FrozenAllocationReader.dll --keep-traces || failed=1
done
exit "$failed"
- name: Retain all outcomes and executable inputs
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: frozen-release-scheduling-control-${{ github.run_id }}-${{ github.run_attempt }}
path: |
results/
inputs/
tools/FrozenConcurrentProbe/
tools/FrozenFixtureProbe/InvocationAllocations.cs
tools/FrozenMeasurementEvents.cs
tools/FrozenAllocationReader/
.diagnostic-tools/
.github/scripts/frozen_concurrent_control.py
.github/scripts/test_frozen_release_control.py
.github/scripts/frozen_release_control.py
.github/workflows/frozen-release-scheduling-control.yml
retention-days: 90
30 changes: 29 additions & 1 deletion tools/FrozenConcurrentProbe/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Reflection;
using System.Runtime.Loader;
using System.Text.Json;
using System.Threading.Channels;

// Investigation tool only: bind once to the original executable; never rebuild its workload.
if (args.Length is < 1 or > 2 || (args.Length == 2 && args[1] is not ("--exact-roundtrips" or "--bdn-await")))
Expand All @@ -11,6 +12,11 @@
var nativeAllocations = NativeAllocationRegion.Load();
if (nativeAllocations is not null && !bdnAwait)
throw new ArgumentException("Native allocation profiling requires the original BDN waiter control.");
var releaseArm = Environment.GetEnvironmentVariable("RELAYER_FROZEN_RELEASE_CHANNEL");
if (releaseArm is not (null or "async" or "sync") || (releaseArm is not null && !bdnAwait))
throw new ArgumentException("Release-channel intervention requires async or sync and --bdn-await.");
var replaceRelease = releaseArm is not null;
var synchronousRelease = releaseArm == "sync";
var image = Path.GetFullPath(args[0]);
var context = new AssemblyLoadContext("Frozen", isCollectible: false);
context.Resolving += (_, name) =>
Expand All @@ -21,6 +27,26 @@
var assembly = context.LoadFromAssemblyPath(Path.Combine(image, "Relayer.Benchmarks.dll"));
var type = assembly.GetType("Relayer.Benchmarks.EndToEndBenchmarks", throwOnError: true)!;
var fixture = Activator.CreateInstance(type)!;
// Owner intervention only: replace the fixture's release channel before setup. Both
// arms replace it, differing only in the native scheduling option. Keep capacity,
// full mode and multi-reader/writer contracts; never rebuild the frozen workload.
if (replaceRelease)
{
var signals = type.GetField("_signals", BindingFlags.Instance | BindingFlags.NonPublic)!.GetValue(fixture)!;
var release = signals.GetType().GetField("<Release>k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic)!;
if (release.GetValue(signals) is not Channel<byte> original || original.Reader.TryPeek(out _))
throw new InvalidOperationException("Expected the empty original release channel before setup.");
var replacement = Channel.CreateBounded<byte>(new BoundedChannelOptions(8)
{
AllowSynchronousContinuations = synchronousRelease,
FullMode = BoundedChannelFullMode.Wait,
SingleReader = false,
SingleWriter = false
});
release.SetValue(signals, replacement);
if (!ReferenceEquals(release.GetValue(signals), replacement))
throw new InvalidOperationException("Release-channel intervention did not bind to the frozen fixture.");
}
var setup = type.GetMethod("Setup")!.CreateDelegate<Func<Task>>(fixture);
var cleanup = type.GetMethod("Cleanup")!.CreateDelegate<Func<Task>>(fixture);
var run = type.GetMethod("ConcurrentRoundTrip")!.CreateDelegate<Func<ValueTask<int>>>(fixture);
Expand Down Expand Up @@ -74,10 +100,12 @@
throw new InvalidOperationException($"Unexpected delivery sum: {result}.");
Console.WriteLine(JsonSerializer.Serialize(new
{
instrumentation = nativeAllocations is not null ? "native-object-allocation-callbacks" : exactRoundTrips ? "exact-synchronous-roundtrip-calls" : "none",
instrumentation = nativeAllocations is not null ? "native-object-allocation-callbacks" : replaceRelease ? "native-release-channel-scheduling-intervention" : exactRoundTrips ? "exact-synchronous-roundtrip-calls" : "none",
exactRegion = nativeAllocations is not null
? "Process-wide CLR ObjectAllocated callbacks from native Begin after warmup through native End after all measured deliveries complete, including counter and timing boundaries. Reports heap objects and runtime sizes by type; no stacks or historical attribution. Do not subtract from other controls."
: "One original ConcurrentRoundTrip delegate call per record (eight messages), before awaiting its returned ValueTask. Calling-thread work only; excludes other threads and later continuations. No type or historical attribution; do not subtract from other controls.",
releaseChannel = new { replaced = replaceRelease, allowSynchronousContinuations = synchronousRelease, capacity = 8 },
interventionLimits = "Only the fixture release channel is replaced; each arm uses the native bounded channel with identical capacity/full-mode/multi-reader-writer settings. Synchronous continuations alter scheduling and downstream execution. These new fixed-count executions cannot identify the historical delta, exact allocated objects, or justify a production trade-off. Do not subtract sampled weights or independent totals.",
invocationAllocations = invocationReport,
image, completionBoundary = bdnAwait ? "original-BenchmarkDotNet-AwaitHelper.GetResult" : "asynchronous-await",
limits = "Fixed-count diagnostic, not original adaptive BDN replay or historical allocation-owner attribution.",
Expand Down
Loading