Slay the Spire

Slay the Spire

Optimize the Spire
45 Comments
(Gk) Erasels  [author] 6 Feb @ 3:52am 
New update with an optimization from cany0udance! This optimization helps with the lag some of you might experience when opening your run history screen.
glennvtx 6 Jan @ 6:15pm 
THANK YOU.
(Gk) Erasels  [author] 14 Jun, 2024 @ 3:27am 
Hmm, your steps for repdouction make wrong assumptions.
> 4. Add MyCustomRelic to relic array.
This would trigger the doRecieveRelic method via the RelicGetSubscriber in the main mod file. That method would change the -1 to its actual location.
s.Claw 4 Jun, 2024 @ 4:09pm 
Hello, for the Relic patch, I am running into a bug where the hashmap has a stale -1 entry after relics are added to the relic array. I think that the code to check for array size difference needs to come before the first call to relicLocs.get(key).

int size = __instance.relics.size();
if (size != RelicOptimizationPatches.relicsSize) {
RelicOptimizationPatches.relicsSize = size;
RelicOptimizationPatches.relicLocs.values().removeIf(val -> (val.intValue() == -1));
}


The issue can occur like so:

1. Start with empty relics array
2. Call getRelic("MyCustomRelic")
3. Hashmap entry added for "MyCustomRelic" -> Integer(-1)
4. Add MyCustomRelic to relic array.
5. Call getRelic("MyCustomRelic")
6. Hashmap returns Integer(-1), so it enters into i != null logic.
7. relicSize check sees that relics.size() != 0, so it removes all -1
8. However since it has already found i = Interger(-1), it skips to the rIterSkipped case and returns null.
裂开logy 18 May, 2024 @ 8:16am 
Enable/disable this mode is the only thing I change. Could it conflict with any of "Relic filter mod", "Colored Map", "Shop Mod", "TrulyRandomMOd" or "BaseMod"?
(Gk) Erasels  [author] 18 May, 2024 @ 6:46am 
I don't see a way for this mod to cause that.
裂开logy 18 May, 2024 @ 6:05am 
Found a bug associated with retrieving the game after leaving in background for a few minutes. The game gets frozen and GPU hang at 100% usage for around 10 s before returning to normal.
(Gk) Erasels  [author] 13 Jul, 2023 @ 12:44am 
Alchyr released his great RAM Saver mod https://sp.zhabite.com/sharedfiles/filedetails/?id=3002563327
that will help with that for those struggling with missing letters in their text or RAM related crashes.
voov 29 Jun, 2023 @ 1:10am 
兼容,优化尖塔mod
bkerns2 10 Apr, 2023 @ 3:35pm 
Thank you for making this.
catboy princess 4 Feb, 2023 @ 11:43am 
The decompiled code looks like this, which I believe is the issue:


public class YoumuPatch {
@SpirePatch(cls = "com.megacrit.cardcrawl.characters.AbstractPlayer", method = "hasRelic")
public static class hasRelicResurrect {
@SpireInsertPatch(rloc = 0)
public static SpireReturn Insert(AbstractPlayer p, String targetID) {
if (p.name == "Youmu" && (targetID == "Blue Candle" || targetID == "Medical Kit"))
return SpireReturn.Return(Boolean.valueOf(true));
return SpireReturn.Continue();
}
}
}
(Gk) Erasels  [author] 3 Feb, 2023 @ 5:52am 
I have a feeling the relic is chaning its ID so certain base game code thinks it's another relic. That would definitely be a big nono with this mod.
catboy princess 2 Feb, 2023 @ 3:05pm 
in my own investigation, i think the issue is actually with the Youmu mod itself, that does something weird to enable the function of the Half Phantom relic, causing it not to play well with the new implementation of the relic list
catboy princess 2 Feb, 2023 @ 2:32pm 
I have an interesting incompatibility to report:

This Youmu character mod starts with a relic (Half Phantom) that is supposed to allow curses and statuses to be played. Having the optimization mod installed will disable that aspect of the relic, greatly affecting the character mod's dynamics.

is there any chance you would like to fix this?

in case this helps, there is a localization mod to translate the Youmu mod to English https://sp.zhabite.com/sharedfiles/filedetails/?id=2777818594&searchtext=youmu
虛無_鬼王 19 Jan, 2023 @ 12:36pm 
Thank you so much for everything you have done! Your mod successfully optimized my 76 mods, my game is no longer lagging!
Winter 'Eira 19 Nov, 2022 @ 11:40am 
A huge improvement great mod.
pgames-food 16 Sep, 2021 @ 9:50pm 
ah yep, i like variety :)
https://sp.zhabite.com/sharedfiles/filedetails/?id=2548274926
i can send you the modlist if you like
(Gk) Erasels  [author] 16 Sep, 2021 @ 2:08am 
I'm very glad to hear that, 75 mods sounds like you're really giving it a stresstest.
pgames-food 15 Sep, 2021 @ 10:22pm 
btw i forgot before, but i managed to get this mod working ages ago ok in the end, and even recently had a game with about 75-77 mods :)
(Gk) Erasels  [author] 14 Sep, 2021 @ 11:37pm 
Considering I haven't had a single crash in all my playtesting, I'm gonna go with not this mod's fault unless you can show me a crashlog.

Either way, if it didn't help, that's too bad. Hope you can fix your performance problems.
L0ki 14 Sep, 2021 @ 3:51pm 
I've had some crashes while using this mod that only happened while using this mod and didn't notice any performance improvements either so I've reverted to no no longer using it.
pgames-food 3 Jul, 2021 @ 12:22pm 
ah ok, many thanks for looking though :)

