Trigger Lag

  • Gahan
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
9 months 5 days ago #6981 by Gahan
Trigger Lag was created by Gahan
Just a question. I develop on a mud with a very active playerbase. We have a ton of perks like storage lockers and weightless containers and such. We've come to realize that dg_triggers are very laggy. If you have a character with more than a few hundred pieces of gear in a storage locker or sitting in their inventory, they actually produce lag when they do anything associated with saving/quitting/storage locker interaction... basically anytime all these objects with triggers get saved to a plrobjs file or storage locker file or house file for that matter. Any thoughts or suggestions about finding new routines to handle triggers when saving? Like perhaps handling object saving to be handled on a different pthread or something? I'm kind of at a loss how to not let this get worse without restricting characters, which I don't want to do... the MUDs player base is loyal and regularly donating to keep things going. Any thoughts at all?
The following user(s) said Thank You: zusuk

Please Log in or Create an account to join the conversation.

  • zusuk
  • zusuk's Avatar
  • Offline
  • Gold Boarder
  • Gold Boarder
  • LuminariMUD Developer
More
9 months 5 days ago #6983 by zusuk
Replied by zusuk on topic Trigger Lag
I have not noticed any issues with objects with lots of triggers causing lag in saving... it could be the issue lies elsewhere?

Have you tried running your MUD under valgrind or another memory debugger to see if you got some sort of memory leak?

How does your saving function for your storage lockers compare to other object-saving functions such as rent or house?

Really kind of just stabbing in the dark without any code to look at :)

Website
www.luminariMUD.com

Main Game Port
luminariMUD.com:4100

Please Log in or Create an account to join the conversation.

  • zusuk
  • zusuk's Avatar
  • Offline
  • Gold Boarder
  • Gold Boarder
  • LuminariMUD Developer
More
9 months 5 days ago #6985 by zusuk
Replied by zusuk on topic Trigger Lag
So I re-read and took note that you said a few hundred items with a script.. I only tested it with 99 scripted objects on my character.

Tested it with 198 - no issue.
297 - noticing a bit of lag
396 - like 3 secondish lag on our server
495 - like 5 secondish lag

Yeah so this definitely needs addressing if you see your players with tons of scripted objects. I put it in our in-game bug list to look at as soon as possible, but hopefully we can get one of the specialists like Thomas to give some feedback on this.

Regards,
Mosheh (Zusuk)

Website
www.luminariMUD.com

Main Game Port
luminariMUD.com:4100

Please Log in or Create an account to join the conversation.

  • Gahan
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
9 months 5 days ago #6986 by Gahan
Replied by Gahan on topic Trigger Lag
Yeah its honestly not uncommon for anyone on our mud to have ATLEAST 100 items on them with scripts attached to them. Its definitely a problem when you have several players online at the same, especially high level ones with the better gear. Things can really get slowed down. When you get up around the 1000 item mark it goes up to 7 seconds. My real test was loading 10,000 objects on my character without triggers no visible lag, loaded 10,000 objects with triggers on them and there was about a 15-20 second lag, each save, each interaction with locker. lol.

Please Log in or Create an account to join the conversation.

  • zusuk
  • zusuk's Avatar
  • Offline
  • Gold Boarder
  • Gold Boarder
  • LuminariMUD Developer
More
9 months 5 days ago #6987 by zusuk
Replied by zusuk on topic Trigger Lag
Yeah that is clearly a critical issue on your MUD, I wonder if saving to a database would be faster or slower. Hoping to look at this next week if we do not get someone else to address this issue.

Website
www.luminariMUD.com

Main Game Port
luminariMUD.com:4100

Please Log in or Create an account to join the conversation.

  • Gahan
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
9 months 5 days ago #6988 by Gahan
Replied by Gahan on topic Trigger Lag
Yeah including myself, I have one or two other people looking into the issue as well at our codebase to see if we can come up with some kind of fix, still nothing yet. I'd love to hear any feedback or revelations you or anyone in the community finds that we could work together to make triggers operate a little bit more efficiently. I'll post any findings here.

Please Log in or Create an account to join the conversation.

  • Gahan
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
9 months 5 days ago #6990 by Gahan
Replied by Gahan on topic Trigger Lag
So I was able to narrow the lag down to two functions in the code (which are called both in extract_obj and free_obj) for whatever reason.

The two functions can be found in dg_handler.c extract_script and free_proto_script. Both of these functions are almost identical. At either rate, I commented out both of these calls, and instantly lag is gone. However, this is obviously not a solution and will create wildly out of control memory leaks especially when dealing with this volume of items. Anyways, I thought I'd share my findings thus far here.

Please Log in or Create an account to join the conversation.

  • Gahan
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
9 months 4 days ago #6992 by Gahan
Replied by Gahan on topic Trigger Lag
Found the issue: In dg_handler.c in the extract_script and free_proto_script the follow code resides in both:

#if 1 /* debugging */
{
struct char_data *i = character_list;
struct obj_data *j = object_list;
room_rnum k;
if (sc) {
for ( ; i ; i = i->next)
assert(sc != SCRIPT(i));
for ( ; j ; j = j->next)
assert(sc != SCRIPT(j));
for (k = 0; k < top_of_world; k++)
assert(sc != SCRIPT(&world[k]));
}
}
#endif

#if 1 will always return as true. Funny why compiler doesn't pick that up. This should be changed to allow for debugging mode, or not. This amount of assertions really slow things down when dealing with a for loop with several thousand objects with triggers.

Just thought I'd point this out. I fixed this issue on my MUD and everything works much better now. Its still not perfect, and a more efficient routine to handle objects is a must.
The following user(s) said Thank You: zusuk

Please Log in or Create an account to join the conversation.

Time to create page: 2.168 seconds