redesign of reminder system #85


  • New
  • Enhancment
Open
  • _ForgeUser12884998 created this issue Aug 18, 2015

    What is the enhancement in mind? How should it look and feel?

    I'm not sure if the comments are read, so I thought I would post my short essay here too.

    could you please redesign the reminder system to reduce the lag it causes?

    Please provide any additional information below.

    in your current system, lets say we have a good sized server of 100 players. none of them have voted recently. the server uses 4 different server lists, each of which take up a line in the reminder system. the top 2 lines are a header for what the user is seeing and the bottom line is a footer, marking the end of the message. in total, the reminder message is 7 lines.

    since we have 100 players that have not voted recently, the reminder system will loop through all 100 players. for each player that hasn't voted recently, it will send the player the reminder message. 1 line at a time.

    each line is sent 100 times. since there are 7 lines, a total of 700 messages were sent. since you use a BukkitRunnable to do this, that loop of 700 was done in a single tick.

    now imagine this is a modded server. mods are always designed in a way that they never want to work well with each other. this creates lag. so while that loop of 700 doesn't seem like all that much, with the extra lag that the mod pack produces (many mod packs run at 15-17 tps without plugin interference regardless of server specs), the extra lag from that loop of 700 can actually freeze the server for 3-5 seconds, interrupting game play and causing player to have to repeat tasks (such as mining), wait to preform actions (such as opening a chest or interacting with another gui based block), or may even die to damage they couldn't defend against while the server was lagging out.

    your vote reminder timer assumes that the server is perfect, running at 20tps. this is simply not true for 99% of servers. while some may be close at 19.99 tps, that is not a perfect 20. in the case of the slower modded servers running at 15tps, if a remind time of 3600 seconds (1 hour) was put into the config, it would in fact take 4800 seconds (1 hour 20 minutes). 15tps is by far still playable and hardly noticeable by players, but it affects your plugin drastically.

    The solution I would suggest is to move away from BukkitRunnables.

    BukkitRunnables are great for doing something every X number of ticks. They however are not good at doing Y number of things X number of ticks. Everything you tell a BukkitRunnable to do, it does in a single tick, freezing the server until its task is complete. It then waits the X number of ticks to do it again.

    For time sensitive tasks, it would be best to use a multithreading technique built in to the java libraries. My personal favorite currently is using a Callable with an ExecutorService.

    Using a multithreading technique from java libraries will ignore the ticks of the server. You can use Thread.sleep(remindseconds*1000) to more closely reflect real time.

    I'm not entirely sure what you will need to do to access everything you need from the callable to make everything thread safe. I'm not in the mood to play with it myself today. Figuring it out though will greatly increase the value of this plugin as it should remove the lag it causes in servers.

    (our servers range from 10-50 people and the reminder freezes the server from 2-8 seconds in each of them. this may not sound significant, but when preforming a time sensitive action or fighting a boss, it is extremely significant)

    Thank you for reading my long winded request.

  • _ForgeUser12884998 added the tags New Enhancment Aug 18, 2015

To post a comment, please login or register a new account.