Skip to content

fix: cache vehicle cargo recharge targets#8521

Draft
scarf005 wants to merge 2 commits intocataclysmbn:mainfrom
scarf005:fix/craft-lag-regression
Draft

fix: cache vehicle cargo recharge targets#8521
scarf005 wants to merge 2 commits intocataclysmbn:mainfrom
scarf005:fix/craft-lag-regression

Conversation

@scarf005
Copy link
Copy Markdown
Member

@scarf005 scarf005 commented Apr 15, 2026

Purpose of change (The Why)

Vehicle recharge processing was rescanning cargo contents every turn in item-heavy vehicles, and solar-equipped battery buses were also paying repeated battery-part scans in vehicle power paths. Together they made crafting, reading, and nearby vehicle turns stutter again around large mobile bases.

Likely BN regression sources:

  • #8252 feat!: Map Data Overhaul; dynamic reality bubble, chunk loader, multi-dimension, and more
  • #8439 fix: activity bubble resize works w/ crafting

Describe the solution (The How)

  • cache vehicle cargo recharge candidates behind dirty invalidation instead of rescanning all cargo every tick
  • keep a dedicated battery part index and replace multimap-based battery balancing with percentage buckets in charge/discharge paths
  • add regression benchmarks for cargo-heavy crafting, cargo recharge, and solar+battery vehicle power scenarios

Testing

  • cmake --build --preset linux-full --target cata_test-tiles
  • ./out/build/linux-full/tests/cata_test-tiles "[vehicle][power]"
  • ./out/build/linux-full/tests/cata_test-tiles "[grids][vehicle]"
  • ./out/build/linux-full/tests/cata_test-tiles "[benchmark][vehicle]" --benchmark-samples 1 --benchmark-resamples 0
Scenario Before After Faster
process_items with recharge station and 8196 cargo items 412.318 us 6.401 us 64.4x
vehicle idle with 64 solar panels and 512 storage batteries 166.974 us 115.568 us 1.44x
vehicle solar backfill with 64 panels and 512 storage batteries 157.827 us 124.385 us 1.27x

Additional context

Reproduction reports:

Checklist

Mandatory

PR opened by gpt-5.4 high on opencode

Assisted-by: openai/gpt-5.4 on opencode
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
@github-actions github-actions bot added src changes related to source code. tests changes related to tests labels Apr 15, 2026
Assisted-by: openai/gpt-5.4 on opencode
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

src changes related to source code. tests changes related to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant