ID:136038
 
The BYOND engine has a horrible way of transferring net data which causes lots of lag. Please, improve the net code.
It is going to be fixed up soon enough, and this has been requested many times before.
The BYOND engine has a horrible way of transferring net data which causes lots of lag. Please, improve the net code.

There are things you could to to improve the lag on your game depending on where the bottleneck is. Here's some possibilities.

Lots of Resources - If you have lots of icons, sounds, and music especially large ones it will bog the game down each time someone joins and begins downloading all the stuff. If you use icon arithmatic you're generating new icons which players must download even if all you did was rotate or shift and image. To reduce this problem use less resources or make them smaller in size and avoid using too much icon arithmatic or cache the images so the players only have to download the edited icons once.

Lots of Data - If BYOND has to transfer more data it will get laggier so you should reduce the number of variables you have on common objects like standard turfs or mobs. You can do this by storing multiple flags in on variable using bitwise operations. Recycle variables if you can.

Psuedo Lag - If your game is poorly programmed it will run slow on the server side. This is not lag but it will look like it to your players. To fix this avoid having too much running at once(ie: Don't use a loop for every mob to have it check for players in view and heal itself). The solution to this problem is to just design your game in such a way that it's optimally effecient. You can use the SwapMaps library to only have maps loaded that are in use and have monsters activated by the player movement so they aren't constantly wasting clock cycles only to do nothing.

BYOND isn't poorly programmed and I'm quite sure it's sending data in a very effecient way but BYOND doesn't have the advantage of having a set purpose so it can't use cheap hacks like most games to get that extra bit of speed. So stop whining and help yourself by learning how to make your game more effecient.
In response to Theodis
Theodis wrote:
Lots of Data - If BYOND has to transfer more data it will get laggier so you should reduce the number of variables you have on common objects like standard turfs or mobs. You can do this by storing multiple flags in on variable using bitwise operations. Recycle variables if you can.

Aww man, now I know Kades will be ultra-laggy. So many variables... I guess I'll just have to make monsters more meaningful and less abundant.
In response to Foomer
You could always just find someone with a fiber optic cable and multi processor machine to host Kades for you. :P
In response to Jon88
I'd be lucky to find someone with a 56k willing to host it.
In response to Foomer
Now I'm all paranoid about my variable usage... :o/
In response to Foomer
I always have been. Unfortunatly I still give /mob loads of vars :I
In response to Theodis
Theodis wrote:
You can do this by storing multiple flags in on variable using bitwise operations. Recycle variables if you can.

Personally I'd do all other things possible before resorting to either of these. Both tend to result in bugs or architectural problems; recycling variables especially so.

If I just couldn't get the lag down in other ways I might consider doing bitwise stuff but I would put it all behind accessors so that the main code never had to deal with it. I would never ever recycle instance variables.

In addition to the font stuff you mention, people shouldn't overlook high-level architecture decisions. For example, make combat round-based with delays, to slow down how much is happening. Consider having smaller number of NPCs that are more interesting, including monsters.

In thinking about doing an RPG, I'm considering having an "output regulator" object that all graphic and text output goes through. If too much stuff is happening in one area it would space less important things out or skip them. For example if an awful lot of stuff is being sent out, putting a 1 second delay on chat messages won't impact players but might help reduce lag.

Also a game event loop is critical. If the CPU is bogging down, slow things down by a tick until it recovers. Etc.
In response to Deadron
Deadron wrote:
Theodis wrote:
You can do this by storing multiple flags in on variable using bitwise operations. Recycle variables if you can.

Personally I'd do all other things possible before resorting to either of these. Both tend to result in bugs or architectural problems; recycling variables especially so.

Come to think of it, I'm not sure the number of variables on objects matters at all. BYOND is not syncing data between clients; that's all covered on the server. The client is sending in info and the server is telling the client what to display and what sounds to play. The number of variables an object has should be irrelevant to the bandwidth.

I might be wrong about that, but I don't currently believe it's an issue.

On the other hand, using the mouse functions for lots of stuff is an issue, since then mouse movements suck up bandwidth.
In response to Foomer
Foomer wrote:
I'd be lucky to find someone with a 56k willing to host it.

I'd be more than willing to host, I am currently on a 56k DialUp, but within the next few days I am transfering over to a 600kbps line.

Just ask me sometime if you need a host and I will comply, you did me a favour for the site I had up, with the imaging and all... So it would only be fair to return the favour, as your job was excellent.

--Lee
In response to Deadron
Bandwidth isn't always the only cause of lag, though...

I would think that in the case of a host server being on a rather RAM strained computer would also cause lag due to processing times... And a huge number of variables and processes being, well, processed can bog down the server itself, independant of bandwidth... Which in turn, causes slowdown on the clients (and the server, in this case... which isn't the case with bandwidth lag)

So in that respect, having a large number of variables to process can lead to lag... Although, it would certainly take an awful lot to make it a noticeable effect, but it is definitely possible...
In response to SuperSaiyanGokuX
Loops are even worse. Play Exadv1's Space Station 13 to see an example of how looping code can bring a server down to a crawl.
In response to Jon88
I saw this post coming the moment lags on infinite loops came up =]

What I would really like to see is the ability to produce a persistent connection between 2 'servers' that way I could have a client program for SS13 that handles a pretty interface and a server program that doesn't have to handle graphics.
In response to Deadron
Come to think of it, I'm not sure the number of variables on objects matters at all. BYOND is not syncing data between clients; that's all covered on the server. The client is sending in info and the server is telling the client what to display and what sounds to play. The number of variables an object has should be irrelevant to the bandwidth.

Yeah I started to think of this shortly after posting during work but by the time I got home the post already moved off the page so I didn't bother replying. Though I'm not sure how the data is handled either it would make sense that it doesn't need to send most of it only data on the verbs, visual display, sound, and statpanel information.
In response to Deadron
Even if its not generating constant lag, there would be a differnce when creating new objects, which some games do almost constantly.
In response to Theodis
Lots of Data - If BYOND has to transfer more data it will get laggier so you should reduce the number of variables you have on common objects like standard turfs or mobs. You can do this by storing multiple flags in on variable using bitwise operations. Recycle variables if you can.

The number of variables doesn't affect anything. The client doesn't get to see any soft-coded variables belonging to objects. All of that remains server side. Also, hard-coded variables are only downloaded as needed -- x, y, z, pixel_x, pixel_y, icon, icon_state, invisibility, etc. If they contain default values, they aren't transmitted to the client.
In response to SuperSaiyanGokuX
So in that respect, having a large number of variables to process can lead to lag... Although, it would certainly take an awful lot to make it a noticeable effect, but it is definitely possible...

Maximum size of a typical BYOND numeric variable: 8 bytes.

"Awful lot" is an understatement. ;-)
In response to DarkView
DarkView wrote:
Even if its not generating constant lag, there would be a differnce when creating new objects, which some games do almost constantly.

Actually, even then, BYOND has a lot of intelligence. Creating new objects is a very simple operation, because objects only track variables that are not equal to the default for the object template. For example, say I have a mob type, /mob/monster.

There are three /mob/monsters across the map. The /mob/monster type has the variables 'HP', 'Max_HP', 'accuracy', 'exp', and 'speed'.

monster template's variables:
icon = 'monster.dmi'
icon_state = ""
x = 0
y = 0
z = 0
HP = 50
Max_HP = 50
accuracy = 25
exp = 40
speed = 100

monster #1's variables:
x = 124
y = 53
z = 2

monster #2's variables:
x = 24
y = 46
z = 2
HP = 42.7
speed = 90

monster #3's variables:
x = 43
y = 54
z = 3
HP = 12.334
icon_state = "hurt"


The real lag comes from deleting objects, which has to call the plumber to delete all of the clogged references from just about every object in the world.
In response to Spuzzum
Spuzzum wrote:
The real lag comes from deleting objects, which has to call the plumber to delete all of the clogged references from just about every object in the world.

You can improve this situation considerably by removing it from your lists yourself and then manually deleting the object.
Page: 1 2