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


    Off topic: I lol so hard on every video on YouTube where they detonate TNT and it is CLEARLY visible that NoLagg is used. (no packet spam, you get client lag otherwise no matter how good your server is)
    'NASA called, they want their computer back'. Sorry guys, TNT is no longer a performance show-off for servers :)

    @Adrenaline the remaining bit?
  3. Offline


    Is it possible that your new way of sending chunks is chopping of the last half-byte of the chunk data in case the number of blocks the packet51 contains is odd?
    I am modifying chunk packets (before compressing of course) and my code was spitting out some debug warnings after updating to latest NoLagg:
    19:09:27 [INFORMATION] Warning: byte array mismatch. Is: 12 should be: 13
    19:09:27 [INFORMATION] Chunksize 1, 5, 1

    And, if I'm not mistaken, 13 is to be expected: 1x5x1 is 5 blocks in total in this packet. 5 bytes for the actual blocks, 2.5 bytes for the block data, 2.5 for skylight and 2.5 for blocklight = 12.5 bytes. Also the craftbukkit docs mention somewhere that the size of such a packet should be 2.5*x*y*z
    As I have no deeper knowledge of the actual inner workings of this packet (I'm only dealing with the block data, so I'm not affected by the packet being one byte short) I leave it up to you to figure out if something is wrong there. ;)
    The fact that the client doesn't crash however shows that this isn't a major issue.... But I still wonder. :)
  4. Offline


    @Borch I only optimize 16x128x16 size packets, all other packet sizes are left alone. Therefore the chunk packet data size is always the same: it simply copies all data over from the chunk, quick and simple.

    See also: on GitHub.
  5. Offline


    In fact the problem is happening with 1.54.2 too :(
    If I spawn a mob, after 1 second or so, the mob simple vanish.. disabling spawnlimits in config and reloading nolagg makes the problem disappear.
  6. Offline


    @spunkiie I see...well no other option but to throw the spawn limiter out then :)
    I'll look after methods to make my own entity spawner implementation...starting at the world.spawnEntities()
  7. Offline


    No errors what so ever bergerkiller. Must because im one of those guys who always stays up to date on dev builds :p
  8. Hmm....
    @ghost15 - were you perhaps using an old (<0.4) version of ChunkManager? There are no known bugs in the latest version, nor anything that could possibly slow your server down... If you could, just to be sure, test with the latest version, that would be great.
    Bergerkiller and I use more or less the same approach to manage chunks, but I have some different ideas than him on how to best send them. My algorithm works best on (slower) servers with bad connections, his algorithm works best for cases where bandwidth is not the limiting factor. In some cases his method may work better, in some cases my method may work better.
  9. Offline


    @Thulinma yup, main difference is that Thulinma uses a constant sending rate for chunks, possibly lower than the 'limit', while I try to push the connection into the max possible way. Mine may possibly cause a lot more network usage than strictly needed, but it's the best I can do to boost the chunk sending.

    Also, the only thing that comes to mind that may cause the tick drop is if a lot of chunks are loaded. Mind you, that when you send a chunk, the very same moment that chunk is loaded. (when you call getChunk())
    What I found was that chunk sending also equals chunk loading rates.

    Believe it or not, but I found a way to reduce:
    - Tick lag
    - Memory usage / load rate / write and allocate times
    Of chunks. I made my own chunk pool system to keep chunk data in memory (just like what happens anyway), but instead of just letting it get garbage collected for no reason, the data is re-used by a next chunk. Obviously, if the pool is full of unused data, a separate thread will automatically clear this pool AND the buffered chunk packet pool.

    Not only will this reduce tick lag when exploring and loading new chunks, it will also make them load faster, since the allocation of new memory is no longer needed. Since this reduces the time the garbage collector has to run, it even reduces CPU usage at some point.

    Of course, it is not yet finished. I still need to fix up the custom Chunk Loader extending class, but the BufferedChunk class is finished, including the pool for it.

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


    Seriously, I love you bergerkiller. Can't wait.
  11. Offline


    @bergerkiller anyideas on that problem i was having before with the chunks? Regarding the compatibility 1636
  12. Offline


    We gave this mod every single bit of chance, but we couldn't figure out how to make it work correctly. We had disabled any custom chunk loading or mob limiter in the plugin's config file but it keeps spamming this line about every second in the server log:

    Can't keep up! Did the system time change, or is the server overloaded?

    When we uninstall the plugin everything works correctly but as soon as we put it back in the server it lags badly. And we were only 2 on the server.

    I don't understand why, I even used nolagg monitor and the updates were in the green ( 0.1 ) and the ram used was not even at half.
  13. Offline



    Your .8 version is dropping mobs again but only under " worlds" any mob settings before the individual worlds stay. I reverted to last known working but I just wanted to let you know you forgot something ;).
  14. Offline


    @ledhead900 Ugh I'll just remove configuration trimming, is simpler than figuring out ways to mark bits read...

    @Krunch so even when disabling all features in the configuration it still causes tick rate drops? Are you, by any chance, exploring new chunks in the world? (the yellow [+x] value after Chunks: when monitoring)

    Since all internal updating times are fine, I can ignore the world meta data updating bits, but what remains is not much...
    I truly couldn't find anything; if everything is disabled nothing is done really, neither in tasks nor in the events...


    Meh I'm afraid I'll have to skip the chunk pool idea. It's possible, but the data is allocated while reading from the region files, so buffering it is impossible. Or I end up re-writing all Tag compounds, which is way too much work.
  15. Offline


    Ah I see now. Still weird, I can't reproduce it without NoLagg. Well, it doesn't break anything, at least I couldn't find anything after some thorough testing. So whatever. :)

    Some questions about the monitor feature.. I know you have answered some questions about it here and there in the thread, but it's hard to find all that stuff now :D (Maybe some explanation in the first post would help)

    I seem to have a lot of loaded chunks that aren't needed, but not unloaded because of the unload delay (or what else does "unloadable" mean?)

    This is with 13 players. They are not even moving that much, mostly building stuff, so why is it that still 90% of the chunks seem to be out of range of any player? The unload delay is just 20 secs. It apparently doesn't hurt performance (yet), but seems a bit extreme.
    What about the memory line? Does +300 modified mean that 300MB were modified? Is +36MB/s a lot for 14 players?

    As this output seems quite verbose I'd just like to know how to interpret stuff, so I could maybe find other things that slow down my server unnecessarily. I'm planning to raise the number of slots, so this might become more useful. :)
  16. Offline


    Hello bergerkiller,

    We had all features disabled EXCEPT for the drops stacking (which is sort of the only reason why we use this mod is to prevent lag from drops), the TNT explosion synchro stuff and the Item buffer in chunk in case there was too many items. Configuration file in quotes below.

    I will give you a bit more detail on the issue: We were only 2 in a big room (and on the server) about 60x60x50 of size that we dug out near bedrock. We were killing monsters in it because we didn't put enough lightning in there to prevent monsters from spawning. The kind of lag was network lag. Client was running fine, I could run jump etc etcc... but on my screen monsters would not move and my friend would not move also. Any actions would take a couple seconds to register. The server also would crash sometimes with this error (always OutOfMemory Java heap space):

    I was thinking it might be some Memory Leak issues because sometimes the server would run fine for a couple hours and then the next moment would crash every 5 minutes even if server is restarted.

    The server runs on a 1.5gb ram machine (which should IMO be enough for 2 players).
    We are using NoLagg 1.54.8 and the latest stable release of CraftBukkit (1597).

    Thanks for your help.

    EDIT: In the NoLagg monitor we had this line: Ticks per second: 1.6

    EDIT 2: Added config in quotes.
  17. Offline


    @Borch The +300 modified means:
    '300 MB of memory is temporarily and will be garbage collected soon, in other words, is modified. The other data ('static' memory) is kept in memory all the time, like chunks, worlds, entities, etc.

    +35 mb/s is pretty high, I give you that. It's possible that some plugin is working with a lot of data? (even with 13 players this shouldn't be so high)

    @Krunch that indeed looks like a bug with the async auto saver. Could you change the 'autoSaveInterval' to 40 or 100? Right then chunks are saved synchronously. (and not cloned and saved async)
  18. Offline


    Question: if the world resides on a ramdisk, are there any advantages to using the chunk unload delay?
  19. Offline



    This is what I get with the monitor when I get on the server with both 40 and 100 set for autoSaveInterval. At the beginning the memory looks good, only uses half of the 1.5gb, but then a couple seconds later it sky rockets to the point where it almost busts the 1.5gb. With NoLagg it still gives me a lot of these warnings: Can't keep up! Did the system time change, or is the server overloaded?

    Also note that I am the only one on the server at the time I was testing this. Also the server runs perfectly fine without any sort of lag when NoLagg is not installed.

  20. Offline


    @Greylocke the only advantage you then have is that the CPU spends less time (de)compressing chunks for no reason.

    @Krunch So something is using up a lot of RAM all of a sudden..but what.
    Do you notice anything in the monitored output when the RAM spikes? A lot of chunks loaded? A large number next to 'left to save'?
  21. Offline


    @bergerkiller The only numbers I see fluctuating between 50 and 100 are the green and red ones (+/-) on the Chunks line. The left to save is always at 0. It simply eats up all RAM. I made some tests and I am pretty sure it has to do with Chunk loading somehow (and memory leak). I decided to give the server 4gb of ram and to run around. No drastic changes has been seen on the number of loaded and updating chunks(fairly the same all the time) but it somehow STILL managed to eat up all of my RAM (4gb) and I am the only one connected on the server.
  22. Offline


    Could you please make the ChunkSending feature compatible with the Ore to Client Obfuscation plugin? When ChunkSending is enabled, none of the ores are being hidden.
  23. Offline


    @bergerkiller Any ETA on when I can test the new build out with the chunk pooling?
  24. Offline


    A vital plugin! Thanks for all your efforts!

    I didn't search through all 70(!) pages but I have a quick question... How exactly does /nolagg fix operate? Will it relight all existing chunks? Does it regenerate everything with good lighting or does it only calculate the lighting?

    I usually pre-generate my worlds with WorldGenerationControl which takes care of proper lighting, but the author is MIA right now and the plugin has issues with the most recent version of Bukkit. So I used WorldBorder's chunk generation to do it this time around, but it doesn't seem to handle lighting and I have lots of messed up shadows in the world that are making my Dynmaps quite ugly. I'd like to be able to relight and run an updaterender command in Dynmap without having to do a fullrender, so another question is: is any event thrown when doing a fix that Dynmap can see? :)

    Thanks for the help!
  25. Offline


    Wise choice just let us manually move over our changes I mean its not physics mathematics if server owners cannot manage something that simple then I don't know what to tell them.
  26. Offline


    @Darkhand81 I do re-sent fixed chunks to all online players, but other than that, nothing that really can be caught. (it is done async as well, so no block physics event either, a re-render is the only option I'm afraid)

    @rtcabooservb It can't be implemented, the memory is allocated while reading the chunk data from file and then directly thrown into the chunk, so I can't buffer that. And since chunk data is randomly written and read to the file, I can't read it differently either. (maybe by completely throwing the file reader around, no other way to do it)

    @godgodgodgo AFAIK it is already compatible, since it simply sends the chunk to the net server handler, just like it used to do internally. Old version?
  27. Offline


    Hmm.. I have no Idea why it won't work then. Could it be a problem caused by spout?
  28. Offline


    @bergerkiller With /nolagg monitor I get (not real numbers):
    Entities 2000[1000 mobs][500 items][0 TNT][20 players]
    I expect the first number to be total entities? But if you add the numbers in brackets they dont equal the total?
  29. Offline


    @xcanner yup, the ones in brackets are parts of that total. Actually, the brackets don't have a meaning, they are simply a separator.

    @godgodgodgo Could be Spout, but not sure what it is.
  30. Offline


    What is the rest of the entities (480)? 1000+500+0+20=1520
  31. Offline


    @xcanner things like minecarts, boats, ignored item (types) caused by bleedingmobs (for example)

Share This Page