CPU spike when Chatting(FOUND WORKAROUND)

Discussion in 'Plugin Development' started by habbcraw, Aug 1, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    habbcraw

    So i've been trying to reduce lag on my server since it after a few hours with 4-11 players on start lagging. So I started chekin my two cores and saw that on every chat message the second core would rise with about 40% in that second. I've tried deactiviating all my chatrelated plugins but didn't seem to make a difference. I also tried if a single message directed to me would cause it which it didn't. So I cam to the conclusion that this lag is created when a message is broadcasted to everyone. Have anyone else experienced this? Is there a solution? Is there a bug in craftbukkit?

    Btw the core Went from 7%-55% in a split second every chat message.
     
  2. habbcraw I can only assume it's a plugin issue. What plugins do you have installed? (Maybe this is the thing that those people go on about; not to use methods that affect the server in the Async thread)
     
    Nick000 likes this.
  3. Offline

    habbcraw

    DJSkepter
    I use my selfmade plugins can you explain more about the Async thread? I got into threads this year. But Im using AsyncSchedulers for toher services like when editing databases but that cant be connected to the chat?
     
  4. habbcraw Well, I believe desht knows more (either him or that fireblast guy) but:
    The chat event is Asynchronous and placing blocks etc. or 'interacting with the Minecraft world' should not be done via an Asynchronous thread. To counter this, if you required to place blocks etc. you would have to run it in a Synchronous thread or something along the lines of that.
     
  5. Offline

    habbcraw

    DJSkepter Yeah ofc I know that but I 97% percent sure nothing of my AsyncSchedules are affecting the chat. Though when I Think about it I found that in one I send a message in Async but how come those messages that aren't form Async lagg? And btw it seems only broadscasted messages create this problem. It seems sending message in Async doesn't do anthing but broadcasted ones does. But how man usual messages from players cause cpu spikes to?

    Also I read that sending messages in async doesn't create any errors or something..?
     
  6. Offline

    mythbusterma

    habbcraw
    Why don't you post the code so we know what you're talking about.
     
  7. Offline

    habbcraw

    mythbusterma Well it's kind of a big plugin connected to many others too much code to post. But could it be that one broadcast in async affect the chat to cuase CPU spike?
     
  8. Offline

    MBon29

    habbcraw Unless this is a plugin you made, then this post is in the wrong section.
     
  9. Offline

    mythbusterma

    habbcraw

    The only code that is pertinent is the code that is called during PlayerChatEvent, AsyncPlayerChatEvent, and anywhere where Bukkit.broadcast() is called repeatedly.
     
  10. Offline

    Necrodoom

    habbcraw follow elimination process, disable plugins one by one till you found the problematic plugin.
     
  11. Offline

    habbcraw

    MBon29 Im talking about my plugin.
    mythbusterma Yeah I thought so.
    Necrodoom Yeah I tried eliminating every Chatevent in every plugin.. still nothing.... Might time to try disabling whole plugins but don't wanna affect the players and can't check it localhost since other procces would affect it.
     
  12. Offline

    Necrodoom

    habbcraw without properly following process of elimination we can't say where exactly the problem is originating from.
     
  13. Offline

    habbcraw

    Necrodoom I'll try soon and return here with the response

    Necrodoom mythbusterma MBon29 DJSkepter Ok so I tried every plugin in order and even without a single plugin this kept going meesages caused from 7-50% or more. This must be craftbukkit? I Think im running on craftbukkit 1.7.9_r-0.2 or 0.1 something

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

    Necrodoom

  15. Offline

    habbcraw

    I wrote wrong 1.7.9 beta build. Necrodoom
     
  16. habbcraw I strongly doubt it would be a craftbukkit issue (I could be wrong however).
     
  17. Offline

    xTigerRebornx

    DJSkepter He still has yet to provide any code.
    habbcraw Are you listening to the PlayerChatEvent anywhere? (not the AsyncPlayerChatEvent)
     
  18. Offline

    habbcraw

    DJSkepter well I had that in mind too that it could infact be my server but I don't see why chatmessages would cause my server to go nuts.

    xTigerRebornx As I said in the other post I removed every plugin and I still had the issue.

    Wait could it be that all my plugins are based on Bukkit R-0.1?

    EDIT: Sry it can't be since i tried without any plugins and still had the issue...​

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

    MBon29

    Most likely. Why would you be building from a version that old?
     
  20. Offline

    mythbusterma

    habbcraw

    You were running your server with 0 plugins and still had this issue? What version of CraftBukkit is your server running, and what are the specs of said server?
     
  21. Offline

    habbcraw

    @MrBon29 Sry again I forget to type Bukkit 1.7.9 R0.1
    mythbusterma You'll probably say the server is the problem since the specs aren't to good but I've had no problem with this within 2 years and back then I had 1 CPU with 2.2 GHz 2G RAM. Now I have 1 CPU 2.3 GHz with two cores and 6G RAM though RAM isn't the problem. The stange thing is this didn't show up half last month from what I could see could be wrong though.
     
  22. Offline

    _LB

    The issue is not actually an issue at all. What's really happening is that Bukkit is mostly single-threaded, so the second core hardly gets used at all. The very small amount of processing for chat events that happens in the second thread uses up all of the second core because, well, there's nothing else to use the second core. So, this is not an issue, just a quirk of the way your core visualizer displays core usage.
     
  23. Offline

    habbcraw

    Actually I have developed my plugins to use the second core as much as possible and they're pretty even when I check it ;) _LB

    I found a workaround since I found that the logger messages caused the CPU to spike im not sure why though.. But I have made my own ChatPlugin two weeks ago which I now optimzed to not send into the logger which made it go away. The problem is that other messages like errors goes to the logger and causes this so I gotta make my own broadcast function to not let any messages get to the console. This was also why reloads were very laggy after a while.
    But I don't get why logger messages in the console would create this....? Any thoughts..

    For others having this problem Im gonna upload my ChatPlugin in a day or two so you can reduce your lag if you experience this to.
     
  24. Offline

    _LB

    How large is your console window's history buffer?
     
  25. Offline

    habbcraw

    What it seems from my view I can sometimes see history from last server restart but mostly I usually just get to see like the 20 last console messages from minecraft. Im gonna look into this since I sometimes use "screen" to be able to reconnect which might be causing this?

    _LB

    Anyone know a way of fixing this log problem?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  26. Offline

    fireblast709

    lol
    habbcraw Let's start by posting the logging code ;)
     
    DJSkepter and ZodiacTheories like this.
  27. Offline

    habbcraw

    fireblast709 Ok maybe I didn't explain myself clearly... There is no problem with the code since this bug still exist when I use no plugins which means it's probably something with the history buffer as someone mentioned but unfortunately I don't know how to fix that so I tried removing as man logger message as possible which made it better but it's not enough since commands are typed into the logger. Either I must find a solution to filter the logger which didn't work for me or a solution to fix something with the logger history which Im not very sure on how to do..
     
  28. Offline

    fireblast709

    I meant this logger. Which one is this. (Even if you don't know, showing some of the fixes might help finding the logger that is supposed to lag)
     
  29. Offline

    habbcraw

    fireblast709 Im talking about the logger you can use to print out messages in console "getLogger()" but every message that goes there like commands issues needs to be rmeoved which seems to be impossible.
     
  30. Offline

    fireblast709

    habbcraw which logger are you using? (Which getLogger()?)
     
Thread Status:
Not open for further replies.

Share This Page