Optimize simulation for tens of thousands of entities - #39
Optimize simulation for tens of thousands of entities#39dmccoystephenson with Copilot wants to merge 5 commits into
Conversation
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
|
Closing as conflicted and partly superseded, following the merge of #35 into A test merge against the current The overlap is substantive rather than incidental. The bounded-log work in this branch ( Two pieces of this branch remain worth carrying forward and are being left on issue #38 rather than discarded:
One tension worth surfacing before this is re-attempted: issue #38 asks for smooth operation with tens of thousands of entities, while #35 (merged for issue #34) introduced a dynamic population cap with a hard ceiling of 200 entities. Whether the target is a large simulated population or a capped one is a product decision that should be settled before the optimization work is redone. The branch is preserved, so this pull request can be reopened if a rebase is preferred over a fresh implementation. Issue #38 stays open. This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). |
The simulation had O(n) friend lookups and unbounded log memory growth, causing performance degradation at scale.
Changes
Data structures: Converted
friends,parents,childrenfrom lists to setsMemory bounds: Added
addLogEntry()withMAX_LOG_SIZE=50Entity removal: Changed
entities_to_removetracking to setExample
Performance
Added
test_performance.pyto validate scaling characteristics.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.