Monster Lag

04/01/2019 23:45 littlechris95#1
Hello, everyone.

I wonder what can cause LAG while using the Scatter skill while the players are hunting. It's as if the monsters die one by one. Is there a solution to this?

Thanks :handsdown:
04/02/2019 01:48 Spirited#2
Quote:
Originally Posted by littlechris95 View Post
Hello, everyone.

I wonder what can cause LAG while using the Scatter skill while the players are hunting. It's as if the monsters die one by one. Is there a solution to this?

Thanks :handsdown:
I would start by using a few C# stopwatches or the performance monitor in Visual Studio. Debug the server and see how long it takes for scatter. Then, see where it's spending the most time and optimize that, or let us know and we can maybe give you a few pointers.
04/02/2019 07:12 littlechris95#3
I did some tests and I took advantage and made a video so that you can understand better.

Video:

[Only registered and activated users can see links. Click Here To Register...]

Image:
[Only registered and activated users can see links. Click Here To Register...]
04/04/2019 23:30 littlechris95#4
anyone?
04/05/2019 03:20 Spirited#5
Quote:
Originally Posted by littlechris95 View Post
anyone?
Quote:
Originally Posted by Spirited View Post
I would start by using a few C# stopwatches or the performance monitor in Visual Studio. Debug the server and see how long it takes for scatter. Then, see where it's spending the most time and optimize that, or let us know and we can maybe give you a few pointers.
As I said... debug the server using stopwatches or the performance monitor and see what's taking the most time. What do you expect us to do? Look into a crystal ball and tell you why your code is slow? We don't have the code, you do. You need to step through your attack method and see what is causing the issue.
04/05/2019 11:01 Super Aids#6
I'm going to make a wild guess and say that you're locking up your main thread whenever you have to perform an action towards multiple entities.

Your "screen" implementation on the server is probably broken.
04/05/2019 22:54 littlechris95#7
Quote:
Originally Posted by Super Aids View Post
I'm going to make a wild guess and say that you're locking up your main thread whenever you have to perform an action towards multiple entities.

Your "screen" implementation on the server is probably broken.
If I give you the project I use as a basis, can you tell me what the problem is? Why I've reviewed this source, tested many things and so far no success...

I can pay someone to fix this for me. Anyone willing? Who could provide this service?
04/08/2019 08:25 KraHen#8
Just get any profiler really and use it to identify the bottleneck in your code. It was already mentioned - it's probably blocking, so either it's doing far too much stuff (most likely) or the operation is really expensive and should be either chopped up or sideloaded to a worker or something. There's multiple approaches to this and you need to choose what to use that fits your source.

TL;DR; - Profile
04/08/2019 08:40 Spirited#9
Quote:
Originally Posted by KraHen View Post
Just get any profiler really and use it to identify the bottleneck in your code. It was already mentioned - it's probably blocking, so either it's doing far too much stuff (most likely) or the operation is really expensive and should be either chopped up or sideloaded to a worker or something. There's multiple approaches to this and you need to choose what to use that fits your source.

TL;DR; - Profile
I know what the problem is, it's really obvious if you watch the video. I'm just trying to help him get there. Just stepping through the code that does scatter is enough to figure it out. I kinda wish he'd put more effort into this, because right now my guess is that he hasn't even read the function that does this. If he could suggest a line or bit of the function he thinks it is, then that'd be a good start.
04/08/2019 13:08 Super Aids#10
Quote:
Originally Posted by Spirited View Post
I know what the problem is, it's really obvious if you watch the video. I'm just trying to help him get there. Just stepping through the code that does scatter is enough to figure it out. I kinda wish he'd put more effort into this, because right now my guess is that he hasn't even read the function that does this. If he could suggest a line or bit of the function he thinks it is, then that'd be a good start.
I did help him in private messages though so I guess that's why he hasn't answered.
04/08/2019 17:50 littlechris95#11
Quote:
Originally Posted by Super Aids View Post
I did help him in private messages though so I guess that's why he hasn't answered.
I have followed you as tips that you gave me. I compared the codes I'm dealing with, but I have not seen so much change like that. I still have this lag. I took some photos of the codes I'm using:

Codes

* I believe I'm on the right track, but still a bit confused.
04/08/2019 17:59 Super Aids#12
Quote:
Originally Posted by littlechris95 View Post
I have followed you as tips that you gave me. I compared the codes I'm dealing with, but I have not seen so much change like that. I still have this lag. I took some photos of the codes I'm using:

Codes

* I believe I'm on the right track, but still a bit confused.
In Image 2 get rid of the "Spells.ToArray()" and just loop over Spells.Values if anything.

Also it doesn't matter if you pass the Spells as a concurrentqueue because it's never used in threading.

In fact it looks like you tried to solve it in the wrong location.

In Image 3 I have no idea what you're trying to solve but the whole making a big array thing and sending that in chunks doesn't work the way you think.

AFAIK you're supposed to have a limit of targets anyway so it's pointless.

Cba to explain why the rest of the images doesn't work but the whole thing looks really terrible.
04/08/2019 21:25 KraHen#13
Did you profile the code to identify the bottleneck? If you can't measure if, you generally can't improve it either. Especially since you don't know the root cause.
04/11/2019 23:16 littlechris95#14
I have worked hard to solve, but so far unsuccessful. I looked at other projects to compare some things and they are quite similar ... I honestly do not know what else might be causing this :/
04/12/2019 04:19 Spirited#15
Quote:
Originally Posted by littlechris95 View Post
I have worked hard to solve, but so far unsuccessful. I looked at other projects to compare some things and they are quite similar ... I honestly do not know what else might be causing this :/
Clue: Look for thread sleeps.