Repository navigation
refactor!: port the simulation onto Clockwork's Microsoft.Orleans.Testing.Simulation - #25
Merged
Merged
Conversation
…ting.Simulation The simulation, scenario, runner, and testing projects now consume Clockwork's prepared Microsoft.Orleans.Testing.Simulation kernel, built from the vendor/Clockwork submodule pinned at 9736589d, instead of the embedded csharp/src/Clockwork snapshot, which this change deletes. - The simulation projects reference the package by ID; eng/OrleansSimulation.targets redirects every package in Clockwork's source-build map to its project in the checkout OrleansSimulationSourceRoot names, so a build has one simulation kernel. An embedding repository names its own Clockwork in Orleans.Consensus.CasPaxos.Embedding.props beside this repository's checkout. - FastCasSimulationCluster composes Clockwork's sealed SimulationCluster and attaches its hosts with AddCustomNode. Node and network randomness come from Clockwork's stable seed domains. Disposal stops the hosts and clients before Clockwork drains pending work. - Delivery delay remains opt-in through FastCasSimulationTransport.EnableDelays, with the historical 1 ms + 5 ms jitter default; Clockwork's network has no such switch. - Node identity in runner logs is the entry's structured ProposerId; the node-prefixing logger factory is gone, and runner logs carry no wall-clock timestamps, so they replay. - RegisterSimulationCluster keeps Run, CreateClient, and CrashNode; Run joins the calling thread to the scheduler's logical thread, and IsSimulationThread exposes that thread. - Test-SourceBoundary.ps1 builds the fixture against an embedding repository's own Clockwork, checks the testing closure resolves exactly that kernel and the gRPC closure none, and that no Clockwork.dll remains in any output. Equivalence: with seed domains changed, per-seed traces differ by design; verdicts and distributions match. Simulation tests, Porcupine (200/200 linearizable), the scenario suite, forking-string corpus, and benchmark sweeps pass on both kernels, and a seed replays to byte-identical artifacts. A benchmark latency margin tuned to one seed of the old stream is set from the topology's spread instead. Implements #20.
Clockwork's cluster disposal runs the work still pending on each node, advancing virtual time past it, so an abandoned operation's deadline or delay could fire after the fixture was disposed and run a consumer continuation that throws ObjectDisposedException on the thread pool. From the start of disposal the fixture's deadlines, cancellations, and delays complete nothing.
… support Clockwork b7e831d adds two fixes: simulation operations reuse a bounded pool of workers instead of starting a thread each (#72), and the Microsoft Testing Platform hooks move out of Microsoft.Orleans.Testing.Simulation.Testing into a separate .Testing.MTP package (#71). With MTP gone from .Testing, the scenario library references .Testing for Clockwork's InMemoryLoggerProvider, as it did before the port. That replaces the buffering logger which only existed to keep MTP out of the library and the runner. Run logs again carry the provider's wall-clock timestamp and thread prefix. The solution now lists .Testing beside the kernel and analyzers. When a solution build reaches a referenced project the solution doesn't list, it builds that project without the solution's configuration. Here that put a Debug .Testing assembly into the Release outputs of the scenario library, the runner, and the simulation tests. CI now checks that the build output holds one build of each simulation assembly and no embedded Clockwork assembly. The MTP integration package stays unsupported in this repository's source build (OCCP0002), because none of its test projects is an MTP application.
Clockwork's cluster disposal drained every member's pending work to quiescence, advancing virtual time to each item's due time. A message still in flight to a member therefore ran during disposal and moved virtual time forward. A message due more than MaxSimulatedTimeAdvance (10 minutes) away failed disposal with "Node attachment cleanup did not reach quiescence", which a consumer could not configure around. Clockwork 65f5be6 (#74) adds SimulationNodeContext.DiscardPendingWork(). FastCasSimulationCluster.DisposeAsync crashes each host and then discards its node's work. Messages and callbacks pending on a member never run, and disposal leaves virtual time where the scenario ended. The fixture's own deadlines and delays live on the cluster lane, so its guards keep those incomplete from the start of disposal. The disposal test becomes a theory over 30-second and 11-minute link delays and asserts virtual time does not advance, as does the cluster-level disposal test. Without the discard, all three cases fail on this pin: the 11-minute case with the quiescence timeout, and the others because virtual time advances by 30 s and 1 s.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
4dad617353f6251e3c2030872e5bb5f4a5560df9Orleans.Consensus.CasPaxos.Testingis unverified until Clog moves its pins.Closes #20. Targets
main, where #21 has landed, and is meant to land by fast-forward to this head.What changes
The simulation, scenario, runner and Testing projects now run on Clockwork's
Microsoft.Orleans.Testing.Simulationkernel, built from source. The embeddedcsharp/src/Clockworksnapshot is deleted. Production projects (core, Server, Grpc, Sqlite, Rest, Host) reference no simulation package.vendor/Clockworkis a submodule pinned at65f5be6. That commit includes worker reuse (perf: reuse simulation operation workers Clockwork#72), the Testing/MTP split (fix: decouple simulation test support from MTP Clockwork#71), and member-work discard (feat: discard stopped member work Clockwork#74).Microsoft.Orleans.Testing.Simulation, plus the framework-neutral.Testingin the scenario library.csharp/eng/OrleansSimulation.targetsreads Clockwork'seng/Microsoft.Orleans.Testing.Simulation.SourceBuild.propsand swaps each package reference for its source project, so nothing is restored from a feed. Library packages become project references, and the analyzers an analyzer reference.Microsoft.Orleans.Testing.Simulation*package, and OCCP0002 for a package whose role this build doesn't supply (instrumentation build, MTP integration, tool).OrleansSimulationSourceRootdefaults tovendor/Clockwork/. A repository that builds this one from source, such as Clog, overrides it withOrleans.Consensus.CasPaxos.Embedding.props, placed in the directory containing this checkout. That file is the only import from outside this repository's build boundary. Boundary files undervendor/keep Clockwork's own build policy separate.FastCasSimulationClusternow wraps a sealedSimulationClusterinstead of deriving from it. Nodes attach withAddCustomNode, and transport delivery goes throughSimulationSchedulerLane.RunForreplacesRunForDurationand stops exactly at the target time.EnableDelays, moves to the transport, because upstream's network has none. The historical 1 ms base and 5 ms jitter defaults are kept.RegisterSimulationClusterkeepsRun,CreateClient,CrashNode,DelayAsyncandTrace, and addsIsSimulationThread.FastCasSimulationCluster.DisposeAsynccrashes each host, then callsSimulationNodeContext.DiscardPendingWork()on its node, then disposes the Clockwork cluster.InMemoryLoggerProvider, as it did before the port. Runlogs.txtlines carry the provider's wall-clock timestamp and thread prefix, as before.vendor/**and.gitmodules. A new step fails if the build output contains anyClockwork*.dll, or two different builds of the same simulation assembly.just csharp-fmtexcludesvendor/.Importing Clockwork: list every Clockwork project in the solution
csharp/Orleans.Consensus.CasPaxos.slnxlists, under/vendor/, each Clockwork source project this repository builds: the kernel, the analyzers and.Testing. When a solution build reaches a referenced project the solution doesn't list, MSBuild builds it without the solution's configuration, so in Debug.Before
.Testingwas listed, a cleandotnet build -c Releaseof the solution copied a DebugOrleans.Testing.Simulation.Testing.dllinto the Release outputs of Scenarios, Runner and Simulation.Tests. A project-level build produced Release, and tests passed either way.Adding a reference to another Clockwork package (for example
.Instrumentation) means adding its source project to/vendor/. CI's "One build of each simulation assembly" step fails when a project is missing from the solution this way.Equivalence evidence
The base is the embedded kernel at
24da806. The "port" columns are this branch at the initial Clockwork pin9736589dand at the final pin65f5be6.Per-seed traces differ between the embedded kernel and Clockwork by design, because Clockwork derives node randomness per address and gives the network its own seed domain. Verdicts and distributions match. Across the Clockwork pins (
9736589d, the intermediateb7e831d, and65f5be6), same-seed artifacts are identical.validate_porcupine.ps1 -Seed 424242 -Rounds 100"Identical" means every artifact is byte-identical except
logs.txt. Those lines start with a wall-clock timestamp and thread id, and the logs are equal once that prefix is removed.New tests cover the following:
One margin in
BenchmarkWorkloadTestsmoved from 20 ms to 10 ms. Over 40 seeds, both kernels produce identical gap distributions; the rationale is in a comment.Single kernel and duplicate assemblies
csharp/scripts/Test-SourceBoundary.ps1builds this repository inside an isolated embedding repository that has its own Clockwork and the embedding hook. It asserts the following:Orleans.Consensus.CasPaxos.Testingeach resolve exactly oneOrleans.Testing.Simulation, from the embedder's project.Clockwork*.dllexists anywhere, including the Native AOT client's output..Testing×4 and the analyzers ×1. Each has a single hash, and all are Release builds.Clockwork*.dlland noMicrosoft.Testing.Platform*.dll.Performance
CI at this head
All runs at this head pass:
The three-process smoke passes, and every job checks out Clockwork
65f5be6.For Clog
Clog's API surface is unchanged:
RegisterSimulationCluster(Run,CreateClient,CrashNode,DelayAsync,Trace) andRecordingFatalErrorHandler. To adopt this, in one PR that moves both pins:65f5be6. Use theOrleans.Consensus.CasPaxos.*project names from refactor!: rename the C# projects to Orleans.Consensus.CasPaxos #21.vendor/Orleans.Consensus.CasPaxos.Embedding.propsbesidevendor/fast-caspaxos, with<OrleansSimulationSourceRoot>$(MSBuildThisFileDirectory)Clockwork/</OrleansSimulationSourceRoot>.eng/Clockwork.targetsto theOrleansSimulation*properties, theORLEANS_SIMULATION*variables and theMicrosoft.Orleans.Testing.Simulation.*IDs. That includes.Testing.MTPfor MTP test apps.vendor/fast-caspaxos/vendor/Clockwork, which the embedding hook leaves unbuilt.FastCasSimulationClusteris no longer aSimulationClustersubclass, andRunForDurationis nowRunFor; Clog uses neither. InstrumentingClog.CasPaxos.Testsmay need fixture work, becauseRun's first segment executes on the control-scope thread.Out of scope
Pre-existing failures, unchanged by this PR, are filed separately:
run_comparative_benchmarks.ps1concatenates mode and topology.dotnet formatfails on untouched Host and gRPC test files.run_parallel_forkingstring.ps1overwrites-Jobs, so it never waits for its jobs.The configuration section, telemetry names (#19), wire formats and persisted formats are unchanged.