Mafia running 120352 kb.... lag city

Theraze

Active member
Okay... for curiosity's sake... how do you end up using 109.2% of your CPU? That must be a Mac feature, but probably explains how it managed to lock you up... :D

Moving on from the morbid curiosity to slightly more useful curiosity. :) Do you have the same before and after battle scripts on the main/alt? Same counter checker, same recovery scripts? Moods... same or different? SOMEthing you've got in there is going nuts on the processor (memory is a red herring... it's your processor that's making you lag, since it's overextending beyond capacity), and if we can figure out what's different, that might help us isolate your problem...
 
First, you must be a nerd shut-in. Any high school coach will tell you to give 110% out on "the field" so my mac isn't really tapped out yet ;) on a serious note, I have no freaking clue how 109% is possible, that's just retarded. I would like to turn off all countercheckers and everything not needed. All I do with my multi is let him hang out in the castle and level up for world events, and my main only uses BCC ascend... like ALL the time. I speed ascend back to back to back (except this stupid ass level 30 AOB crap. BCC has never given me a problem (except for the new temple quest) so any other scripts are useless to me, also I couldn't ever really figure out how to set up the Bale recovery script so that about killed my want for anything besides the ascension script :(
 

Veracity

Developer
Staff member
Okay... for curiosity's sake... how do you end up using 109.2% of your CPU? That must be a Mac feature, but probably explains how it managed to lock you up...
I have no freaking clue how 109% is possible, that's just retarded.
Your processor has more than one CPU. A multi-threaded program like KoLmafia can run on more than one CPU at the same time. Obviously you can't use mre than 100% of a single CPU, but if you have a 2-CPU system. you effectively have 200% of a single-CPU available and the performance tool reflects that.

Both Theraze's comment that that it "must be a Mac feature [that] probably explains how it managed to lock you up" and i_eat_food's comment that it was "just retarded" looked like proud displays of ignorance.

I am not impressed.
 

Theraze

Active member
No, that really is a mac thing... on a PC, the percentage shown is based on your total. If you have a dual-core hyper-threaded processor, and mafia's instance of java's affinity is set to a single CPU out of the 4 available then its max CPU usage will be 25% not 100%. CPU usage, in Windows Task Manager, will never go above 100%.
I wasn't saying that it locked him up BECAUSE it was a mac feature, but that it locked him up because the CPU usage pegged. Anytime I'm fixing a computer and see CPU maxed out, that means the computer overextended itself, generally because the user requested something weird, like trying to use a PDF printer and cancelling out the location to save the file to, causing it to try to save the file forever and using up 99-100% of the CPU until you manage to [very very very slowly] delete the printer entirely.
As i_eat_food had referred to memory usage causing his problems, but the screenshots clearly show that the actual issue is the CPU usage, I was directing us further towards what Catch_22 had picked up on i_e_f referring to in post 9.

Moving back to the non-OS variance issues. :) Apparently you've got SOMEthing screwy and/or different on your multi, so let's start checking those script bits. Check and post results of this on both characters?
get afterAdventureScript
get betweenBattleScript
get buyScript
get counterScript
get recoveryScript
 
Last edited:

me259259

Member
Do you have the same before and after battle scripts on the main/alt? Same counter checker, same recovery scripts? Moods... same or different?

What scripts do you use i_eat_food? If you have made your own scripts, maybe you're doing something wonky that's eating up a lot of memory.

Then again, just looking at your memory numbers...

file-33.jpg

124MB of memory isn't a lot for a program to use, especially for a computer that is less than a year old. Heck, I jump up to 155MB after my login script runs, and that's tiny compared to everything else I run. How much memory do you have on that computer? What else are you running when you run mafia? If this isn't happening on your main, what is the max memory mafia can use there? If it's higher, then we should focus on why the memory limit isn't the same for both.
 
Last edited:

me259259

Member
The screenshots show that those values are the same.

D'oh! That's what I get for posting before getting my caffeine fix for the day... In that case, we should focus on what specific scripts are running. Even so though, 126MB max seems low, my mafia memory limit on my laptop from 7 years ago went up to 150MB.

What do you use to eat? A script, or do you pick the foods yourself?
 
Last edited:

Theraze

Active member
Except that it didn't. 109% out of 200% is not "pegged".

A single thread can't use more than one CPU at a time, right? So if a single thread is maxing its processor, the fact that additional processors are available for other threads/programs just means that your system keeps running, but mafia will be slow until the first thread finishes working.

This is based on my understanding of single v. multithreaded apps. Maybe that's off, but... if one of i_eat_food's 35 threads in the multi is maxing his CPU (for that thread), that would lag mafia until whatever process that thread was doing completed. Or is that totally misunderstanding the way multithreading works?
 

Veracity

Developer
Staff member
So if a single thread is maxing its processor, the fact that additional processors are available for other threads/programs just means that your system keeps running, but mafia will be slow until the first thread finishes working.
I guess. However we don't have enough information to say "one thread is using 100% of a cpu and the other 34 threads are using a total of 9% of another CPU".
 

roippi

Developer
You can use the -Xms flag to increase the java heap size, which would likely fix your performance issue. That's rather a bandaid though, you've got a rogue script misbehaving that you should address.
 

xKiv

Active member
Actually, you should use -Xmx for that. -Xms increases the initial heap size, -Xmx increases maximum heap size.
1) if you increase initial heap size without maximal size, your java will eventually refuse to run (Incompatible minimum and maximum heap sizes specified)
2) -Xms will affect speed only until allocated memory peaks (java will automatically allocate more memory when it thinks it will need more soon (another configurable twiddly bit), and that stops everything for a while to let java set up everything properly with the newly larger heap)
3) this is how I run mafia:
java -Xms512M -Xmx512M -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -server -jar $(ls -1 KoLmafia*.jar | sort -t- -k2 -n | tail -n 1)
(that bit at the end picks out the latest mafia jar in the current directory)
The garbage-collector printouts give me a nice benchmark on how long it takes to get somewhere.
 
I only run bumcheek asc. and the only thing it does for breakfast it summon pasta and what-not. I feed my multi and main both by hand. I'll get those screenshots up tonight after dinner :)
 

Theraze

Active member
Feeding and those shouldn't matter... we're looking for something that gets lost in the background and stays there. Probably. :)
 
So I need screenshots of these right? Ok, how do I get these to pull/show up? I'm going to screw with it myself in the mean time but if I get a response before on here I'll take the advice ;)




get afterAdventureScript



get betweenBattleScript



get buyScript



get counterScript



get recoveryScript
 

lostcalpolydude

Developer
Staff member
You need to copy each of those into the CLI, one at a time, and press enter. Then copy-paste the response that shows up.
 

me259259

Member
Feeding and those shouldn't matter... we're looking for something that gets lost in the background and stays there. Probably. :)

Eh, it was a hunch. I saw that in the previous screenshots, the one that was having a problem had eaten, and the one that was fine had not. If he used a script to eat, I was hoping that was the thing causing memory issues.
 

Catch-22

Active member
Also, I have no idea what Java is :confused:

Java is a software platform that KoLmafia depends on. Whilst I commend the efforts of Theraze and others in getting your issues resolved, I'd still strongly suggest you update Java. I'm not sure what version of OS X you are running, but here's a link for the latest Java for Mac OS X 10.6.
 

DoubleFloat

New member
I have to somehow "reopen" this thread as I'm currently also encountering massive RAM and CPU usage while using release 13330.
Right now, according to task-manager, it's using 60% of my CPU and about 1.5GB of RAM. In addition to this the GUI is somehow unresponsive, which I suppose is the result of the resource usage.

I'm not running any scripts apart from Bumcheek's snapshot script, but I didn't even ran that today.
Any ideas on this?
 
Top