Skip to content

Paralellise update gamestate & modifiers#741

Draft
wvpm wants to merge 3 commits into
minimise_allocations_modifiersumfrom
paralellise_update_gamestate
Draft

Paralellise update gamestate & modifiers#741
wvpm wants to merge 3 commits into
minimise_allocations_modifiersumfrom
paralellise_update_gamestate

Conversation

@wvpm
Copy link
Copy Markdown
Contributor

@wvpm wvpm commented May 19, 2026

Stacked on top of #739

Note updating adjecencies inside the country is commented out.
This really should've never been placed there as recalculating it is expensive and can't be multithreaded easily.
Also the outcome rarely changes. It can only change when provinces change owner or our capital changes province.

@wvpm wvpm changed the title Paralellise update gamestate Paralellise update gamestate & modifiers May 19, 2026
@wvpm wvpm changed the base branch from master to minimise_allocations_modifiersum May 19, 2026 10:59
@wvpm wvpm force-pushed the paralellise_update_gamestate branch from 05a9419 to 45a7c59 Compare May 19, 2026 11:00
@wvpm wvpm force-pushed the minimise_allocations_modifiersum branch 3 times, most recently from 44c0e3b to 18d03f0 Compare May 19, 2026 13:39
break;
case work_t::COUNTRY_TICK_BEFORE_MAP:
for (CountryInstance& country : work_bundle.countries_chunk) {
country.country_tick_before_map(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't this call manage_national_stockpile which ultimately can call add_buy_up_to_order (for example), which is thread safe, but will make the order of the contents of buy_up_to_orders relative on the speed at which the threads in the pool finish (and their number), meaning that the order in which they are resolved in GoodMarket::execute_orders will vary based on timing, meaning that deterministic lockstep will not hold for multiplayer?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The market doesn't care about ordering.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, fascinating. I assumed that you were trying to replicate the v2 economy, where items are drained from the market in order (specifically in rank order) and nations later in the order simply can't get anything. Doing equal division is also what version 1.0 of PA did, and for the same reasons (it makes it possible to parallelize the economy). Since this was the one big difference between the PA economy and the V2 economy in 1.0, I imagine that your economy system will behave a lot like the 1.0 PA economy. So be warned that this creates some substantial differences in gameplay.

@wvpm wvpm force-pushed the paralellise_update_gamestate branch from 45a7c59 to 1fac069 Compare May 19, 2026 22:09
@wvpm wvpm force-pushed the minimise_allocations_modifiersum branch 2 times, most recently from e396ef5 to 1e3a0c2 Compare May 20, 2026 12:34
@wvpm wvpm force-pushed the paralellise_update_gamestate branch from 1fac069 to 8d985e8 Compare May 20, 2026 14:43
@wvpm wvpm force-pushed the minimise_allocations_modifiersum branch from 1e3a0c2 to fb5cc3e Compare May 20, 2026 16:23
@wvpm wvpm force-pushed the minimise_allocations_modifiersum branch from 153f1c7 to 71daf85 Compare May 20, 2026 17:01
@wvpm wvpm force-pushed the paralellise_update_gamestate branch from 8d985e8 to 7b58a30 Compare May 20, 2026 17:21
@wvpm wvpm force-pushed the minimise_allocations_modifiersum branch from 71daf85 to 2b3344b Compare May 20, 2026 17:22
@wvpm wvpm mentioned this pull request May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants