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

Core: change Region caching to on_change from on-miss-strategy #2366

Merged
merged 12 commits into from
Oct 29, 2023

Conversation

Berserker66
Copy link
Member

What is this fixing or adding?

should make several parts of AP faster, but have not gotten around to benchmarking yet.
Difference may be negligle, possibly even worse, for small single-world gens.

How was this tested?

unittests and some small gens. SDV is failing unittests currently and I have no yet checked why.

@ThePhar ThePhar added is: refactor/cleanup Improvements to code/output readability or organizization. affects: core Issues/PRs that touch core and may need additional validation. is: enhancement Issues requesting new features or pull requests implementing new features. labels Oct 25, 2023
@Berserker66 Berserker66 changed the title Core: change Region caching to dirty-strategy from on-miss-strategy Core: change Region caching to on_change from on-miss-strategy Oct 26, 2023
@Berserker66
Copy link
Member Author

It's now failing LttP Dungeon and OoT tests, have not figured out why yet, I assume I missed something that is done to one of the variables I wrapped. This should be slower assuming all worlds used the old API perfectly, but faster in reality, though benchmarking still needs to be done with the latest changes.

Berserker66 and others added 3 commits October 27, 2023 03:16
Not sure why is_bunny runs into None regions now, though
should reduce memory footprint at only minor performance change
@Berserker66 Berserker66 marked this pull request as ready for review October 27, 2023 01:38
@Berserker66
Copy link
Member Author

Should be good for testing now. Unittests are passing, it should be faster and more convenient.

@Berserker66
Copy link
Member Author

300 Factorio worlds:
new Region cache: 154 seconds
main: 160 seconds

Probably within noise margin. But it's also a world that already behaved in regards to the old API and this PR prevents "mistakes".

BaseClasses.py Outdated Show resolved Hide resolved
@BootsinSoots
Copy link
Contributor

BootsinSoots commented Oct 27, 2023

Test 1: 3 1-coinsanity DLCQuests because that's what I had in Players

#2366: 65.06 seconds
Main: 68.86

If I still remembered how to do t-tests, this is where I would tell you it's not significantly different. Going test ER games next

(this included full playthrough because I forgot to turn it off)

@BootsinSoots
Copy link
Contributor

Test 2: 10 default SDV template yamls

#2366: 85.2261703000404
Main: 84.28835940011777

Testing with ER turned on next (but not chaos because no)

@black-sliver
Copy link
Member

You gotta roll with set seed (python Generate.py --seed 123456) and ideally turn off spoiler, because that's not fully deterministic and also the variance in cpu clock can skew the result.

@CodeTriangle
Copy link

CodeTriangle commented Oct 27, 2023

I'm the beta world developer for CrossCode. In a test with 1000 random worlds, when run on main, time spent in create_regions would creep up by a factor of about 160 by the end of the generation. With #2366 merged into the local branch, time spent in the function shot down to an average of 0.0027 seconds as opposed to the 0.1376 seconds average when generated on main (these were tested with the same seed).

In short, this makes all the difference for my world.

@BootsinSoots
Copy link
Contributor

You gotta roll with set seed (python Generate.py --seed 123456) and ideally turn off spoiler, because that's not fully deterministic and also the variance in cpu clock can skew the result.

Ah, I thought the point was to test it without determinism. I can change my settings then

@BootsinSoots
Copy link
Contributor

Test 3: 10 SDV Full ER seeds, seed # 123456

main: 115.04147580009885 seconds
2336: 116.55106319999322 seconds

Difference appears to be minimal, as predicted, in small worlds. Will test with 100 worlds next

@kindasneaki
Copy link
Collaborator

Tests for RoR2: seed # 70986686017450515584

100 world:
main: 27.220027624978684
2366: 25.535646124975756

300 world:
main: 170.74974070803728
2366: 156.1382752499776

10 world.
main: 0.7691042909864336
2366: 0.7513600420206785

@black-sliver
Copy link
Member

black-sliver commented Oct 28, 2023

ap-roller with 3 yamls per run and -O, --spoiler 0 shows an improvement of ~5% after 2500 runs execs for soe,v6,spire,subnautica,zillion,timespinner,smz3,sm64ex,sc2wol,sa2b,ror2,rogues_legacy,raft,minecraft,meritous,hk,factorio,dark_souls_3,archipidle,alttp

Update: --spoiler 3 looks very similar so far (that is also 5%) more like 2%

Update2: i see no difference in failure behaviour, so the mentioned games seem to work with the changed code

Update3: with "up to 12 yamls", -O and --spoiler 0 it also looks like 5% so far. Guess any additional scaling would happen at a higher player count, or is on average not the case for the games listed above.

@black-sliver
Copy link
Member

After letting it run for a bit longer, the "up to 12 yamls" ended up not being faster on average. I guess that means it very much depends on the game, and most of the games above are not affected.

@black-sliver
Copy link
Member

At this point, I'm wondering what cythonizing the containers would do

@Berserker66
Copy link
Member Author

At this point, I'm wondering what cythonizing the containers would do

might be worth a shot

Copy link
Member

@black-sliver black-sliver left a comment

Choose a reason for hiding this comment

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

Looks like it's not slower on average.

@black-sliver black-sliver mentioned this pull request Oct 29, 2023
espeon65536 added a commit to espeon65536/Archipelago that referenced this pull request Oct 29, 2023
Eventually we want to remove the full recache and just delete them from the cache directly, but I will save that for after ArchipelagoMW#2366
@Berserker66 Berserker66 merged commit 3e0d1d4 into main Oct 29, 2023
21 checks passed
@Berserker66 Berserker66 deleted the core_new_region_cache branch October 29, 2023 18:47
espeon65536 added a commit to espeon65536/Archipelago that referenced this pull request Oct 29, 2023
Eventually we want to remove the full recache and just delete them from the cache directly, but I will save that for after ArchipelagoMW#2366
FlySniper pushed a commit to FlySniper/Archipelago that referenced this pull request Nov 14, 2023
Jouramie pushed a commit to Jouramie/Archipelago that referenced this pull request Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects: core Issues/PRs that touch core and may need additional validation. is: enhancement Issues requesting new features or pull requests implementing new features. is: refactor/cleanup Improvements to code/output readability or organizization.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants