Bug - Fixed mafia running very slowly while farming.

fronobulax

Developer
Staff member
Logged on and vamped out:
36,697 KB / 253,440 KB

Had breakfast, squished squishables, and did the BHH.
53,797 KB / 253,440 KB

Farming for 13 adventures: Chat has already slowed drastically, pauses are still short
46,694 KB / 253,440 KB

80 adventures, pauses are about 3 seconds each.
50,731 KB (Spikes up to 66,000) / 253,440

130 adventures, pauses are about 5 seconds each.
54,549 KB (spies up to 72,000) / 253,440

Stopped automation and clicked "collect garbage"
Reclaimed 27504 KB of memory

Resumed automation:
First adventure, the pauses are still about 5 seconds each.
49,486 KB (spiking up to about 67,000)/ 253,440 KB

Any of that help at all?

Yes. Thank you. That suggests that my hypothesis of a memory leak is not viable :-(

Windows, right? Start the Task Manager. If you are on Vista or 7, Show Processes for All Users. Look at the Performance tab and see if the amount of Free Physical Memory seems low when running mafia and observing problems, compared to not running mafia. Look at the Processes tab, sort on memory and see if any process is using xxx,xxx K or more. I would expect that javaw.exe (or equivalent) will do so but if anything else is that might point us in a direction. svchost, for example can get bloated to the point of slowing the system down.

I'm basically stumped.
 

fronobulax

Developer
Staff member
I just thought that I should point out that that feature also exists in XP, but that may not have been your point :)

You're right. It is a checkbox if you are logged into XP as an Administrator (which I always am) and triggers a user access control prompt on Vista and 7 because I don't normally run as an Administrator. Thus I remembered the intrusiveness of asking to monitor all processes on the newer systems and that it was an extra step.
 

nworbetan

Member
*wait 5 seconds*
You win the fight!
*wait 10 seconds*
You gain an item: Lunar isotope
*wait 10 seconds*
You gain an item: Lunar isotope
*wait 10 seconds*
You gain an item: Lunar isotope
---
Then the next adventure starts.

I've seen this exact thing happen a couple times before, and I remember thinking that the isotope drops slowing down was actually getting worse the more adventures I spent farming them. So if you're trying to re-produce this, my humble suggestion is to load up on +item%, set your CCS to sniff alielephants, and go afk long enough to burn a good chunk of your daily adventures.
 

Mystia

Member
I've ascended twice, and gone back to farming isotopes, now using two spectre scepters instead of one spices, and the lag hasn't come back yet.

Perhaps it had something to do with the time I spent in aftercore? (I was level 52 when the lag was happening)
 

slyz

Developer
I tried to reproduce this, but I haven't exactly managed it. I only had a barely noticeable pause between each item drop.

I added just a little bit of output in ConcoctionDatabase.refreshConcoctions().
Code:
Request 117 of 120 (Spaaace: The Domed City of Grimacia) in progress...

[1715] The Domed City of Grimacia
Encounter: alielf
Strategy: D:\dloads\KoLMafia\ccs\generator.ccs [alielf]
Round 0: slyz wins initiative!
Round 1: slyz executes a macro!
Round 1: slyz casts ENTANGLING NOODLES!
Round 2: slyz casts STRINGOZZI SERPENT!
Round 3: alielf takes 82 damage.
Round 3: alielf takes 41 damage.
Round 3: slyz casts STRINGOZZI SERPENT!
Round 4: alielf takes 82 damage.
Round 4: alielf takes 41 damage.
Round 4: slyz wins the fight!
After Battle: Boule does a couple of karate moves, then swivels his hips and gyrates his pelvis.
You acquire an item: lunar isotope
Refreshing concoctions...
Concoctions refreshed.
Refreshing concoctions...
Concoctions refreshed.
You acquire an item: lunar isotope
Refreshing concoctions...
Concoctions refreshed.
Refreshing concoctions...
Concoctions refreshed.
You acquire an item: elven medi-pack
You gain 12 Beefiness
You gain 20 Enchantedness
You gain 13 Sarcasm
If I set autoSatisfyWithCoinmasters to false, the second concoction refresh doesn't happen.

Since the pause Mystia was reporting happened between each item drop, I'm going to assume that the problem is indeed caused by ConcoctionDatabase.refreshConcoctions().

I'll try to figure out how ConcoctionDatabase.deferRefresh() works, so that concoctions are refreshed only once after each fight. That might help a little bit.

When refreshing concoctions after acquiring/loosing a specific item, maybe we could refresh only the concoctions affected by the ingredient, instead of refreshing everything? It shouldn't be too difficult to add a concoctionsByIngredient map in ConcoctionDatabase, and create a ConcoctionDatabase.refreshConcoctions( ingredient ) function.
 
Last edited:

Mystia

Member
I've managed to reproduce the bug again.
I'm up to level 26, completed the nemesis quest, and and the no-pausing I was experiencing before has ceased.
Would a video of the CLI help?
 

holatuwol

Developer
No, I think slyz has pinned it down to constant refreshing of concoctions, which only causes problems if you have a large pool of items. There's a workaround that we can put into place that only refreshes the concoctions if there are no queued requests (since updating that list while requests are running is a little overkill), but if anyone thinks of a better solution before the weekend when I'm able to commit code, I'm welcome to ideas.
 

holatuwol

Developer
Okay, I've committed some changes in r9889 and r9890. I'm wary of the r9889 changes since right now I'm stuck on Java 7 on my development machine and I can't actually test beyond seeing if they compile (I'm going by gut instinct ... we all know how well that usually goes), so please let me know if anything breaks or if this speeds up program execution for you.
 

roippi

Developer
No more information was provided to hola after he asked for it, so we'll assume this was fixed by his commits.
 
Top