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

    Lunar Delta

    I do backups every hour, so I just used MCEdit to paste the whole area back in from a backup. You do keep backups, right?
     
  3. Offline

    beleg

    yes but not every hour :/

    is there a way to just use the backups for the chests inventory?

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

    bergerkiller

    Just revert back to v1.46, it should not have that issue there. (at least, that is what I thought)
    Had to change it because of ghost entities...but the new coding didn't fix that either.

    EDIT

    Ok seriously SCREW Async bukkit tasks. They aren't even async and it's impossible to kill them...
    Time for an async thread.

    EDIT

    Ok that's finally as it has to be. Chunk sending and compression on a single thread, using the remaining time from the chunk sending bit for chunk compression if this is possible.
     
  5. Offline

    Sepulzera

    When disabling useSpawnLimits and useChunkUnloadDelay your plugin will only influence explosions and itemstacks, and leave chunks alone at all?
     
  6. Offline

    bergerkiller

    @Sepulzera yup, but async auto-save still takes place. To disable that, set a save interval < 400.
     
  7. Offline

    thehutch

    Suggestion:
    Limit block spawn/place rate? aka stuff like worldedit make them spawn in intervals of X time? possible? and also for things like 200+ people placing a block all at the same time and also you know when people get that lag when they place a block and it disappears again :(
     
  8. Offline

    bergerkiller

    @thehutch pretty much impossible to fix that. It's very unsafe to get block data from another thread, that is why I detach chunks from the main thread (on the main thread) before saving the data async. The NoLaggChunks addon does buffer out the large block changes, such as huge TNT changes, and sends all the (smaller) changes in one large flow of packets. This doesn't fix tick loss on the main thread of course.

    Also: SQUIIIIDS Y U BE ANNOYING WITH UR GHOSTING D:
     
  9. Offline

    thehutch

    @bergerkiller Can entities spawn on chunks which arent visible by anyone? If so maybe remove them entities until someone can view them removing un-needed entities or would this calculaion slow down TPS more than what the removal of entities would? tbh I'm just thinking of as many ideas as possible to help this plugin :D
    EDIT: What about slower word loading? prevent worlds being loaded as fast a possible when a player changes world or logs on or does this plugin already do this?
     
  10. Offline

    bergerkiller

    @thehutch again, not possible, since all of that is done inside the server, on the main thread. I can't cancel, stop, buffer or delay chunk loads, otherwise I would have done that. However, I can (async?) generate or pre-load chunks around a player, like a peel around the chunk area.

    EDIT

    Wow I never knew it was this simple to enhance performance :confused:
    - Chunk task to a thread: Way smoother chunk sending, and that with compression...
    - Entity/item/mob lists made into task variables: reduced RAM write rate and less tick lag (it seems)
    - Forced chunk unload: no more annoying mobs hanging about. (really..)
     
  11. Offline

    thehutch

    @bergerkiller
    What's better Thread.sleep(x) or bukkits own delay schedular?
     
  12. Offline

    bergerkiller

    @thehutch Bukkits scheduler uses a Thread.sleep in the background, so I decided to do the same to replicate 'tick' rates. This is the new chunk sending code:
    Code:
            mainthread = new Thread() {
                public void run() {
                    long time;
                    while (enabled && !this.isInterrupted()) {
                        try {
                            time = System.currentTimeMillis();
                            //======================================
                            synchronized (buffers) {
                                for (PlayerChunkBuffer buffer : buffers.values()) {
                                    buffer.sendNext();
                                }
                            }
                            //======================================
                            //use remaining time for compression - sync to a duration of 50ms
                            //use a buffer of 10 ms
                            while (System.currentTimeMillis() - time <= 40 && Compression.execute());
                            //sleep for the remaining time
                            time = 50 - (System.currentTimeMillis() - time);
                            if (time < 10) time = 10;
                            Thread.sleep(time);
                        } catch (InterruptedException ex) {
                        } catch (Exception ex) {
                            if (enabled) {
                                NoLaggChunks.log(Level.SEVERE, "Failed to perform routine chunk processing:");
                                ex.printStackTrace();
                            }
                        }
                    }
                }
            };
            mainthread.start();
    And I've had it, I'll just send entity destroy packets to all nearby clients -.-
     
  13. This plugin have got a problem.
    This is the problem when i write in a sing and i reload the server all sing i write are clear without words this was the last 3 updates this is good:
    v1.44
     
  14. Offline

    bergerkiller

    @vicente947 I know, is already fixed in the next version I'm making right now (1.48)
    Could even be the chunk 'restore' feature though, I'll check it to be sure.
     
  15. Offline

    Lice

    With me now affects some chunks. The signs have not written more. And chest are all empty!
    Is there a fix?
     
  16. Offline

    bergerkiller

    Fix is comin'...just so you know it isn't as simple as it seems...
    Code:
        @SuppressWarnings("rawtypes")
        public static void unload(Chunk chunk) {
            if (!chunk.isLoaded()) {
                chunks.remove(chunk);
                return;
            }
            try {
                try {
                    if (AsyncSaving.enabled) {
                        net.minecraft.server.Chunk c = getNative(chunk);
                        //send death packets to ensure no ghost mobs stay behind
                        for (int i = 0; i < c.entitySlices.length; i++) {
                            Iterator iterator = c.entitySlices[i].iterator();
                            while (iterator.hasNext()) {
                                Entity e = (Entity) iterator.next();
    
                            }
                        }
                        c.removeEntities();
                        chunk.unload(false, false);
                        AsyncSaving.scheduleSave(c);
                        return;
                    }
                } catch (Exception ex) {}
                chunk.unload();
            } catch (Exception ex) {
                NoLagg.log(Level.WARNING, "Failed to unload chunk " + toString(chunk) + ":");
                ex.printStackTrace();
            }
        }
    
        /**
         * This clones the chunk, breaking it loose from the original
         * Do NOT use this method in async methods!
         * Use the cloned version only for async saving, as it is partly dereferenced
         * @param chunk
         * @return
         */
        @SuppressWarnings("unchecked")
        public static net.minecraft.server.Chunk cloneChunk(net.minecraft.server.Chunk chunk) {
            try {
                net.minecraft.server.Chunk newc = new net.minecraft.server.Chunk(chunk.world, chunk.x, chunk.z);
                newc.bukkitChunk = null;
                if (!transferData(chunk, newc)) return null;
                for (int i = 0; i < newc.entitySlices.length; i++) {
                    newc.entitySlices[i].addAll(chunk.entitySlices[i]);
                }
                newc.tileEntities.putAll(chunk.tileEntities);
                return newc;
            } catch (Throwable t) {
                t.printStackTrace();
                return null;
            }
        }
    
        public static boolean transferData(net.minecraft.server.Chunk from, net.minecraft.server.Chunk to) {
            try {
                to.b = from.b;
                to.g = from.g;
                to.h = from.h;
                to.i = from.i;
                to.heightMap = from.heightMap;
                to.done = from.done;
                return true;
            } catch (Throwable t) {
                t.printStackTrace();
                return false;
            }
        }
     
    thehutch likes this.
  17. Offline

    thehutch

  18. Offline

    Lice

    Will it be possible then all the boxes again true as it was before?
    Or not to repair the damage? And the signs?
     
  19. Offline

    bergerkiller

    @Lice Afraid it's not possible to restore it, since the data that was attached to it is gone.

    EDIT

    Ok sign/furnace/chest wipe issue seems fixed now, after leaving the game and waiting out the unload delay the sign doesn't lose it's text. Stopping and saving or waiting auto-save also seems to safe.

    EDIT

    Aaaah this is a lot better. Somehow managed to fix chunk load tick drop as well...no idea how.

    I'll update 1.48 while it's safe.
     
  20. Thanks for all and chest clear.
    This is essencial plugin. :)
     
  21. Offline

    bergerkiller

    Ok uploaded. Removed 1.47 to be sure no one ever gets this wiping issue again.
     
    thehutch likes this.
  22. Offline

    bergerkiller

    Expect a re-upload in a few minutes, the onChunkPopulate is causing a 'deadlock': it has to wait for the other thread to finish the (long) process of generating lighting. This causes a severe tick drop.
     
  23. Offline

    Fr0zenfr0g

    ok, you are the best!
     
  24. Offline

    Eminam

    How soon is "a few minutes". The reason I ask is I have 1.48 in right now, just haven't restarted yet lol. So I'm waiting for the reupload of the plugin before I restart lol >.<
     
  25. Offline

    bergerkiller

    @Eminam that's fine, but it might take a bit longer. It's pretty hard to keep two separate lists (chunks in -> chunks buffer) to allow full use of the (multi-threading allowed) list.
     
  26. Offline

    Eminam

    @bergerkiller It's no biggy, was just trying to get a general idea of an ETA is all. No rush.
     
  27. Offline

    bergerkiller

    v1.48 does work tho, but will cause pretty heavy tick drop when exploring new areas. (when chunks are generated)
     
  28. Offline

    rbos

    I have updated to 1.48, but emptied chests have not been restored, nor signs. Is that data gone entirely?

    Worldedit //restore does not appear to work to restore the chests. - Never mind, I think the chests I was testing on were just empty.
     
  29. Offline

    Eminam

    @rbos I THINK in a post earlier. He stated that the stuff was permanently gone and can not be recovered. I MAY be wrong but, I believe the stuff is permanently gone.
     
  30. Offline

    bergerkiller

    @Eminam yeah it's permanently gone :/
     

Share This Page