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

    Reconnect is a very bad way. The entire world is then sent over, again, which means more network stress for the server. Better to let a single chunk get shipped over than to recall the entire load...

    Also, it's not an instant load, so it won't cause lag if someone spams it. You can set the maximum allowed chunk rate in the configuration. There would be no difference if a player is clicking wildly or if the player is exploring a lot.

    Considering adding an 'unsafe' option to send packets async (to allow worldedit to do gradual changes you can watch), but not sure if this is such a good idea...
     
  3. Offline

    MJRamon

    Oh, okay)
    And is there a way to stress down the process of sending the world to a player on connect? My server experience much lag (for 1-3 seconds, which is big) when someone joins the world. and if players begin to logout/login often, the server can go on halt for about a minute and kick everybody with "Read time out" error
     
  4. Offline

    bergerkiller

    I *tried* to disable the native chunk sending code, but if you can't find it, you can't alter it. This means that the regular ring-send-system is still active. (which I don't really like...)

    That said, I still need to test this from another computer. Sending chunks 'extra' can be good, but could cause chunks to be sent twice...
     
  5. Offline

    MJRamon

    Oh, so I can start my server without NoLagg for now and wait for an update tomorrow :)
     
  6. Offline

    bergerkiller

    I'll just upload 1.2 real quick, you can test the feature too then. To disable the chunk 'pre-sending', set the chunkSendRate to 0. You can set it to 20 to update chunks every second, to still have the feature without too much possible lag.

    EDIT

    Updated. Would like some feedback on it, joining your own local server is far from joining another server.
     
  7. Offline

    MJRamon

    Thanks, updated the plugin, set all config to default.
    My goal is: to low down processor calculations. It is Athlon II Dual-Core 3.1 GHz (only one core is used by Bukkit, though... ouh).

    Also there is 1 Gb of RAM (DDR II) for the Bukkit server. It is not enough, I know... Going to buy two planks of 4 Gb of DDR3 1333.

    Testing now :)

    Okeey... Perfomance is a bit higher then without plugin, but... again!

    [​IMG]

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

    Fiddy_percent

    I would just like to say this plugin saved my server! some mod of mine (who was a long time member decided he would randomly spawn 30,000 things of TNT and set it off not knowing what no lag did. Not only did it explode at 20 tnt per second I cleared it all away with ease! THANK YOU SOO MUCH!
     
  9. Offline

    bergerkiller

    @MJRamon did you try right/left clicking while aiming at the void/missing chunks? Because that should at least get rid of them.
     
  10. Offline

    erdrickk

    Plugin is working great so far - Bukkit 1221 with NoLagg 1.2

    Getting this error though...

    Code:
    14:57:53 [SEVERE] Could not pass event PLAYER_MOVE to NoLagg
    java.util.ConcurrentModificationException
    at java.util.HashMap$HashIterator.nextEntry(HashMap.java:810)
    at java.util.HashMap$KeyIterator.next(HashMap.java:845)
    at java.util.AbstractCollection.toArray(AbstractCollection.java:188)
    at com.bergerkiller.bukkit.nolagg.PlayerChunkLoader.updateChunk(PlayerChunkLoader.java:178)
    at com.bergerkiller.bukkit.nolagg.PlayerChunkLoader.update(PlayerChunkLoader.java:70)
    at com.bergerkiller.bukkit.nolagg.ChunkHandler.handleMove(ChunkHandler.java:58)
    at com.bergerkiller.bukkit.nolagg.NLPlayerListener.onPlayerMove(NLPlayerListener.java:30)
    at org.bukkit.plugin.java.JavaPluginLoader$7.execute(JavaPluginLoader.java:286)
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:58)
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:339)
    at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:180)
    at net.minecraft.server.Packet10Flying.a(SourceFile:126)
    at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)
    at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:92)
    at net.minecraft.server.NetworkListenThread.a(SourceFile:108)
    at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:471)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:374)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:417)
     
  11. Offline

    bergerkiller

    @erdrickk thanks, this proves that putting the chunk loader in an ASync task doesn't work. (even though it is pretty much random...)

    Weird thing is that I can't seem to reproduce black holes anymore...quite a pain to know it's not solved, but to me solved...
     
  12. Offline

    erdrickk

    Cool glad I can help! looking forward to 1.21 :p :p
     
  13. Offline

    registered

  14. Offline

    bergerkiller

    @registered I don't really keep backups unless I violently change stuff. What problems are you having?
    You can always disable certain features, these settings only use the tnt handler thingo:
    Code:
    autoSaveInterval: 20
    explosionRate: 40
    chunkUnloadDelay: 0
    formItemStacks: false
    tntDetonationRate: 10
    maxItemsPerChunk: -1
    orbScannerInterval: 200
    updateInterval: 20
    tntDetonationInterval: 1
    chunkSendInterval: -1
    Note that the ChunkUnloadDelay thing is the main cause of missing chunks, you can set it to 0.

    EDIT

    Re-uploaded it (replacing the asynced task by a synced task and one other minor change)
    Once again: to get rid of unloaded chunks, aim at it and click and the chunk will be sent to you. It's an internal Bukkit issue that chunks are not being sent. In a normal server this also happens, but less often because less chunks are loaded. When chunks are kept loaded/alive, this number increases, thus the chance a chunk is not sent to the player.

    I also managed to trigger a load by spawning an item in the chunk...it's odd but it worked. It must have to do with a boolean value on the chunk...would be a lot easier if I'd change that instead.
     
  15. Offline

    L24D

    @bergerkiller
    Not to change the subject, but I was curious...
    Any plans on adding monster/animal limiting, like PerformanceTweaks used to have? :D
    That would be super :p

    Haha anyways, Thanks :p
     
  16. Offline

    Phliz

    1st: @bergerkiller Great plugin.
    2nd: My explosions audio and visual do not work. (tnt, creepers etc...)
    I like everything else about the plugin but what do my configs need to be to maintain the A/V of explosions?


    Found my issue, plugin conflict :p
     
  17. Offline

    Afforess

    I mentioned this earlier, but chunk sending it in EntityPlayer, and mostly, PlayerInstance. PlayerInstance is not a public class, so you will have a difficult time using java to alter what and how it operates.

    Skimming through this thread - a couple points I'd like to make:

    Don't assume async will work unless you get an error. It could work flawlessly for a month only to corrupt your map in a new and completely terrible way. Sending packets async is safe for certain packets, unsafe for others. It really depends on the packets. Block, Teleport, Respawn, and Chunk packets are a few, (but not limited to) those that are UNSAFE for async tasks.

    Also, most collections, like arraylists, linked lists, Hashsets, Hashmaps, etc, do NOT work async. They will throw an exception and fail. Java has special collections designed for the task of multithreading, such as ConcurrentHashMaps which are safe.

    Additionally, the server (unless I'm gravely mistaken) doesn't send ring or spiral chunks. It sends vertical lines of them. Spiraling chunk loading only occurs when Spout is installed (it a feature).

    If you have additional questions, I'm familiar with most of the server and client code. Probably because I have no life. :p

    Gah, double post. :/

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

    mb01

    Same problem, but with Hawkeye.
     
  19. Offline

    CyrussM

    bad english ahead xD :
    Can you add a feature to limit Arrows shot from a dispenser? Or can you limit the Time how long a Arrow will be there after hitting the ground? We make some Indiana Jones Traps with two 8x8 dispenser Blocks. Its a little laggy xD
     
  20. Offline

    bergerkiller

    @L24D this is already included, see the spawnlimits in the configuration. It actually is a lot more powerful than PerformanceTweaks had.

    @CyrussM I don't think it's a good idea to buffer arrows, but I could add them in the spawnlimiting feature. (if it contains a spawn event/event to work from)

    @Afforess Does the Spout netserverhandler allow other plugins to change packets that are sent? I could always cancel those packets and only allow my own, unless you think this interferes too much. Also, what file is the nearby chunk coding located? Packets are being sent in the PlayerInstance using 'dirtyCount?', but haven't found the location of where this function is called.

    Also, I know lists don't work async, I had only put it there to check if it's possible to send chunks while worldedit is busy editing them. Forgot to change it back. :)

    EDIT

    @CyrussM The Arrow entity can be limited (simply limit arrow), but it will NOT be an instant limit. It will remove arrows every updateInterval.
     
  21. Offline

    Afforess

    Yes, Spout provides packet listeners. Implement this interface, and then register the listener for each packet id you want to intercept. You can cancel packets.

    How PlayerInstance actually works is a bit confusing. PlayerInstances are created for each player, and track the chunk that the player is in. Then, depending on the view distance, when the chunk the player is in changes, it sends chunk updates.

    If you want to completely turn off chunks, block the packets and send your own. Keep in mind you will lose the cpu that was spent creating and compressing the packets initially, unless you reuse them.

    To get a much better idea of how player instance works, I'd recommend you grab a copy of the Minecraft Coder Pack (MCP) for 1.8.1, decompile the vanilla server jar, and read the unobfuscated variables.
     
  22. Offline

    bergerkiller

    @Afforess yeah I have seen and altered the MCP source too, helps a lot in understanding the framework hehe.
    You mentioned compression...does this compression occur when creating the packet or when sending the data? Else I'd be better off storing the packets 'to be sent' and send those in-time instead.

    I'll make advanced chunk handling part of Spout then, since I don't really like the idea of sending lots of packets twice. (I DID notice FPS lag as a client while using it)

    Also, perhaps off-topic, but will Spout eventually replace Bukkit? I start to notice lots of shared features, such as custom entities and netserverhandler.
     
  23. Offline

    Afforess

    Chunk packets are created as raw packets with the entire data in them initially, then are passed off to the ChunkCompressionThread to be compressed in a separate thread. They get compressed from 64kb to 1-8kb, then sent out. Actually, it looks like Spout provides a way to intercept the packets pre-compression too, so you could stop them early.

    FPS lag using Spout? Or FPS lag sending packets twice? :/
     
  24. Offline

    bergerkiller

    @Afforess FPS lag sending packets twice. :)
    It's like, you press /reload, and an immense lag appears when NoLagg starts sending all 100 ahead packets to the player.
     
  25. Offline

    Afforess

    Yeah, that's because the pre-chunk packets cause the client to load the chunks up and get them ready to receive data. And the chunk packets are just so huge that they are slow...

    Chunk packets are the number one bottleneck for network traffic in MC. Spout/Spoutcraft uses a custom cache that saves maps in binary format for future use, and syncs up delta changes next time the chunk is loaded (even if it's not the same game session, i.e you come back after a week), and we get a 70% bandwidth reduction. :p

    Now just to fix the entity movement packet spam. :/
     
  26. Offline

    bergerkiller

    @Afforess still can't seem to register the packet listener through the PacketManager. (don't know how to obtain it)
     
  27. Offline

    Afforess

    SpoutManager.getPacketManager().

    SpoutManager is the base manager class, you can get at nearly everything from it.
     
  28. Offline

    bergerkiller

    @Afforess thanks, I was trying to do the same through Spout.getInstance(), my bad. :)
     
  29. Offline

    Afforess

    Yeah, that's there, but not part of the API. We use it internally only. :p

    Oh the joys of a split API/Plugin.
     
  30. Offline

    bergerkiller

    @Afforess on a sidenote...why isn't it possible to use static classes as listeners? For example:
    Code:
    pm.registerEvent(Event.Type.PLAYER_MOVE, PlayerListener.class, this, Priority.Lowest);
    I always declare classes the same anyway, and usually end up adding static members in the player listener to still communicate around. It seems pretty simple, and makes a plugin look a bit tidier IMO.

    In short: why use a constructor and local members, and not static members in a class w/o constructor?

    Code:
    public class NLPlayerListener extends PlayerListener {
    
        @Override
        public static void onPlayerPickupItem(PlayerPickupItemEvent event) {
    
        }
    }
     

Share This Page