Add partitioned parallel simulation (ParallelSimulation)#102
Open
adamfilli wants to merge 2 commits into
Open
Conversation
…eparate threads Introduces a partitioned parallel execution mode where users declare independent entity groups (partitions) that run as separate Simulation instances on a thread pool. Enables near-linear speedup for workloads with natural parallelism (fleet nodes, regional deployments, sharded systems) on free-threaded Python 3.13t+. Key changes: - Convert parallel.py module to parallel/ package, moving existing ParallelRunner to parallel/runner.py - New ParallelSimulation, SimulationPartition, and ParallelSimulationSummary types - Two-layer partition validation: static attribute walking at init + runtime event target guard in the simulation loop - Convert _active_code_debugger from module global to contextvars.ContextVar for thread safety - Add _event_validator hook to Simulation (zero overhead when unused) - 32 new tests (20 unit, 12 integration), all 2984 tests pass Co-Authored-By: Claude Opus 4.6 <[email protected]>
Describes extending ParallelSimulation with PartitionLink declarations and windowed execution so partitions can exchange cross-partition events while maintaining time synchronization via barrier-based coordination. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Owner
Author
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.
Summary
ParallelSimulation— a partitioned parallel execution mode where users declare independent entity groups that run as separateSimulationinstances on a thread poolparallel.pymodule into aparallel/package, preserving the existingParallelRunner(process-based sweeps/replicas) alongside the new thread-based partitioned simulation_active_code_debuggerfrom a module global tocontextvars.ContextVarfor thread safety_event_validatorhook toSimulation(zero overhead when unused, excluded from fast path)New types
SimulationPartitionParallelSimulationSimulationinstances and runs them onThreadPoolExecutorParallelSimulationSummaryTest plan
🤖 Generated with Claude Code