Skip to content

Reduce allocations when copying count states - #1271

Open
sbfnk-bot wants to merge 4 commits into
mainfrom
issue-1269-reduce-count-level-simulation-to-the-dai
Open

sbfnk-bot wants to merge 4 commits into
mainfrom
issue-1269-reduce-count-level-simulation-to-the-dai

Conversation

@sbfnk-bot

@sbfnk-bot sbfnk-bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Copy daily-count histories using CountSimulationState to reduce allocations while keeping the arrays independently mutable. The allocation check compares copies of the complete state.

The count-simulation and quality checks passed.

Still to do on the issue: Make count continuation state bounded by the generation-time support; remove generation-level simulation, its resolution and multiplier; and move the mean-field, linear-noise and hybrid approximations with their documentation and tests into a satellite package.

This PR partly addresses #1269.

sbfnk-bot and others added 3 commits November 27, 2026 13:57
Co-authored-by: sbfnk <sebastian.funk@lshtm.ac.uk>
Co-authored-by: sbfnk <sebastian.funk@lshtm.ac.uk>
Co-authored-by: sbfnk <sebastian.funk@lshtm.ac.uk>
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark comparison vs base

Minimum time per call. Buckets are PR time as a % of base, so lower is faster (🟢 faster, ⚪ within 5%, 🔴 slower). Counts of benchmarks per bucket:

Group 🟢 <50% 🟢 50–75% 🟢 75–95% ⚪ 95–105% 🔴 105–125% 🔴 125–150% 🔴 >150%
Evaluation · · · 19 · · ·
Evaluation — 19 benchmarks (by time change)
Benchmark base PR time memory
evaluation: compile_contact_pairs 25.77 μs 26.62 μs ⚪ 1.03× ⚪ 1.0×
simulation: homogeneous 26.96 ms 27.6 ms ⚪ 1.02× ⚪ 1.0×
simulation: homogeneous, susceptibility trait 34.27 ms 33.47 ms ⚪ 0.98× ⚪ 1.0×
simulation: network, live kernel 3.99 ms 4.06 ms ⚪ 1.02× ⚪ 1.0×
simulation: branching process 1.44 ms 1.46 ms ⚪ 1.01× ⚪ 1.0×
simulation: network, shared kernel 165.24 μs 163.87 μs ⚪ 0.99× ⚪ 1.0×
evaluation: PoissonWeibull pdf, large count 50.41 μs 50.78 μs ⚪ 1.01× ⚪ 1.0×
simulation: branching process, interventions 16.36 μs 16.46 μs ⚪ 1.01× ⚪ 1.0×
evaluation: chain size loglikelihood 1.95 μs 1.96 μs ⚪ 1.01× —
evaluation: PoissonLognormal pdf, large count 37.86 μs 37.98 μs ⚪ 1.0× ⚪ 1.0×
simulation: homogeneous SI, max_time 18.1 ms 18.15 ms ⚪ 1.0× ⚪ 1.0×
simulation: households 1.03 ms 1.03 ms ⚪ 1.0× ⚪ 1.0×
evaluation: pairwise_surv_loglik 24.24 μs 24.28 μs ⚪ 1.0× ⚪ 1.0×
evaluation: PoissonLognormal pdf 36.62 μs 36.69 μs ⚪ 1.0× ⚪ 1.0×
simulation: network, live kernel with policy 4.38 ms 4.37 ms ⚪ 1.0× ⚪ 1.0×
evaluation: PoissonWeibull pdf 51.47 μs 51.43 μs ⚪ 1.0× ⚪ 1.0×
simulation: branching process, HeldCapacity with DeferRefused 1.34 s 1.33 s ⚪ 1.0× ⚪ 1.0×
evaluation: ChainSizes loglikelihood 460.0 ns 460.0 ns ⚪ 1.0× —
evaluation: extinction_probability 891.0 ns 891.0 ns ⚪ 1.0× ⚪ 1.0×
AD gradients — 0 benchmarks (by time change)

none

@codecov

codecov Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.80%. Comparing base (301e2c0) to head (2094383).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1271   +/-   ##
=======================================
  Coverage   97.80%   97.80%           
=======================================
  Files         104      104           
  Lines       11906    11906           
=======================================
  Hits        11645    11645           
  Misses        261      261           
Flag Coverage Δ
epibranch-ad 29.21% <ø> (ø)
epibranch-analytical 40.22% <ø> (ø)
epibranch-engine 52.17% <ø> (ø)
epibranch-inference 43.98% <ø> (ø)
epibranch-interventions 54.42% <ø> (ø)
epibranch-population 53.93% <ø> (ø)
epihouseholds 96.94% <ø> (ø)
epinetwork 95.40% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Co-authored-by: sbfnk <sebastian.funk@lshtm.ac.uk>
@sbfnk-bot

Copy link
Copy Markdown
Collaborator Author

The allocation check now compares copies of the complete state. The previous comparison with a partial deep copy required a twofold reduction and failed on Julia 1.10.

The count-simulation and quality checks passed. The remaining issue work is outstanding.

@sbfnk-bot
sbfnk-bot marked this pull request as ready for review November 27, 2026 16:08
@sbfnk-bot
sbfnk-bot requested a review from sbfnk as a code owner November 27, 2026 16:08

This branch has not been deployed

No deployments
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.

1 participant