immortalityidle / immortalityidle.github.io

Immortality Idle Game Repo
32 stars 31 forks source link

lag spikes every few seconds #185

Open jklw10 opened 1 year ago

jklw10 commented 1 year ago

doesn't seem to be a cpu overload since the usage is under 10% for the whole browser. but the console does spout this: image every time said lag spike hits. not sure which is caused by which though.

jklw10 commented 1 year ago

image yep, a major garbage collection looks like the culprit for the lag spike. memory allocation benchmark seems to point to TrainingFollowers.consequence i'll take a gander at it if there's anything fishy looking there. image

jklw10 commented 1 year ago

i can't say there's anything that immediately seems slow, but since the the stact trace does point into the task invocation it's possible that it's making an allocation for each lambda based on the builder's data, so maybe consider making a "trainbuilder" function and calling it instead. again, unsure how JS' internals work and if that would even help there.

Restarting the game seems to have fixed the stutter issue, and to be fair i had it on for 2 days before it was an issue.

slaymaker1907 commented 1 year ago

@jklw10 if it happens again, maybe try using some of the heap profiling tools. It looks like you use Edge and there is an option to take a snapshot and to do a sampling on allocations for major GC collections. The big culprit for stuff like this in what I assume is a generational collector are objects which live a moderate amount of time since they get cleaned up at more expensive GC stages and it obviously happens pretty frequently compared to stuff that lives for minutes+.

image

jklw10 commented 1 year ago

Allocation sampling just instantly crashes everything, also it's brave but both are chromium based and probably have similar tooling. And I can confirm that after leaving it to run for like 3 days it just crashed :) after 1 day it had some hiccups like this one. thought it was not that specific action that cause those hiccups since even after removing the training it had issues, though I didn't all that carefully what all is loaded at all times so it's possible that even actions that aren't in use cause issues.

I can give the save file of my progress but you'd have to still run it un interrupted for 1-2 days to get the hiccups.