i can always take a few out and add a few new ones in then, its ok - i must have gotten a bit greedy, trying to add all the mods i found lol :)
(Gk) Erasels  [author] 3 Jul, 2021 @ 3:07am 
Sadly I'm of no help in that regard, haven't really interacted with swapfiles before and a quick google search wasn't enlightening.
pgames-food 2 Jul, 2021 @ 6:34pm 
do you know if there any way to get java to load more memory or use a swapfile?
i can load up 23 mods, but when i tried with a lot more, it maxed out my 8GB system ram and crashed. even if the game would take longer to load, it wouldnt be so bad but im wondering why it crashes... if it loads things as it needs them, maybe there is a way to allow java to not run out of memory, but instead to simply need to access the filesystem more often?

(Gk) Erasels  [author] 2 Jul, 2021 @ 1:49am 
Hmm, sorry to say, but it's unlikely. That sounds more like a RAM issue going by what you said.
drewmarc 1 Jul, 2021 @ 7:21pm 
In vanilla, I've come across a bug while playing Discovery, where the cards fail to generate. The discord says it has to do with failing to load the cards for you to discover (and it apparently affects Jack of All Trades, which I haven't picked so far). Do you think this mod will fix this issue?
pgames-food 28 Jun, 2021 @ 10:50am 
hi erasels, this sounds like a good optimisation. im new to slay the spire (and mods) but will add this to save cpu cycles :)

(older versions of rimworld, used to fully scan and refresh the entire modlist, over and over, but they changed and optimised the process there too) :)
NorahC 27 Jun, 2021 @ 8:17pm 
1
(Gk) Erasels  [author] 6 Jun, 2021 @ 10:10pm 
This mod doesn't really touch anything related to resolution or settings in the slightest so I'm not sure how that could be. If you do find out what mod or combination thereof caused it, I'd be happy to know.
Queen Grimlock 6 Jun, 2021 @ 3:12pm 
For some reason the mod seems to have disabled any option for borderless fullscreen other than 3360x2100, which is way bigger than my monitor's actual size. Not sure if this is a weird interaction with another one of my mods, but I felt it was worth mentioning.
Chom 28 May, 2021 @ 2:46am 
For someone like me who runs with so many mods this is a godsend.
scallop 16 May, 2021 @ 3:01pm 
Thanks so much for this, dude! :HatHealth:
some (momi) 27 Apr, 2021 @ 6:05pm 
fan-fucking-tastic mod
旅渚Lastcel 22 Apr, 2021 @ 8:48am 
It works, thank you
(Gk) Erasels  [author] 22 Apr, 2021 @ 7:46am 
It's called Optimize the Spire in the mod selection menu
旅渚Lastcel 22 Apr, 2021 @ 6:58am 
Excuse me, what's the name of this mod in the selection page? I can't find it because I have too many mods in my list
StarrySunbeams 17 Apr, 2021 @ 2:22pm 
Absolutely fantastic. Thank you for this!
Asdercol 17 Apr, 2021 @ 6:35am 
God tier mod, no longer crashing every single time I abandon a run, finish a run or close the game.
(Gk) Erasels  [author] 13 Apr, 2021 @ 1:44pm 
That sounds exactly like something within the scope of this mod, thanks for the write up, I'll take a look at it,
ojb 13 Apr, 2021 @ 1:38pm 
Again, I haven't done much digging myself but I saw this mod earlier in the week and thought about it when digging in the muck of the MasterDeckViewScreen for another project. It might be worth doing a search through your game for any instances of Collections.sort() and examining if this inefficient behavior happens elsewhere.

It might be worth taking a look at and doing some profiling on if you're interested.

[3 / 3]
ojb 13 Apr, 2021 @ 1:38pm 
Now, deck sizes never really get that big in most vanilla games, and are small enough that there's not much performance hit anyway. Though with modded games, games with modifiers (e.g. endless or the daily modifiers that clutter the deck), or other instances of large deck size, this may add up to some actual performance penalties on lower end machines.

The trivial solution would be to cache the results of the sort whenever the sorting button is pressed and store it somewhere instead of resorting every frame.

I haven't personally looked into things like the draw, discard, or exhaust piles, but there's a large chance that they have similar issues to the master deck screen (and they would theoretically be far worse, due to temporary status cards or other modifiers - even in just vanilla play, I've seen these piles reach close to 1000 cards under fortuitous circumstances, which is potentially on the magnitude where constant sorting might start to matter on low end machines).

[2 / 3]
ojb 13 Apr, 2021 @ 1:38pm 
Hey Gk - don't know how useful this information might be for you, but I ran into something that may be in the scope of this project while working on my own mod. MasterDeckViewScreen (which is the screen that shows all your cards when you open the deck), has options to sort your deck by Obtained Order, Type, Alphabetical, etc.

Outside of the default ordering (which doesn't have this problem), if you select any other option it actually (re)performs the sort of all cards once per frame. Some quick googling indicates that Java's Collections.sort() implements the mergesort algorithm in the backend, which doesn't have any speedup when the collection is already sorted. I.e. you're paying the full n log n cost over and over for each frame.

[1 / 3]
Asdercol 12 Apr, 2021 @ 4:15pm 
Yes!
GoatBoy 12 Apr, 2021 @ 2:24pm 
Totally agree with Too Mellow, thank you for this!
Too Mellow 12 Apr, 2021 @ 7:38am 
regardless of how much this does or does not help. anybody trying to help improve a gamers experience is amazing person, thank you for your hard work and hope you find even more successful ways to improve the game :)