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

    bergerkiller

    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. :)

    Important:

    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

    Description

    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.

    Read more...

    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.

    Read more...

    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. :)

    Read more...

    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.

    Read more...

    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.

    Read more...

    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.

    Read more...

    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)



    Media



    Video by brandcool86


    FAQ

    - 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.

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

    Changelog

    Show your appreciation for my plugins by donating
    [​IMG]
     
  2. Offline

    bergerkiller

    @beleg anyway, thanks for the report, because it did lack a null check. You see, in the latest few versions I added memory leak fixes. (otherwise temporary chunks, sets, lists, etc. stay in memory for no reason), when the plugin is disabled Bukkit likes to keep events working...soow they still fire and caused an NPE.

    I'll add a general announcement in the main page, about Spout.
     
  3. Offline

    Chrispm84

    @bergerkiller I'll try something like this and see if it helps:

    spawnlimits:
    default:
    mob: 2000
    animal: 1000
    monster: 800
    slime: 200

    If you ever wanna see a server that GREATLY benefits from your plugin:
    IP: omegacraft.beastnode.org
     
  4. Offline

    beleg

    are /mobspawn and the MobArena included? if im setting mob: to 1000
    (Could the mobarena spawn mobs over the mob limit? i think this would be good :D)
     
  5. Offline

    bergerkiller

    @beleg yup they can, custom mobs are excluded in the limits. When reloading this is undone, so custom-spawned mobs do get removed then.

    Another update, found out it loads the chunk although it was already loaded, causing the (already existing) entities to stay while loading those from file. It's kinda weird, but I can fix it by clearing the data within.

    EDIT

    Yup clearing it works, but it is kinda weird that it keeps the chunk in memory although I unloaded it. That is actually a more severe bug IMO...

    EDIT

    Re-uploaded a fixed version now, same version number. (only added a single 'removeEntities()' line before saving)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Sep 9, 2018
  6. Offline

    sirbrando

    Ok, I'm having a problem where a crap ton of mobs are being spawned in one spot! There was over 5000 in one area at one point. What is this? Help thank you.
     
  7. Offline

    bergerkiller

    @sirbrando Had the same on a friends' server...it's really REALLY weird, because no mob limits were set so far...

    Neither do I spawn mobs in the plugin, which makes it very weird. Since it always leads to one point:
    - It has to be the new async saving.... :confused:

    Since you get it, try setting 'chunkUnloadAsyncSave' to false. If it no longer occurs then, then I know where to look...
    Obviously, if you set a mob limit this will also fix this.
     
  8. Offline

    sirbrando

    I don't know... I did //butcher , it got rid of them. But it's starting to happen again, there was 200 sheep in one area just a bit ago. I laughed at first... then I realized... This could be a big problem.
     
  9. Offline

    bergerkiller

    Ok got it confirmed. Whenever chunks get unloaded (out of view), the mob count in that chunk duplicate for very strange reasons. I'll look into it a bit more, perhaps need to clear the mobs in the chunks before saving them...

    For now, control it by setting a mob limit of around 400 default.
     
  10. Offline

    sirbrando

    Alright
     
  11. Offline

    sirbrando

    ok, thanks a lot! :)
     
  12. Offline

    GameFAQsRolo

    I'm running into a weird problem since 1.42 I think and currently on 1.44.2? (I haven't tested this latest one .3?). This is on CB 1.9 pre5 (happened on builds #21 and #25) so I don't know if you're even giving support for these versions yet.

    I thought someone had already mentioned it, but now I can't find the post. There are 2 main things that happen: (1) mobs freeze and (2) the player can't pick up items. There might be a possible (3) with some chunks not loading during this same time frame. Here is a quick video:
    http://www.youtube.com/watch?v=ItYmDpwbDAI

    It's brief, but you can see that the mobs on the right are frozen in place. All players have to log out in order for the bug to go away.

    CB #25 (1.9 pre5)
    NoLagg 1.44.2
    NoLagg config - http://pastebin.com/t5hd6Dbk
    Plugin list - http://pastebin.com/ZsxPR4Yz

    I'll load up the new version and see if it happens again.
     
  13. Offline

    bergerkiller

    @GameFAQsRolo I did fix entities not getting cleared when the chunk unloads, which could explain the frozen mobs. (it has to call entity remove on all entities or they stay at the player, which seems obvious)

    Actually...items are also entities. Meh I probably fixed it, but if it still occurs feel free to reply. :)
     
  14. Offline

    Borch

    interacting from another thread?!

    Well, don't have time to check the code right now, but another thing that came to my mind is:

    1. a chunk is to be unloaded, the async thread gets a handle to it, the chunk is dereferenced in the main thread.
    2. the async thread gets interrupted, the main thread keeps running
    3. someone comes near the same chunk that is about to be written to disk by the save thread
    4. will the main thread load the outdated chunk from disk, or will it check if there is a more recent version of the chunk pending in the async thread?
     
  15. Offline

    bergerkiller

    1. Yep, it unloads, detaches and the loose data is saved async.
    2. Then it marks itself as not enabled, you are notified in the console and no async saving is performed, instead it will act as if it is not enabled. (a bit laggier, you can restart it by reloading if you really have to)
    3. Impossible, before a chunk can possibly get unloaded it checks if a player is near. If so, the timer is re-set, if not, it checks if time ran out and unloads the chunk. Chunk is unloaded and the left-over chunk data is temporarily stored. The async thread saves and removes these chunks, which doesn't take that long, but could still cause tick lag if not done async. Possible errors are always caught.
    4. Good question, I guess it depends on the amount of chunks it has to save. I can't make it 'instaload' the temporary chunk, since there is no event for it. There is a very small chance it loads the chunk before saving, haven't noticed it happening though...

    You do make a good point in the fourth point, there is a very small chance it loads the chunk before it is saved by the async thread. I'll see if this can occur, and if so, if it's possible to transfer this queued chunk to this newly loaded chunk.
     
  16. Offline

    Borch

    Ah sorry I probably didn't make it clear enough, this was supposed to be a chain of events, not 4 independant points ;)
    In 2 by "gets interrupted" I meant interrupted by the OS' scheduler, not crash or something. I know the odds are pretty low that this will happen, but it will eventually happen for someone I guess, and if Murphy's law strikes at the same time, it wil happen on a chunk that has been active for 5 hours before where players built the most awesome thing ever. :D
    But anyways, this is a pretty awesome idea. In the past weeks I kept experimenting with the chunk unload delay and save interval and noticed that it can have a bad impact if you set them too high.
    Oh and do you know anything about built-in async saving in 1.9? A while ago I read that Mojang at least was about to implement that in singleplayer, anything like that in the 1.9preX server?
     
  17. Offline

    bergerkiller

    @Borch Don't worry, that's what the auto save interval is for. As far I know it doesn't save async there...mmh I should definitely implement that though. :p

    And yeah, having it too high will result in higher RAM usage, which will make it harder for the JVM to assign memory to new variables. Note that disabling autosaving does exactly the same, I had around 2000 loaded chunks at some point...very VERY bad idea to run a server like that.

    I don't know much of the new 1.9 pre release, haven't looked into it much. Did notice some signs of animals no longer firing the creature spawn event...
     
  18. Offline

    GameFAQsRolo

    It is still happening with the new 1.44 file.

    I also found the post I had remembered seeing.
    This is exactly the behavior I'm experiencing on my server. The following posts about the black holes also seems related. The only thing I'm not experiencing is the 2000 mobs spawning, but that might be because I have the spawn limit set.
     
  19. Offline

    bergerkiller

    @GameFAQsRolo This jumping around only happened to me once (in the early dev. stages) - then a chunk nearby wasn't loaded. The only possible way this happens is if you see black holes in which you can fall. (you are not pushed back by the server)

    Hard to tell what can cause this, but if disabling the chunk unload delay fixes this, then I know where to look for clues.

    Also, did you use /reload while the server runs? It's one of the key factors that can cause chunk issues.

    EDIT

    I see CraftBukkit uses a different method to check if players are near a certain chunk. Time to use that instead, although it requires more chunks near.

    Ok re-uploaded 1.44 with this change in 'can chunk unload'. It now uses a chunk radius larger than the view distance to check if a chunk can unload. This could solve the issue, but not sure.
     
  20. Offline

    GameFAQsRolo

    @bergerkiller I will test again in about 12 hours. I did not use /reload. I will try the new version and if the problem persists, I will change the chunk unload delay to false (which I haven't tried yet).
     
  21. Offline

    bergerkiller

    I just found something quite...stunning.

    The auto save interval should never be set too high. Why? Well, in the 'saveAllChunks' function, it saves a max of 24 chunks per autosave. If set too high, it will never be able to save all chunks. Either disable it and manually save now and then, or set it at every 10 seconds (200), as it is quite an important thing.

    I will definitely add an async saving routine which saves all chunks in a set interval, where no count is important. After looking at the code, this seems possible, as long I clone the chunk entities and tile entity lists.

    Code:
            for (int j = 0; j < this.chunkList.size(); ++j) {
                Chunk chunk = (Chunk) this.chunkList.get(j);
    
                if (flag && !chunk.r) {
                    this.saveChunkNOP(chunk);
                }
    
                if (chunk.a(flag)) {
                    this.saveChunk(chunk);
                    chunk.q = false;
                    ++i;
                    if (i == 24 && !flag) {
                        return false;
                    }
                }
            }
    EDIT

    Async autosave alive and running very well :)

    Saves the entire world to file each interval, as was the case with the built-in interval.
     
  22. Offline

    ledhead900

    @bergerkiller
    latest version causes Chunk ghosting again lol.

    Well I think it is this but I did not have this issue 2 versions ago, But now when I explore Terrain is gone until I land on it or come closer to it. Does not happen on all maps.

    Tho it is happening on my New World that runs Terrain Control Generator.
     
  23. Offline

    bergerkiller

    @ledhead900 What is that, a chunk generator? And chunk ghosting is more of a client-sided issue, have it myself too. After all chunks are sent this goes away, or if you come near of course. Could also be a Spout issue, since I am using that too.
     
  24. Don't think so, it happens with a vanilla MC client too
     
  25. Offline

    Sepulzera

    Could you provide debugg-messages for each version, including:
    - chunks changes (load, unload, etc)
    - buffered tnts (xx tnts were triggered / were exploded the last 20 ticks)
    - not buffered items / spawned entities?
    - formed stacks with size

    With a setting to enable/disable debugg-msgs...

    Also, you might add some "lag"-messages on demand: /tps to get the tps, /mem to get the current memory usage and /lag (blocklag and so on, if possible)
     
  26. Offline

    bergerkiller

    @Sepulzera but then PTweaks is completely and utterly defeated, I want to leave the only creations of that author to it's value :p
    I already added a tps percentage indicator in SignLink yesterday..just for the fun of it. Not really useful tho.
    How would you want all of this displayed? Because it obviously has to be updated frequently in some sort of organized display. (chat, a separate window or program?)

    @Lathanael I might be able to cope with it in NoLaggChunks, but it's still a bit too glitchy to throw it into the public. It works really well, but has issues when sending out terrain that has just been generated.
     
  27. Offline

    Sepulzera

    server-console/window only, mb every second?
    Should be quite ok for debugg-msgs, but you could also increase it up to 5 or 10 seconds, thought it will lose its informative value with increasing time elapsed.

    Well, currently I'm using "LagMeter" to have an tps and memory usage output, but I think a "NoLagg" plugin should provide such cmds, too :p
     
  28. Offline

    ProjectInfinity

  29. Offline

    ledhead900

    really coz spout did have it until the latest update.

    I turned off async unload chunks and unloadchunks its seems to have become less annoying. Will test further, Oh and dont WE about the myworld request I just swapped to Worldborder and it lets me generate chunks up the to the border and with a padding.
     
  30. Offline

    bergerkiller

    @Sepulzera Ok I'll add some sort of UI-rich message for both console and player output as the end output.
    Will make the interval configurable (in ticks, since it requires to be synced)

    @ProjectInfinity could be, never thought about it really. Even then, when unloading it doesn't create a new instance of the chunk, so that is kinda weird. It stores the leftovers, saves it and discards it.

    @ledhead900 Okay, although async saving did help 'a little' there still is something somewhere causing lag...could even be the fact that I'm looping through the chunks...

    Does Increasing the update interval help? To something like 100? (5 seconds)
    (And have unload delay / async enabled)
     
  31. Offline

    beleg

    :( getting big black holes again.. I dont have spout.
    If im disabling the unload delay and async reload im not getting them.
    I stopped the server and put the plugin in then i started the server again (not pluginmanager this time :D)
     

Share This Page