Merged
Conversation
Collaborator
Author
|
I ran this locally for 5 consecutive times Timings Comparison Using median
Here is the script to test locally and results |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Collaborator
Author
|
I can still see considerable regression locally |
|
Performance benchmarks:
|
Collaborator
Author
|
Using min
Results: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Collaborator
Author
|
I have reverted the PR to use original |
Member
|
Thanks for the effort. Can you give me some insights/statistics how much the warmup helps? |
quaquel
reviewed
Jan 24, 2026
Collaborator
Author
improvement = (warm_up - stable_run)/warm_up |
Member
|
Sorry I meant reliability statistics, not speed. So standard deviation, quartile intervals, maybe a histogram or bloxplot. |
Collaborator
Author
Member
|
I think that is quite conclusive. Warm-up is variance-reducing. |
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
This PR refactors
benchmarks/global_benchmark.pyto address high variance and inconsistency in our performance benchmarks (observed up to ±30% locally and on CI). The changes align our methodology with industry standards (e.g., NetLogo, ASV, CPython) by introducing warm-up periods, controlling garbage collection, improving timer precision.Motive
The current benchmarking setup suffers from several critical flaws causing unstable results:
gc.enable()allows the Garbage Collector to fire unpredictably during timed runs, causing random spikes in execution time.timeit.default_timer()lacks the strict monotonicity required for precise micro-benchmarking compared totime.perf_counter().model.remove_agents()at the end ofrun_model.Implementation
gc.disable()is called before the timing loop to prevent random pauses.gc.collect()is called explicitly to ensure a consistent memory state for each run.gc.enable()to re-enable GCtimeit.default_timer()withtime.perf_counter()to guarantee high-resolution, monotonic timing.model.remove_all_agents()at the end ofrun_modelto mitigate memory accumulation (addressing @quaquel's feedback).