What causes lag?

Discussion in 'Spigot Plugin Development' started by IAmRoot, Aug 15, 2019.

  1. I tried doing google searches for this but could only find posts and articles on how to stop lag from a server owner's perspective (like installing lag monitoring plugins like clearlagg). But when developing a plugin what are the most common causes of lag (besides memory leaks because that's a java thing not spigot).

    Just curious on what causes the most lag in spigot plugins.
     
    • IO operations being executed in the main thread
    • Poor code designs which make use of heavy code improprietly.
    • Long operations/iterations of collections handled improperly.
    And so many more things in general. However, a way to handle lag is not by adding more lag. (And what I mean by that is you don't fight lag by adding plugins which may contribute to it)

    You run some timings, find the source of the lag and handle it appropriately.
    Memory leaks are hard to spot but may actually be common if developers are not careful enough.
     
  2. x86

    x86

    Updating blocks using code uses quite a bit of cpu (such as updating signs in a loop).

    Waiting for network responses on the main thread is also extremely stupid.