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


    @bergerkiller I just noticed that when TPS drops on my server, the difference is somtimes very high 1500+
  3. Offline

    Don Redhorse

    lol... i just got this... with 1.54.8..

    2012-01-06 22:22:31 [WARNING] Could not properly handle event CHUNK_LOAD:
    java.lang.IllegalAccessError: Synchronized code got accessed from another thread: com.bergerkiller.bukkit.nolagg.StackFormer
        at org.bukkit.plugin.RegisteredListener.callEvent(
        at org.bukkit.plugin.SimplePluginManager.callEvent(
        at net.minecraft.server.ChunkProviderServer.getChunkAt(
        at org.bukkit.craftbukkit.CraftWorld.getChunkAt(
        at com.bergerkiller.bukkit.nolagg.meta.ChunkMetaData.getChunk(
        at com.bergerkiller.bukkit.nolagg.meta.ChunkMetaData.getNativeChunk(
        at com.bergerkiller.bukkit.nolagg.meta.ChunkMetaData.add(
        at com.bergerkiller.bukkit.nolagg.meta.ChunkMetaData.<init>(
        at com.bergerkiller.bukkit.nolagg.meta.WorldMetaData.getChunk(
        at com.bergerkiller.bukkit.nolagg.meta.WorldMetaData.getChunk(
        at com.bergerkiller.bukkit.nolagg.meta.WorldMetaData.removeSpawnedItem(
        at com.bergerkiller.bukkit.nolagg.WorldStackFormer.kill(
        at com.bergerkiller.bukkit.nolagg.WorldStackFormer.updateItems(
        at com.bergerkiller.bukkit.nolagg.meta.WorldMetaData.updateStackFormingAsync(
    2012-01-06 22:22:31 [INFO] This error is logged only once: it could have occurred multiple times by now.
    2012-01-06 22:22:31 [INFO] Please contact one of the authors of plugin 'NoLagg': bergerkiller
  4. Offline


    Not that simple, you need to request the ore guy to make a addon for his plugin that works around this one.
  5. Offline


    What does this error mean, and what can I do to either prevent it or fix it when it happens?
    [NoLagg] Skipping auto-save for worlds: Saving queue overloaded.

    Right afterwards, the TPS slipped steadily downward. NoLagg monitor didn't report much:
    Memory: 457/1019 MB (+0 modified)(+-39 MB/s)
    Chunks: 3324 [701 Unloadable] [+0] [-0] [0 left to save]
    Entities: 458 [390 mobs] [21 items] [0 mobile TNT]
    Buffers: [0 TNT] [0 items] [8.24 mb Chunk Packets]
    Ticks per second: 8.9 [44.0%]
  6. Offline


    Have you patched nolagg ? from last time I asked because,
    autoSaveInterval: 4000
    explosionRate: 15
    chunkUnloadDelay: 60000
    formItemStacks: true
    tntDetonationRate: 5
    maxItemsPerChunk: 40
    updateInterval: 30
    tntDetonationInterval: 10
        mob: 1400
        Earth: {}
        Venus: {}
        Nether: {}
        Earth_the_end: {}
        space: {}
        mob: -1
        ghast: -1
        squid: -1
        slime: -1
      default: {}
    bufferItems: true
    bufferTNT: true
    useSpawnLimits: true
    useChunkUnloadDelay: true
    stackRadius: 1.0
    stackThreshold: 2
    monitorInterval: 40
      enabled: true
      boost: 25
      minRate: 0.25
      maxRate: 2.0
    ignoredItemTypes: []
  7. Offline


    No I've been working on something totally unrelated to Bukkit (School), I got some spare time now so I'll patch the things I can...

    Thanks for the chunk load access error. I'll look at it. (it doesn't really load chunks when stacking entities, it merely changes some values, but you never know...)


    @xcanner are you by any chance using TrainCarts? Because that plugin had issues with hundreds/thousands of minecarts getting spawned causing massive lag.

    Async access error is fixed (simple removed that line ...)
  8. Offline


    1597 bukkit
    nolagg 1.54.8
    2012-01-07 15:44:14 [INFOConnection reset
    -01-07 15:44:14 [SEVERE]     at com.bergerkiller.bukkit.nolagg.BufferedPacket51MapChunk.a(
    2012-01-07 15:44:14 [SEVERE]     at net.minecraft.server.Packet.a(
    2012-01-07 15:44:14 [SEVERE]     at net.minecraft.server.NetworkManager.g(
    2012-01-07 15:44:14 [SEVERE]     at net.minecraft.server.NetworkManager.d(
    2012-01-07 15:44:14 [SEVERE]     at

    2012-01-07 15:43:52 [INFOConnection reset
    -01-07 15:43:52 [SEVERE]     at Method)
    2012-01-07 15:43:52 [SEVERE]     at
    2012-01-07 15:43:52 [SEVERE]     at
    2012-01-07 15:43:52 [SEVERE]     at
    2012-01-07 15:43:52 [SEVERE]     at
    2012-01-07 15:43:52 [SEVERE]     at
    2012-01-07 15:43:52 [SEVERE]     at net.minecraft.server.Packet51MapChunk.a(
    2012-01-07 15:43:52 [SEVERE]     at com.bergerkiller.bukkit.nolagg.BufferedPacket51MapChunk.a(
    2012-01-07 15:43:52 [SEVERE]     at net.minecraft.server.Packet.a(
    2012-01-07 15:43:52 [SEVERE]     at net.minecraft.server.NetworkManager.g(
    2012-01-07 15:43:52 [SEVERE]     at net.minecraft.server.NetworkManager.d(
    2012-01-07 15:43:52 [SEVERE]     at
  9. Offline


    @Adrenaline ow great, I use a custom implementation of a commonly used packet and now all native errors end up here...:(

    Honestly, this isn't caused by NoLagg, it's just an error occurring natively.
    But, I'll add a check against it anyway (it's an useless error)
  10. Offline


    @bergerkiller I'm curious, why do you use 1575 instead of the RB (1597)?
  11. Offline


    @QQCucumber I have no idea honestly, I like the number I suppose. I should change it though, I use 1596 on my server. What is the latest RB actually?

    Also, chunk buffers implemented :D
    It took me one long ride to implement buffered tag compounds, but it was effective: I can now effectively re-use chunk byte data, this way reducing chunk load times and memory usage increase. It even allows me to get a read-out of the current buffered chunk size, just like packets. Great for spotting memory leaks!

    And I already spot a memory leak just now. It's clearly visible that the number does not drop, which is a bad sign.
  12. Offline


    Yeah I need to figure out where I allocate so much mem all the time. This is with 17 players... :/
  13. Offline


    I do, but we only use destinations and tag signs on the server (1.54).
  14. Offline


    Ok I uploaded version 1.55 BETA. It has chunk re-use (buffer) functionality

    But: a VERY large but. If you want to test/use it, PLEASE make a backup of your world(s) before you do so. An hour ago when testing it, it caused chunks to be teleported from place to place, due to the chunk getting saved after the data got a new owner chunk. This resulted in massive floating pieces of chunk dripping out lava and was quite messy.

    I fixed (at least, I hope I fixed) that issue now, but need some testers to verify that this no longer happens. Therefore, back-up your worlds first, it seriously f'ed my test world up :(

    Using /nolagg monitor you can check the chunk buffer size from time to time.

    It does have great performance use: it gets rid of high memory rates some people may be having. (it eventually got to 0 mb/s when the buffer was at full capacity)

    Also, you can now use /nolagg gc to make the garbage collector clean up unneeded memory. Note that the internal JVM does this a lot better, but it can be used for benchmarks. (and I added it to piss off PTweaks, which uses the garbage collect command to fake low memory usage :) )

    @Smex yup, but that does not reduce RAM memory usage in any way. The internal mechanisms already deal with that perfectly fine, better than a plugin developer ever could, therefore the /nolagg gc command is only for benchmarks. (to see how much memory is actually in use)
    Once the server begins to run out of memory, it performs a global garbage collect himself, which is a lot better than performing it all the time. (which consumes CPU times)

    However, I do deal with low memory now. This is done by using buffers of data instead of throwing away memory and allocating new memory. In the long run, this will reduce the rate memory usage increases, thus reduces the amount of times the garbage collector has to run. It also speeds up the process of chunk loading, since it no longer has to ask the JVM to allocate new memory for him. (which requires some background calculation to find a suitable spot)

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


    Awesome. Hope the world bug is fixed. Testing now.
  16. Offline


    @rtcabooservb please don't, chunk swapping bug still exists. D:
    Removed it again...
  17. Offline


    Oh. D: Just when I was about to put it on too. Nice save.

    Edit: Any ETA on a working build?
  18. Offline


    @rtcabooservb Will update in a few minutes, but first need to do ALOT of testing on this...


    This thing is hard to fix...has something to do with a chunk re-using another's chunk data while loading...but this is not possible since everything is synced :/

    Ok new beta is up. Tracked down the issue and fixed it. It was caused by an internal save-queueing system I had totally now completely evades this saving system. This was possibly another reason for a memory was pending the chunks for saving from another thread, instead of actually saving it as was intented.

    I have seen no missing chunks and/or weird chunk swaps (and neither did I see any 'tile entity wrong block type' warnings in the log). However, chunk data buffering is a delicate task, as the old chunk may still be in use while you redirect it's data. Therefore, if you are able to test this new feature out, please do so. I don't have all possible plugins at hand to fully test it.

    Note that ANY plugin that keeps chunks in hashmaps wrongly will no longer cause memory leaks now, since the data is simply re-used. This can be a good thing, but also a bad thing if the plugin actively operates on the (unloaded) chunk. (which is a bad thing anyway)

    Main features this beta adds:
    - Reading the memory allocated for chunks
    - Chunk load smoothing: will handle massive loads and unloads with great ease
    - Memory more stable: no longer memory increasing rapidly when players walk around
    - A garbage collect (/nolagg gc) command to collect unneeded memory garbage (kinda optional)
    - better saving system: no longer uses the pending save system

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


  20. Offline


    Waiting for Stable version :)
  21. Offline


    @Adrenaline I'm waiting for someone saying the latest beta is stable. I've been using it here for a full day and haven't had any issues with it, but I can't speak for others...
  22. Offline


    I've been using it since the release. No problems on my end. I'm waiting for another update. :p
  23. Offline


    @bergerkiller I've been using it 1.55Beta2 and it works very well.
  24. Offline


    With proud I say: it was a great idea of mine to implement chunk buffering.
    Chunk data generation went from:
    Saving a lot of processing time when a lot of chunks get loaded. I did have to adjust everything a bit.

    On top of that, it will now save all chunks async ALWAYS. I now override the internal saving coding. This means that my simple /world save all command in MyWorlds is now instant, while you see the 'to save' rise to 400 chunks, and then decreasing correctly. This renders world auto-save plugin useless, as the save operations no longer take several seconds to perform.

    Some adjustments on the next version (stable version) I'll upload soon:
    - No longer increases pools buffer by buffer, but in batches, reducing the large overhead when new buffers are made
    - No longer cleans up pools that were recently inflated, thus improving efficiency
    - Way better saving system (will always save chunks async, for non-unload saves it clones the (tile)entity data to a DummyChunk)
    - No longer assumes chunks are unloaded in onChunkUnload, instead uses the custom chunk loader to perform chunk unload-saving.
    - Pools keep a queue of recently freed buffers, reducing the need to loop through all buffers to find an empty one.

    Plus a lot of performance fixes. I am still testing the latest build on various criteria.

    Ok updated to 1.56 (to prevent confusions around 1.55 beta, I just incremented the version number)

    Everything has been debugged thoroughly (luckily I did, otherwise it would have become a messy situation with corrupted chunks, and yes I've seen them)

    See the changelog for more details, main improvement is the chunk data buffering. It re-uses chunks, reducing chunk load times significantly. I did some benchmarks with the internal StopWatch class, and it indeed is a lot faster. (though with a little overhead when new memory needs to be allocated, but that's expected)

    Of course, I can't compare my one-player-server to a server full of people, but if it reduces load times for one player, it surely does this for multiple players. I expect this will reduce the amount of RAM memory a server requires to host more players, as it now ONLY needs memory for the actual loaded chunks. If this is 30000 chunks, this is 2.4-3 gb.

    Note: The '[200 U]' value after chunks is the amount of chunks that could potentially be unloaded, but are kept loaded by players. They are the 'unloadable' chunks.

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


    What does this error mean?

    2012-01-10 18:58:17 [WARNING] Task of 'NoLagg' generated an exception
    at org.bukkit.craftbukkit.util.LongBaseHashtable.getEntry(
    at org.bukkit.craftbukkit.util.LongHashtable.get(
    at org.bukkit.craftbukkit.util.LongHashtable.get(
    at net.minecraft.server.ChunkProviderServer.getChunkAt(
    at org.bukkit.craftbukkit.CraftWorld.getChunkAt(
    at org.bukkit.craftbukkit.CraftWorld.getBlockAt(
    at org.bukkit.craftbukkit.block.CraftBlock.getRelative(
    at org.getspout.spout.block.SpoutCraftBlock.getRelative(
    at org.getspout.spout.block.SpoutCraftBlock.getRelative(
    at org.getspout.spout.block.SpoutCraftBlock.getRelative(
    at com.bergerkiller.bukkit.nolagg.NLBlockListener.fixColumn( 
    Happens only in one world I think when using Bspace worlds it does this after the server locks up. can take up to 10min of play but does it on block modify events like place/break. Normally I just get cpu spike and server lockup but I manged to pull an error by increasing the stack size in java to 20mb using arguments in command line.

    Here's the thing I tried 5 backups I tried with little to no plugins I have tried a brand new space world made in latest Banana space. I suspect it might be bukkit tho I don't recall it doing it before reco build was out. My other worlds appear to be un effected.


    and you forgot t fix the config mob wipe issue in the new version :'(
  26. Offline


    I Love It. end.
  27. Offline


    @ledhead900 Mh yeah I didn't remove the configuration trimming bit. But, since I'll get rid of mob limits in the future anyway, it doesn't really matter. The problem is that I have to cancel mob spawning and use my own spawner instead, while still listening for the animal/monster enable property of the world (which is disabled all the time)

    I couldn't spot the stack trace 'overflow' error though, I did read somewhere that you have to increase the maximum allowed stack trace size for the JVM somewhere, but can't remember where. (I believe as parameter when launching the server)

    Also, what are/is the stacktrace line(s) that are shown multiple times? What is repetitively logged?
    stacktrace overflow exceptions look like this:
    etc, etc, etc, 
  28. Offline


    I print with the /gc from essentials the memory usage + the loaded chunks per world.
    NoLagg has "New chunk sending mechanics". So how chunks are theretically loaded before and after nolagg per player at view-distance 10?
    Can you draw a chunksending picture without NoLagg
    This is within:

    and what is if i'm using spout/spoutcraft server-only?
    Spout send to the client "custom chunk packets". NoLagg has Custom packages too. Which method will be used?
  29. Offline


    Last edited by a moderator: Jul 14, 2016
  30. Offline


    im glad you are keeping up the amazing work i have always depended on for my servers. bergerkiller you are the man and i dont know what i would do without my nolag n my myworlds. Good shee bro, check out my portal station schematic i designed for your myworlds pluggin. mad thanks for your dedication to your pluggin users.
  31. Offline


    @Sh4d0w it takes a while to make such an animated gif (took me an hour, lol)
    But natively nothing is sorted at all. This means that, last coordinate added, last sent. So, if you walk around in the world, the new chunks you enter are not sent first, even if you are standing on top of it. Instead chunks behind you are sent (which were 'queued' earlier). Spout fixes this issue by 'spiralling' the chunk sending, but this spiralling does not take player look-at direction in mind. (therefore still sends chunks behind the player)

    Native: No sorting: last chunk added, last sent
    Spout: Sorting: spiral around the player
    NoLagg: Uses player direction and sends from the middle outwards (controlled spiralling)

    Not only does NoLagg use a different sending 'order', it also re-uses chunk packet data during the creation of said chunk packets, reducing tick rate drop while chunks are sent. It also skips several mathematical calculations (directly copies chunk data into the buffer)

    @PinguinAman interesting, since when does polling from a queue cause a 'no such element' exception. If there is no element, it should return null...however, it could be a cross-threading issue. I'll look at this.


    Ok got it, thanks for reporting. Was indeed a cross-threading issue that was occurring. I'll make a quick fix.

    @andrewkm I believe this is fixed, since the chunk region loader got completely updated to the latest coding and is now 100% managed by myself. (even chunk loading is optimized to not create new byte arrays while reading)


    Yup this is fixed. If the tick list is set to null, it simply sets it to an empty list instead.

Share This Page