Inactive [FIX/ADMN] NoLagg v1.88.1 - Prevent common lag causes on your server [2338]

Discussion in 'Inactive/Unsupported Plugins' started by bergerkiller, Sep 17, 2011.

  1. Offline


    I had already made this plugin before after having a major lag issue. (lots of torches being filled, turned into items, lag for 20 minutes) It also works for 1060.

    Some feature ideas are taken over from PerformanceTweaks by @LexManos so some credit goes to him. Code, however, written from scratch by me. :)


    If you get a warning message [NoLagg TLN] followed up with a stack trace in the log, this has to do with the main thread not having responded within 10 seconds. When a plugin takes more than this time to enable, it will show that. The warning is NOT an error and is no bug, and not a bug related to NoLagg. To disable this feature, disable 'threadlocknotifier' in the config.yml. This feature is mainly intended to notify you what plugin is causing the server to freeze, may it ever happen. It is used to debug plugins in general, as they may get stuck for whatever reason.

    NoLagg's features in a nutshell


    Prevent lag caused by many items

    Every time an item gets spawned, it is buffered per chunk. For example, you spawn 30 items using Q and the maximum allowed items per chunk is 20, then the 10 remaining items are not spawned. They are spawned as soon the item count in this chunk is < 20 again.


    Form item stacks - fully automatically

    Whenever two or more (configurable) items or experience orbs get near each other, they form a single stack of that item type. If someone drops 64 dirt blocks on the ground using Q, it will show a single item of 64 dirt instead.


    Prevent lag caused by TNT

    This plugin takes over tnt ignition caused by explosions. When exploding stacks of tnt, it does not rush all tnts into a single tick, but detonate them nicely in sync. This results in pretty awesome fireworks. :)


    Prevent lag caused by lighting glitches

    Whenever a new chunk is generated, it's lighting information is generated and all nearby players receive the updated chunk data. If the auto-method fails, you can use /nolagg fix to do it manually. This fixing fixes, for example, dark spots in and around caves lagging the client.


    Set entity spawn limits

    You can set a spawn limit on virtually every entity in the game. From mobs to items to TNT. Only thing being excluded is Players, since I can't simply kick someone 'like that'. :)
    Note: It removes already spawned entities too. So, if you want to keep your animals alive, don't set mob or animal limits, or it will possibly clear your farm animals. (or you can disable the spawn limiter all together)

    I recommend finding an alternative plugin for this instead. Removing entities after they are spawned causes more lag than it prevents!

    Global auto-saver

    Since asynchronous chunk saving is now implemented internally, it is no longer a problem to save entire worlds frequently. You can set auto-save intervals in the configuration. If used with an interval higher than 400 ticks (20 seconds) it will use a scheduled task instead of the internal saver to prevent chunks never getting saved. Another benefit is that player information is also auto-saved, preventing your players losing their inventory state.

    New chunk sending mechanics

    Instead of loading chunks all around the player, the player direction is used to load the visible chunks first. This means that players can expect chunks in front of them to load quickly, while chunks on the sides take a bit longer to appear. When the player looks into another direction, the direction changes and thus the new visible chunks get loaded first. Only if all chunks ahead of the player are loaded, chunks around the player are sent. This all can be configured using a simple minimum and maximum sending rate.


    Examining the server tick rate

    If you encounter very low tick rates and you want to find out what plugin is causing it, you can use the examine component to find it out. It comes with a graphic viewer, which makes bug tracking the easiest thing ever.


    Prevent cross-thread access for events

    As it seems, some plugins don't follow the rules and use Bukkit methods in another thread. This plugin will notify you and cancel if possible whenever this happens so other plugins understand their mistake. If you encounter a lot of spam in the console, first check the stack trace for the plugin that caused the error. Report this error to the author or remove the plugin, if you have questions you are free to ask.

    Configuration (on BukkitDev)

    Commands and Permissions (on BukkitDev)

    Synchronized code accessed by another thread? (BukkitDev)


    Video by brandcool86


    - Help I experience missing chunks
    If you are using Spout, don't use Reloads. This is also the reason why Spout added a warning when a player tries to reload the server. Not using Spout, then it's a bug which you can report.

    - Can this plugin be used with PTweaks
    (this message was really old...) Yes, they are compatible, but if certain features overlap, make sure you disable these features in either plugin.

    - I get a warning about the async auto save and interval. Wat do?
    Change the autoSaveInterval value in the configuration to a value higher than 400, like 600. The warning is to prevent endless autosaves to occur, clogging up CPU.

    - I have experienced CPU usage
    CPU usage is not the same as lag. NoLagg uses multiple (2-3) extra threads to prevent tick and network lag. If a lot has to be done, it does this quicker, but this takes more CPU obviously.

    - I have lag when using NoLagg
    See also the FAQ above. Explain what type of lag you have: tick lag, client lag, network lag and/or 'block placement' lag. You can use /nolagg monitor to check the tick rate. If this is normal (>15), then you have network lag. Client lag is when the FPS drops. Block placement lag is lag when the tick rate is normal and other network messages, like chat, are instant.

    - WorldEdit causes lag...
    YES because it is unsafe to take over the main thread while another plugin is having hold over it. I can try fixing this, but it could ultimately lead to some serious concurrency exceptions. Don't expect this to be implemented very soon...

    - Do spawn limits interfere with mob-spawning plugins like MobArena?
    No, it does not. It only limits mobs spawned by 'nature': all custom creature spawns are ignored throughout the run of the plugin. Only after you reload will it lose track of these entities and will it remove custom-spawned mobs. If you use MobArena, be sure nothing is going on when you reload the server.

    - Does item stacking interfere with Showcase or BleedingMobs?
    It supports Showcase and ShowcaseStandalone entirely. (showcased items are completely ignored at all times) The same applies to the 'particles' created by the BleedingMobs plugin. Know of a plugin where it stacks items which should not be stacked? Post the plugin name so I can add support. You are an owner and want to add support? Only having a function in your plugin to check if an item is 'ignored' is enough.

    - Can this plugin be used with Chunk Manager
    If you want to use the Chunk Manager with Nolagg, disable the chunk sending of Nolagg first. If you don't do that, this plugin will do that by itself and send a warning in the log. Of course, compare the results first. :)

    - What are the best settings if I have a lot of RAM memory?
    This plugin does not deal with reduced RAM memory. If I could, I would, but you simply can't reduce the amount of memory Java uses. This data is locked and secured, so I can't simply throw away bits of data or write and read data from/to disk. Any plugin claiming to reduce RAM usage on a server, is probably 'garbage collecting'. This fakes having less RAM usage by removing unused data, but Java does this by itself as well once it hits a certain limit. All these plugins will do is make the Garbage Collector run in overdrive, which will only kill your tick rate and/or CPU speeds. A bad thing.

    - I get a lot of 'Synchronized code accessed from another thread' errors
    Find out what plugin is acting up by inspecting the stack trace. If the plugin that causes this is inactive, all you can do is wait for a refurnished version or someone to fix it for you, or use an alternative plugin. If it's still under development, notify the author of this, it IS an error caused by that plugin. If you can't find out the cause, PM me or post in this thread.

    Before you begin writing a lag issue

    This is very important, just posting a 'it causuz lagz und shitz' won't do, won't help and I won't be able to help you any further either. Question is if I even want to help you, if you post such a message without anything worth looking at. Things to include in your message:
    - Errors in the log if possible
    - What CB version you use and what NoLagg version you use
    - When this lag occurs. Tick rate drop in general?
    - The configuration you used when running this plugin
    - What type of lag if applicable. Options are: tick lag, client lag, network lag (see above)

    Important links

    NoLagg Download page and others at Dev Bukkit
    View the source code of NoLagg at GitHub

    Use an archive extracting program (WinRar, WinZip) to open the archive.

    - Add option to disable physics when the tick delay becomes too high


    Show your appreciation for my plugins by donating
  2. Offline


    GameFAQsRolo ok thanks for clearing that up, and ye, was using Spout at the time :)

    Jaker232 You need to use the 1.57.7 version for older craftbukkit builds.
  3. Offline


    Problem with orebfuscator (seems your chunkSending algorithm somehow bypasses chunk obfuscating in my plugin with Spout is installed)
    Attempt to fix it:
    Add line
    this.l = true;
    somewhere in here:

    Without the Packet.l = true, spout thinks it's a normal packet and sends it along with your other packets, such as Chat packet, also might create much lag.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jul 14, 2016
  4. Offline


  5. Offline


    nope @_@
  6. Offline


    lishid I thought I had set that to true though...(otherwise it doesn't get handled by the packet compression thread)
  7. Offline


    2 things:

    1. since you're not calling super(), the default constructor that sets it to true is never called.
    2. It's renamed recently to

    this.lowPriority = true;
  8. Offline


    lishid good point, I'll change it then. I can vaguely remember I didn't want Spout to receive my packet since it uses this spiral buffer, so it's possible that this is why I didn't do that. I'll look at the Spout source again.
  9. Offline


    I'm using a newer build that is 1.1, you may want to edit your code.
  10. Offline


    Jaker232 I'll do that at a later time, else I keep on updating NoLagg...
    Once they reach build 1800 or so I'll update everything, got to focus on TrainCarts more.
  11. Offline


    The more you procrastinate, the more I have to wait for my server to go up. However, I can just go work on the forums and setting it all up.
  12. Offline


    Jaker232 Um I downloaded the latest CB build (1774) and didn't get a single error in my project.. did you use 1.57.8?
  13. Offline


    CB 1714
    Version 1.56.6
  14. Offline


    Spout's code checks for lowPriority instead of packet instanceof Packet51MapChunk to check against it's packet listener (canSendUncompressedPacket)
  15. Offline


    Jaker232 ah that version is..a bit too Try updating CraftBukkit to a higher build. (1714 still had some bugs I believe)

    lishid Maybe you have more Spout can I make my chunk packet get sent without Spout using their annoying spiral-queue-sending on it? It kinda defeats it's purpose if Spout messes up the order...


    Also, setting lowPriority to true does not fix it.

    lishid well if you use Spouts packet listener and alter the packet raw data directly, it will work.

    I'm adding multi-thread support so the packet sender can keep up if your processing takes too long.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Dec 28, 2018
  16. Offline


    Did you test? There is a way to bypass spout, but it would bypass everything else...
  17. Offline


    lishid actually, whenever I send a packet51mapchunk, even if created using the x/y/z/w/h/d/world parameters, it doesn't appear to be received by Spout at all...I used the EntityPlayer netserverhandler...


    meh time to do this even more different: I'm adding my own chunk compression thread. It will copy the chunk data over in one single buffer, send it through spout if enabled and compress it locally. This way I can add multiple compression threads running simulatenously, completely eliminating every type of tick rate drop caused by chunk sending.

    Adding to the mix: a separate task which loads the chunks around the player.

    Chunk compression threads finished :)
    You can now add *infinite* compression threads to run on your server, GREAT for multi-core CPU's :)
    Default is only one thread, but you can raise this value in the configuration. When two threads are running you don't even notice that ore obfuscator is running - chunk receive rate stays the same. (a bit delayed though)

    Also, it will now send packets nearby (<3 chunks) with a higher priority than those further away. This will ensure that players low on chunks will get their packets compressed as first and will receive it as first. Spout packet listener support has been fully added, ore obfuscators work perfect. :)

    Finally, it will no longer allocate 80 kb of chunk data for every chunk. Instead it allocates a single 80 kb buffer for each compression thread. When sending a chunk, it fills this buffer with the chunk data, sends it to spout, compresses it. Even the compressed data is buffered using special 'flexible buffers', if it doesn't fit, it will inflate to make room for the data. Luckily chunk packets were made around a size variable.

    Will upload the source now to GitHub so lishid has an idea how I solved my issue...

    <chunk sending thread>

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Dec 28, 2018
  18. Offline


    -_- how can you solve it? I'm instructing all my users to disable chunk sending in your plugin for now...
  19. Offline


    lishid don't worry about it, I am adding a separate type of spout support now. There is always a way to make Spout do my events :)

    Right now building a Chunk compression thread, using a single 80 kb byte buffer and deflater to generate (smaller) compressed data. This raw byte data buffer is sent.

    Note that the raw data buffer WILL change, so any plugin that stores packet data temporarily will fail. I'll add a separate 'useChunkPacketBuffer' option.
  20. Offline


    If you can, please read through my code to make sure it's compatible, thanks!
    If you need help, I'll be on bukkitdev chnnel sometimes later tonight

    My plugin comes with a configurable amount of threads for processing. If using spout, then I let spout manage the threads BECAUSE IF YOU SEND IT TO ANOTHER THREAD, somehow spout breaks it and you get 'holes' of not loaded chunks sometimes.

    Only one chunk is sent per tick per player. If your server's core is not enough to keep up with it, then multi-core might help.
    Btw, usually you get ~100-200 chunks per player on login, and ~10-20 when a player move to another chunk

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Feb 15, 2019
  21. Offline


    Any ETA?
  22. Offline


    That's what I usually do.
    Without spout, I override player.NetServerHandler and intercepts any packet Packet51MapChunk, send it to another thread to be processed within a queue.
    With spout, I use the UncompressedPacketListener, which gets processed inside spout.

    BTW, if you send a packet from spout to another thread to be processed later, you would get holes in the world sometimes. (probably some spout optimization that screwed up)
  23. Offline


    Hi, I seem to be running in to bit of an error. Hate to post it on the plugin page, but I didn't find a ticket page on your bukkitdev. Whenever I try to load this syntax:

    Version: Last 1.0.1 Build for CB 1597

      default: {}
      global: {}
          monster: 750
          animal: 500
          fallingsand: 20
          monster: 10
          animal: 6
          fallingsand: 20
    It generates this instead:
      default: {}
      global: {}
          monster: 750
          animal: 500
          fallingsand: 20
          monster: 10
          animal: 6
          fallingsand: 20
        monster: -1
        animal: -1
        fallingsand: -1
    P.S. Is there a fallinggravel field, too? I didn't see one in the configuration field but it didn't shoot errors when I used it earlier.

    Thanks, I very much appreciate it. ^^
  24. Offline


    So for example, if you have a 4 core, 8 thread cpu and you change the compression threads to 8 in the config, chunks will load faster?
  25. Offline


    Fuzzwolf that is odd, and good suggestion about the falling sand/gravel, I'll add the gravel version too. (it is the same fallingsand entity, but uses a different 'type' of block)
    Will look at the configuration bit, but could be native-related...

    rtcabooservb yes, if a lot of players are online, it will use multithreading, which will make it possible to compress more packets in a certain timescale. Using too many threads is a waste though, since it will then have a lot of waiting threads. I'll add a 'busy percentage' identifier for the monitor.
  26. Offline


    How many threads do you recommend?

    I'm actually using an intel 8 core CPU at 4.5ghz. I think it can keep up. :p How many threads do you recommend I use?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jul 14, 2016
  27. Offline


    1 core is usually enough for 40 players, don't go more than total - 1 threads.
  28. Offline


    So I will not benefit at all with 2 threads? For example, it won't help with worldedit when chunks update?

    Any ETA on when we can test this build on github?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jul 14, 2016
  29. Offline


    I'm not sure what WorldEdit does with chunk packets, but I think bukkit server actually sends them as chunks.
    It depends on how much you're editing, but you'd still be sending 1 chunk per tick.
  30. Offline


    Okay. Thanks for the info. :p Just wanted to know if more than one thread would help, especially since I've been holding off on orebfuscate since it slows down chunk sending. I'd love to test out a build whenever possible.
  31. Offline


    It doesn't slow chunk sending as much as network lag would.
    Also, I have a configurable number of threads for processing, if you haven't noticed. (command: /ofc threads #)

Share This Page