Wisling / tibiaauto

Tibia Auto is made to excel in the automation of various aspects of the playing the MMORPG Tibia
31 stars 17 forks source link

Memory reading optimizations #20

Closed dmarszk closed 8 years ago

dmarszk commented 8 years ago

Identified two main bottlenecks:

Wisling commented 8 years ago

Oh my, you're tackling this?! Good on you. I've just left it as is and allow the pointer creation to be in one thread and the deletion to be in another 'cause changing it is a lot of work :p I may help you out though as it will be better this way. If it helps at all, the first byte of name is 0 for an uninitialized CTibiaCharacter.

dmarszk commented 8 years ago

Yeah it struck me that profiling have shown about 40% of the CPU time being spend in memory read functions during map research. I'm still figuring out the best way to optimize it.

felipetnh commented 8 years ago

This looks nice. By how much percentage is this going to improve TA? :D

dmarszk commented 8 years ago

Well, if it ever gets to an optimal implementation - it should cut CPU usage between 30% and half.

felipetnh commented 8 years ago

Wow... That would be awesome! :D

dmarszk commented 8 years ago

RFC. I applied some fixes regarding the aferomentioned issues. I tried to do it as simple as possible.

dmarszk commented 8 years ago

Roughly... I believe it will make at least 90% less ReadProcessMemory calls. It's possible that there's a more optimal MEMORY_CACHE_ENTRY_SIZE value. Of course the whole bunch of scanning algorithms are broken by design in this case and could be done better, but it's the simplest way to speed them up.