#Horrible WebSocket lag in 1.10.x

1 messages · Page 1 of 1 (latest)

molten spear
#

Joining Dungeons with a team, the game lags horribly, horribly bad.

Solo Dungeons and everywhere else is fine.

The lag in Dungeons with a team gets fixed instantly when WebSocket connection is eventually terminated due to any reason.

Workaround was to disable WebSocket entirely by adding -Dskytils.websocketURL=localhost to JVM arguments at which point the mod will try to connect localhost through WS and will get IOException: Connection refused, but that work around no longer works and code modifications are necessary.

willow tundra
#

Imma just hijack this since I can't be bothered to make my own post, the Websocket connects even when joining single player (possibly also servers other than hypixel)

willow tundra
#

@molten spear if you still have the issue, try without chattriggers

glass skiff
#

i also still get lags in dungeons on newest version

willow tundra
glass skiff
#

just unloaded or actually remove it ?

willow tundra
glass skiff
#

ok ill test once with just disabled and then with it fully removed if it still lags

#

ok just disabling already made it not lag

willow tundra
#

you got bettermap?

glass skiff
#

yea

#

want me to throw that out ?

#

ik that volc also uses a websocket i think but i got that disabled

#

also btw this has nothing to do with this thread but maybe u know this, do you use preset paths for icefill solver since its always the same thing there is only a few diffrent patterns or do you actually have some pathfinding algorithm do a new path every time

#

btw without bettermap im not lagging now, idk if this could also be because of reloading chattriggers tho

glass skiff
willow tundra
#

But to answer your questions:

  • it calculates the path cause getting preset is effort
  • It will be straighter if they start using my code (and you enable dungeon sweat mode)
glass skiff
#

ait

#

also idk if you can tell yet but is that bettermap lagging websocket thing fixable ? cus i rly wanna keep bettermap for the leap overlay

willow tundra
glass skiff
#

i mean if there is the slightest chance u make a similar leap overlay where the same classes have the same locations etc then i can finally get rid of bm

willow tundra
#

if you can give me a screenshot of what it looks like I might try it

glass skiff
#

healer is always bottom left which is the most important, rest im not sure but doesnt matter too much as long as its consistent

#

btw i turned off websocket on skytils so i could play with bm& no lags and somehow still freezing

#

does it take some time to apply the change or is it maybe not websocket lagging it ?

willow tundra
willow tundra
#

aka it's only caused by bm I think

glass skiff
willow tundra
#

tho you can confirm by joining a dungeon without Skytils in your mod folder

glass skiff
#

if you make it too small/stacked together then u have to be careful again

willow tundra
#

No guarantee that I'll make it, but if I do I'll try to do it that way

calm hamletBOT
#
Aethor Suggestions
0: Suggestion 2858 ( votes: 117)

@calm hamlet composter timer for the hud, [link](#suggestions message)

1: Suggestion 114 ( votes: 97)

Suggestion: when using a spirit leaps it opens a map and shows where they are like the fast travel on sba, [link](#suggestions message)

2: Suggestion 1015 ( votes: 87)

Gyrokinetic wand area of effect overlay display, [link](#suggestions message)

3: Suggestion 2860 ( votes: 84)

@calm hamlet A ping or a pop-up notifying you when there are 5 visitors in your garden., [link](#suggestions message)

4: Suggestion 2866 ( votes: 83)

@calm hamlet something like the terraria recipe browser mod, where you can star a recipe and it shows your prog, [link](#suggestions message)

5: Suggestion 2870 ( votes: 83)

@calm hamlet This one is weird but maybe implementing a garden specific tracker like
Crops till next crop miles, [link](#suggestions message)

6: Suggestion 2842 ( votes: 80)

@calm hamlet An overlay above the visitors of what they want to have and some UI checklist of the items you nee, [link](#suggestions message)

7: Suggestion 2872 ( votes: 75)

@calm hamlet add voidgloom boss laser timer (timer until laser is done), [link](#suggestions message)

8: Suggestion 2841 ( votes: 64)

@calm hamlet An Overlay that indicates how close you are to leveling up a garden milestone for a crop that chan, [link](#suggestions message)

9: Suggestion 2250 ( votes: 64)

More cat pictures when loading mod 🐱, [link](#suggestions message)

glass skiff
#

<3

willow tundra
#

Wait actually doesn't Skytils already have spirit leap stuff

#

Ah nvm it only allows you to mark people in the menu

glass skiff
#

it has smth for spirit leap that makes it display class letter on the head

molten spear
# willow tundra <@231807520614776832> if you still have the issue, try without chattriggers

The commit 694f9b7 ("fix: change WS coroutine context") didn't fix the issue and disabling connect to skytils websocket in the config didnt get my fps back to normal either so i experimented out with commenting out some code and that seemed to fix the issue.

I also noticed that the code that i commented out were missing the check for if connect to ws was enabled in the config before running, and thats probably why disabling ws didn't fix it either.

I highly suspect this related to the while loops at line 224 of DungeonListener.kt. None of the methods called do any blocking (isNotEmpty(), poll(), sendPacketAsync() all return instantly - check javadoc of poll, I would expect it to block till an element is available, but it just returns null if no element is available, besides, even if it blocked, we are checking isNotEmpty beforehand) and there is no delay() call in the while loop, so i suspect its starving cpu.

molten spear
#

For the leap menu, Skytils's feature shows class, name and a unique color based on class already and can also highlight last wither door opener so it shouldn't be too hard to make the menu do a consistent sorting (hypixel scrambles the order every other run even if no one left and everyone is playing same class) and make the buttons big in a new overlay menu that hides vanilla gui and sends window click to the correct slot on click.

molten spear
# molten spear The commit 694f9b7 ("fix: change WS coroutine context") didn't fix the issue and...

Confirmed the issue with a spark report. 44.98ms spent on DefaultDispatcher thread per a game tick on the Client thread, meaning its competing heavily with the game thread on my CPU. If you have a high core count CPU, it will still unnecessarily stress and block a core on your CPU, but Client Thread, Chunk Batcher threads, Sound Thread etc. can still run on your other cores so you likely won't experience as much lag as me, but since my CPU is only 2 cores, it heavily affects me.

molten spear
# coral summit can you send your report

I don't have the original report's link anymore, but the full report is irrelevant anyway, I am pretty sure this the culprit as i have done more extensive tests and tried different fixes in this subject.

I have made a Pull Request targeting the dev branch with the fix, would appreciate it if you review it:
https://github.com/Skytils/SkytilsMod/pull/501

I am currently using a version with changes in the PR in my mods folder for a few days without any issue but if its still needed I can revert back to the official release and send the full spark report.

GitHub

While loop without a delay starves CPU time in background inside the coroutine's DefaultDispatcher thread, competing with Client thread and causing horrible lag inside dungeons on machines ...

livid haven
#

in reply to https://github.com/Skytils/SkytilsMod/pull/501: (since my github account has been deleted)
using .take() would be more appropriate here (in combination with a blocking queue), if this was using threads. since this is using coroutines, using channels would be better. instead of waiting an arbitrary amount of time, the .receive operation (which is equivalent to .take) will suspend the coroutine until a new message appears in the channel

GitHub

GitHub is where people build software. More than 100 million people use GitHub to discover, fork, and contribute to over 420 million projects.

Kotlin Help
molten spear
# livid haven in reply to https://github.com/Skytils/SkytilsMod/pull/501: (since my github acc...

I have mentioned the take() approach in my PR as well but as you said it would block other coroutines from using the shared OS thread so delay(50) was a simple fix

I didn't know much about channels before and I'm not very profecient in kotlin idioms but I took a look at the link you sent in the docs and it seems very simple to use, I will definitely give it a try in a solution using them and update my PR if i succeed.

Thank you for the recommendation!

coral summit
#

i probably did it wrong

#

i think i got a C+ on my c++ exam so time to go look at whats wrong

#

yep it works when i test it again

coral summit
#

i assume its only this one because i didn't realize concurrentlinkedqueue isnt O(1) size

coral summit
coral summit
#

and see if i used the channels right

coral summit
#

the duo core experience

molten spear
# coral summit the while(true) loop doesn't affect you in the WSClient.kt file right

I'd assume so since looking at it's code receiveDeserialized should likely suspend/block, but I have not tested it since I actually have WS disabled in the config, the while loop in the DungeonListener runs even if WS is disabled in the config so this what led me to experimenting with the code, since it would lag even with WS in config disabled (or the old -Dskytils.websocketURL=localhost workaround).

I will give it a try later with your PR to see if DungeonListener's while loop is fixed and to see if WSClient's while(true) has any impact.

Regarding the isNotEmpty and O(1) situation, while I agree that it's an optimization, this wasn't the main issue, it was the while loop having no delay/suspending/blocking, it would cause lag even if you had no code inside it, like while (true) {}, so whether method called inside there was O(1) had no relation, and the choice of 50ms delay in my PR was just the first number that came to my mind due to MC ticks having 50ms interval, I think even if i added only 1ms delay it would fix the issue.

molten spear
# coral summit the while(true) loop doesn't affect you in the WSClient.kt file right

While loop in WSClient doesn't cause any issues.

Tested the PR, seems to fix the CPU usage issue but very short time after dungeon start, I got this error:
https://paste.mozilla.org/mm386vZW

And then randomly when going to a new dungeon right after ending one, got spammed with the message:

§c§lSkytils (1.10.6) §8» §cFailed to send room data to server. true

The message repeated like 30 times whenever it happened and then it would go away.

Otherwise works fine though, the found secrets show correctly.

sterile frigate
#

what

coral summit
sterile frigate
#

try using launch instead of async

#

i'm pretty sure cancelling a deferred will wait for it to finish executing

#

which may still have queued channel reads

#

and then also probably cancel the job before closing/cancelling the channel

willow tundra
molten spear
glass spruce
#

Skytils (1.10.7-RC1) » Failed to send room data to server. true (21)

coral summit
#

not sure how that happens i cant lie

sterile frigate
#

most well tested lily feature

coral summit
sterile frigate
#

like a physics sim?

coral summit
sterile frigate
#

bro what

#

meanwhile i'm over here fighting rendering math

#

i have no clue how any of this works

coral summit
sterile frigate
#

yeah