jwoolley / simpleton-mod

A custom character mod for Slay the Spire.
https://steamcommunity.com/sharedfiles/filedetails/?id=1717515299
1 stars 0 forks source link

Performance Problems - saving custom pool card a lot, and stopping the game for a while because of it #3

Closed Clauvin closed 5 years ago

Clauvin commented 5 years ago

What happened: The game stopped for more or less 15 seconds each time I entered or left any room.

What exactly happened: Played a Custom Game, using modifiers to have a card pool of 10+ characters (3 base game + Tenno, Marisa, The Florist, Hayseed and others). Was using The Florist and every time I would enter in a room...

16:11:36.377 INFO thesimpleton.TheSimpletonMod> CardPoolCustomSavable::registerSaveId
16:11:36.385 INFO thesimpleton.TheSimpletonMod> CardPoolCustomSavable::registerSaveId registering customSaveKey: TheSimpletonModCardPoolCustomSavable
16:11:36.394 INFO thesimpleton.TheSimpletonMod> CardPoolCustomSavable.onSave :: called
16:11:36.402 INFO thesimpleton.TheSimpletonMod> CardPoolCustomSavable.onSave :: Saving card pool. Cards:
16:11:36.410 INFO thesimpleton.TheSimpletonMod> 0) Warcry [cardId: Warcry]
16:11:36.418 INFO thesimpleton.TheSimpletonMod> 1) Slingshot [cardId: StuffTheSpire:Slingshot]
16:11:36.426 INFO thesimpleton.TheSimpletonMod> 2) Rock Throw [cardId: StuffTheSpire:RockThrow]
16:11:36.426 INFO thesimpleton.TheSimpletonMod> 3) Fear [cardId: jedi:fear]
... (this and the other elipsis symbolizing all the missing log lines).
16:11:39.030 INFO thesimpleton.TheSimpletonMod> 324) Tweet [cardId: beaked:Tweet]
16:11:39.038 INFO thesimpleton.TheSimpletonMod> 325) Resilience [cardId: beaked:Resilience]
16:11:39.046 INFO thesimpleton.TheSimpletonMod> 326) Cower [cardId: beaked:Cower]
16:11:39.054 INFO thesimpleton.TheSimpletonMod> 327) Survival Instinct [cardId: beaked:SurvivalInstinct]
16:11:39.062 INFO thesimpleton.TheSimpletonMod> 328) Conserve [cardId: Fiend:FiendConserve]
16:11:39.069 INFO thesimpleton.TheSimpletonMod> 329) Ram [cardId: Fiend:FiendRam]
...
16:11:48.559 INFO thesimpleton.TheSimpletonMod> 1427) Purple Orb [cardId: Purpleorb]
16:11:48.567 INFO thesimpleton.TheSimpletonMod> 1428) Trickster [cardId: Trickster]
16:11:48.575 INFO thesimpleton.TheSimpletonMod> 1429) Devil Star-L [cardId: DevilstarL]
16:11:48.584 INFO thesimpleton.TheSimpletonMod> getSeasonalCropCards called: 
16:11:48.593 INFO MyAct> Saving wentToTheFactory boolean: false
16:11:48.601 INFO saveAndContinue.SaveFile> Next Room: com.megacrit.cardcrawl.rooms.MonsterRoomElite
16:11:48.610 INFO ww_relics.WW_Relics_Mod> Saving World Warriors Relics data from

Why this was a problem: If it happened once, fine, but it was happening twice for each room, so in an act of 15 rooms traveled, with more or less 30 seconds per room with the game paused...

...this meant a total of 7 minutes and 30 seconds waiting for each 15 rooms. :/

The character really needs to save the whole card pool? And every time a room is entered/left behind?

jwoolley commented 5 years ago

Thanks for logging these, I'll see if I can get to the bottom of them.

The game in fact already saves the card pool and the rest of the game state after every room—this code is triggering off of that save. That code can probably be optimized to only include Hayseed cards, though.

Can you tell me how large your card pool actually was at the time of the trace?

Clauvin commented 5 years ago

The game in fact already saves the card pool and the rest of the game state after every room—this code is triggering off of that save. That code can probably be optimized to only include Hayseed cards, though.

Hm... then maybe the problem is less the extra save and more all the extra lines printed thanks to that save? Prints tend to slow down programs a bit, and with so many called...

Can you tell me how large your card pool actually was at the time of the trace?

Of course, 1430 cards.

jwoolley commented 5 years ago

Ok, that's good—I wanted to make sure my save code wasn't double-counting cards (which is something that happened before).

I had the same thought about logging and I think you may be right. Fortunately removing that is an easy fix. I'll make that change and push it up soon.

Clauvin commented 5 years ago

My counting was based in the log number at the end of the save, let me check if there's any double-counting.

It's not double-counting!

jwoolley commented 5 years ago

This should (hopefully) be resolved with https://github.com/jwoolley/simpleton-mod/commit/732059c39869e8a25c734bdf4a789fc3795b93ae.

jwoolley commented 5 years ago

Fixed with the referenced commit.