Page 2 of 4 FirstFirst 1 2 3 4 LastLast
Results 11 to 20 of 38

Thread: KoLmafia using up lots of CPU

  1. #11
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    4,024

    Default

    I will note that this might be Much Ado About Nothing since I am used to bursts of 20% CPU with associated fan operations on a slightly more powerful machine and consider it normal. That said since there is an assertion that it only started happening recently there may be some code that could be looked at. I will also note that writing Java to implicitly manage GC is not for the faint of heart and migth even be a Fool's Errand.

    Profiling options have changed significantly since the last time I had to do it for real -)

  2. #12
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    4,024

    Default

    I do not know how to use the command prompt to change to the directory with mafia, but I did follow the instructions here to allocate more memory to Java: http://www.messiahpsychoanalyst.org/...ory_in_Windows Unfortunately, it did not solve the issue, as another "/count " made the CPU jump up to 20-30% as usual.
    Originally Posted by Zyro View Post
    That link has -Xmx2048m being changed. If this is a GC problem you should do the same thing but enter -Xms256m (or similar). If my memory is not completely shot -Xmx sets the maximum amount of memory Java is allowed to use. -Xms sets the initial heap size. When Java runs out of memory it will GC and if it still needs some ask for more up to the -Xmx value. So in a primitive way if -Xms is increased the amount of time between calls to GC should increase because there is more memory initially available.
    You just vehemently agreed with me
    Originally Posted by Veracity View Post
    I agree with frono.
    Originally Posted by Veracity View Post

  3. #13

    Default

    That also shows a chat command. Does it only happen after using chat commands (AFAIK anything that starts with / is essentially passed to kol's chat system somehow?), or normall mafia commands (for something that will probably hit the server, try ... hmm ... putting something in your DC? or searchmall? or refresh all?)
    (to be clear: I am now asking if this happens even if you *never* use a chat command in the gCLI)
    Originally Posted by xKiv View Post
    As far as I can tell, typing anything in the gCLI and pressing enter causes the CPU to rise to around 30% and it doesn't go down until I press the Garbage Collect button or restart mafia. I just tested by typing "cast ode" (no / in front of cast) and the same thing occurred.

    That's probably normal. GC is always CPU work. Unless it takes longer than half a second or so.
    Originally Posted by xKiv View Post
    It takes far longer than half a second - I've seen the CPU stay at around 30% for many minutes before I press the GC button to make it go back down. In fact, it's never gone down again by itself in any of these situations.

  4. #14

    Default

    I will note that this might be Much Ado About Nothing since I am used to bursts of 20% CPU with associated fan operations on a slightly more powerful machine and consider it normal.
    Originally Posted by fronobulax View Post
    It is not bursts of high CPU usage - every time this occurs, even with very minimal mafia usage (e.g., typing a single line in the gCLI and hitting enter), it will go up to around 30% and stay there permanently until I manually do something about it.

    EDIT: To add to this, under regular conditions, mafia's CPU usage is usually no higher than 10% for me. I'm running an ascension script right now, and after a short while, the CPU rocketed up to 30+%. I clicked the GC button while the script was still running, and the CPU went back down to below 5%. Several minutes have passed since then, and now it is back up to 30+%. (Cycle repeats...)

    That link has -Xmx2048m being changed. If this is a GC problem you should do the same thing but enter -Xms256m (or similar). If my memory is not completely shot -Xmx sets the maximum amount of memory Java is allowed to use. -Xms sets the initial heap size. When Java runs out of memory it will GC and if it still needs some ask for more up to the -Xmx value. So in a primitive way if -Xms is increased the amount of time between calls to GC should increase because there is more memory initially available.
    Originally Posted by fronobulax View Post
    I just tried that as well, but to no avail. Fwiw, after doing that and restarting mafia, the second number in the GC counter hasn't changed.
    Last edited by Zyro; 04-25-2018 at 06:59 PM.

  5. #15
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    4,024

    Default

    I just tried that as well, but to no avail. Fwiw, after doing that and restarting mafia, the second number in the GC counter hasn't changed.
    Originally Posted by Zyro View Post
    Try with 512m?
    You just vehemently agreed with me
    Originally Posted by Veracity View Post
    I agree with frono.
    Originally Posted by Veracity View Post

  6. #16

    Default

    Try with 512m?
    Originally Posted by fronobulax View Post
    Still no change in the second GC number (it's 253440 KB) and the high CPU issue is still occurring when I run any command in the gCLI

  7. #17

    Default

    What should the first number in the GC counter be relative to the second one?

    Mine usually looks something like this: https://i.imgur.com/YgIf4aH.png (I took this screenshot while it was in "normal" CPU state, not high CPU usage state.)

  8. #18

    Default

    After further testing, it definitely seems like the issue is connected to the gCLI. I can reproduce causing the CPU to spike and then go back down as follows:

    1. Type anything in the gCLI and press enter (e.g., "cast ode")
    2. Perform another action in mafia not using the gCLI (e.g., run a script, automate some turns, or press the GC button)

    Performing step 1 causes the CPU to rise to 20-30% almost instantaneously, and performing step 2 causes it to drop back down to <5% just as fast.

    At this point, I am out of ideas for testing.

  9. #19
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    4,024

    Default

    On my system the second GC number is 3704832KB so it is pretty obvious I am running KoLmafia with more resources than you. I cannot recall seeing the first number ever exceed a tenth of the second. I have some instrumentation in place. I'm not making sense yet. I'm running scripts and all of the hot spots seem to be associated with parsing and executing scripts. There doesn't seem to be a lot of garbage collection going on but that may be me not understanding how much time I am looking at.

    Since your test is pretty specific I will try it at some point and see if I can learn anything.

  10. #20
    Developer
    Join Date
    Apr 2010
    Posts
    4,422

    Default

    Mine is at 1853440 KB, and when idling first number is around 1/10 of that. I can well believe that having only 256 MB allocated is a level easily exceeded and may trigger garbage collection if close.

    Edit - Saw it hit 310 MB when maximizing and equipping that equipment. Was a lot lower when actually running automation.
    Last edited by Darzil; 04-26-2018 at 02:59 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •