Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use performance optimized shuffle_do() method #201

Merged
merged 1 commit into from
Sep 21, 2024

Conversation

EwoutH
Copy link
Member

@EwoutH EwoutH commented Sep 21, 2024

Replace shuffle().do() in 18 models with the performance optimized shuffle_do() method.

shuffle_do() was added in projectmesa/mesa#2283 and is first included in the upcoming Mesa 3.0.0a5 release. It allows for a drop-in performance upgrade:

- self.agents.shuffle().do("step")
+ self.agents.shuffle_do("step")

Which can speed up the Agent activation by over 3x depending on the scenario.

Configuration shuffle().do() shuffle(inplace=True).do() shuffle_do()
10,000 agents, 1,000 steps 8.27 s 3.65 s 3.06 s
100,000 agents, 100 steps 13.71 s 6.31 s 3.71 s
1,000,000 agents, 10 steps 18.36 s 9.44 s 5.75 s

shuffle_do() can be used to replace the old RandomActivation scheduler, as demonstrated in #183.

Part of #111.

Replace shuffle().do() in 18 models with the performance optimized shuffle_do() method
@EwoutH EwoutH merged commit 9a5396f into projectmesa:main Sep 21, 2024
2 of 3 checks passed
@EwoutH
Copy link
Member Author

EwoutH commented Sep 21, 2024

Thanks for the swift reviews!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants