CPU freq.

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)

Moderators: lisa, rock5

Message
Author
User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: CPU freq.

#21 Post by beanybabe » Sun Aug 02, 2015 2:14 pm

I upgraded everything on pc today also found some bugs with Kaspersky online scanner. I am going to try it back to default and see if it works again.

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: CPU freq.

#22 Post by beanybabe » Thu Aug 20, 2015 1:52 am

I am still convinced there is something off in the timing. When some errors happen if I add prints to try to catch them they stop. The prints add enough delay to stop the error it seems. Many errors start to happen during increasing user activity.

its like following bread crumbs with a steam roller all I get is more crumbs.

User avatar
Administrator
Site Admin
Posts: 4865
Joined: Sat Jan 05, 2008 4:21 pm

Re: CPU freq.

#23 Post by Administrator » Thu Aug 20, 2015 10:26 am

You could try increasing the number of attempts that it will try to read the memory, or insert a small delay in between them.

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: CPU freq.

#24 Post by beanybabe » Thu Aug 20, 2015 1:22 pm

I tried the attempts but the memory the values always print as the same. When I add prints to see the values it seems to work ok. Its just a feeling I get since there seems to be no way to test what is going on I have found yet. These memory problems in rom create so many errors it takes some magic to know what is real.

Some code seems to cause some errors i'm still trying to narrow down which. I noticed this on nearly identical wp.

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: CPU freq.

#25 Post by beanybabe » Sat Aug 29, 2015 5:02 pm

Still having problems with this. I have another multicore cpu and rombot is saying the cpu is almost 9ghz with its foumula i had to change the devisor to nearly 4000 to get the bot not to crash. Here is how I changed the rombot to make it easier to fix. I hope someone can figure a way to auto calc the correct number for local FreqAdj
With one cpu I have to lower it to 980 with another I have to change it to 3780 they are both same cpu but different revisions. if i get the freq to show the same as what windows reports it seems to run ok.

Code: Select all

ReportedCpuFreq =                        --  put your windows cpu freq that shows on computer  here in mhz  eg 3000  for 3ghs   1 ghz = 1000 mhz
 FreqAdj = ReportedCpuFreq /getTimerFrequency().low
   if( getTimerFrequency ) then
      -- Grab the real frequency instead of calculating it, if available
      bot.GetTimeFrequency = getTimerFrequency().low / FreqAdj;
   else
      -- calculate the CPU Frequency / used for manipulation the GetTime() values
      local calc_start = getTime();
      yrest(FreqAdj);
      local calc_end = getTime();
      bot.GetTimeFrequency = (calc_end.low - calc_start.low) / FreqAdj;
   end
Here is some info it may help, its a little over my head. http://tdistler.com/2010/06/27/high-per ... ux-windows
On Windows, QueryPerformanceFrequency() and QueryPerformanceCounter() are the obvious choice. QueryPerformanceFrequency() returns (surprise!) the frequency of the counter. QueryPerformanceCounter() returns the current value of the counter. Just like CLOCK_MONOTONIC on Linux, the Windows performance counter is a high-frequency, stable, monotonically-increasing counter.

The methods are defined in windows.h. The prototypes are:

BOOL QueryPerformanceFrequency(LARGE_INTEGER *lpFrequency);
BOOL QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount);

Windows Timing Errata

Note: The follow items do NOT affect the resolution of the Window’s performance counter, but I think it’s still important to know when doing timing on Windows.

One problem you may run into on Windows is that the default system clock interval defaults to 10 or 15ms (depending of the OS version). This clock is what drives all the timers and sleep functions for that platform. What this means is that, left to the default, your timers will trigger 5 to 7.5ms late, on average.

You can fix this by increasing the system clock resolution to 2ms (I remember reading a tech article by Microsoft saying that 2ms gave better system performance than 1ms, but I can’t find it for the life of me). You do this by using the timeGetDevCaps(), timeBeginPeriod() and timeEndPeriod(). Sample code can be found HERE. You have to include mmsystem.h and link against Winmm.lib.

I feel it necessary to note that increasing the system clock interval negatively affects power consumption. The Windows 7 blog as an interesting breakdown of “Windows 7 Energy Efficiency”. Specifically, they noticed a 10% drop in battery life when the clock resolution was set to 1ms using timeBeginPeriod().

User avatar
Administrator
Site Admin
Posts: 4865
Joined: Sat Jan 05, 2008 4:21 pm

Re: CPU freq.

#26 Post by Administrator » Sun Aug 30, 2015 12:15 pm

Code: Select all

bot.GetTimeFrequency = getTimerFrequency().low / 1000;
I think the issue here could be related to integer overflow. Returning just the 'low' part is only giving the latter-half (last 4 bytes) of a 64-bit integer (8 bytes). While the 'high' and 'low' are exposed, they probably shouldn't be used and manipulated directly like that.

But, this in itself does not cause an issue. The calculated frequency is then put to use here:

Code: Select all

			skill.LastCastTime.low = skill.LastCastTime.low + casttime*1000 * bot.GetTimeFrequency;
Instead of using things like the frequency (unstable), we should instead be working off of time (mostly stable, until you get into quantum mechanics, which is way beyond the scope of this topic and, as such, I'll leave as a discussion for another day.). This is why MM2 is taking a totally different approach to timing.

Anyways, I think that the combination of these calculations on 64-bit integers (tables, that is) may result in attempting to use the skill too quickly under certain circumstances. Perhaps the 64-bit 'now' just rolls over, leaving a negative value for the difference between times, leading to attempting to read the memory immediately after writing? Perhaps adding the skill cast time into the 'low' part is overflowing, and when we insert it back we are not compensating by adding the overflow into the 'high' part. Something along those lines.

MM1 does have an __add metamethod on the int64 tables. This means we should be able to have them used as 'normal' numbers like so:

Code: Select all

skill.LastCastTime = skill.LastCastTime + (casttime*1000 * bot.GetTimeFrequency);
Fixing these sorts of calculations should (in theory) resolve the problem you are facing. That is, if my assumption that it stems from improperly manipulating a 64-bit integer is correct. For your convenience, the files/lines that would need to be modified are as follows:
  • player.lua:887
  • player.lua:917

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: CPU freq.

#27 Post by beanybabe » Sun Aug 30, 2015 7:13 pm

I do not quite understand it other than trying to read those articles i posted. I just noticed the problem when some people said it worked ok and they had older pcs it runs ok on my single core pc but as I went to quad then eight core cpus the problem got worse. Altering those numbers and it runs better but still is not perfect. When there is lag during peak net traffic it can still crash latency seems to affect it.
I'm not very up on programming these new cpus as I leaned on the early ones and timing was simple then. I just was trying to point you in some direction that might help or at least help others with same problem. After changing the number on my test machines they both can run for quite a while. Now it just crashes is at portals or re-logging. There may be some timing problem in those areas of code.

User avatar
Administrator
Site Admin
Posts: 4865
Joined: Sat Jan 05, 2008 4:21 pm

Re: CPU freq.

#28 Post by Administrator » Sun Aug 30, 2015 7:57 pm

Did you make the proposed change that I had posted at those two lines or not? I'm not sure what to make of your response.

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: CPU freq.

#29 Post by beanybabe » Mon Aug 31, 2015 1:20 am

oh ill give that a go. i missed what said It seemed like you were explaining what might be happening as it was very like what was said in this person page http://tdistler.com/2010/06/27/high-per ... ux-windows talked about ways to fix the timing problems in games. I got lost reading about half way down.

Reading it a second time I now notice the line numbers.

I edited my test machine it is the one that crashes the worst. Restored the original 1000 back in bot.lua also. I will give that a try. :geek:
Last edited by beanybabe on Mon Aug 31, 2015 3:12 am, edited 1 time in total.

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: CPU freq.

#30 Post by beanybabe » Mon Aug 31, 2015 3:02 am

something went wrong my main wp i'm testing works with it but it does not attack anything.

error happen when I attack a mob.
15-08-31 04:25:30 - C:/micromacro/scripts/rom/classes/player.lua:919: attempt
to perform arithmetic on global 'casttime' (a nil value)

User avatar
Administrator
Site Admin
Posts: 4865
Joined: Sat Jan 05, 2008 4:21 pm

Re: CPU freq.

#31 Post by Administrator » Mon Aug 31, 2015 9:51 am

player.lua:917 should be changed from:

Code: Select all

				skill.LastCastTime.low = skill.LastCastTime.low +remaining*1000 * bot.GetTimeFrequency
to:

Code: Select all

				skill.LastCastTime = skill.LastCastTime + (remaining*1000 * bot.GetTimeFrequency)

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: CPU freq.

#32 Post by beanybabe » Mon Aug 31, 2015 3:21 pm

That seems to work now it is attacking again.

The problems I keep having with timing are not related to attacking. I need to find were error is posted. I searches and found this memoryReadByte if you search the forum you can see the errors. This is one of the effects of the timing problem.

User avatar
Administrator
Site Admin
Posts: 4865
Joined: Sat Jan 05, 2008 4:21 pm

Re: CPU freq.

#33 Post by Administrator » Tue Sep 01, 2015 1:10 am

That wasn't to fix the attacking. That was to fix the timer from overflowing and becoming corrupted in attempt to fix the issue you originally had reported. Has it helped or do you still get the error?

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: CPU freq.

#34 Post by beanybabe » Tue Sep 01, 2015 5:04 am

It is running better this may have fixed it. It is handling portals and npc well. I will try it during time of day it fails most and see how it does.

Just as I wrote it was working rom crashed as it finished a daily and was heading to portal. no error message from bot just the critical error from rom.
This does not seem related to the bot.


I read through the code in player.lua and ill say :ugeek: :ugeek: to you that is over my head.

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: CPU freq.

#35 Post by beanybabe » Tue Sep 01, 2015 3:42 pm

I got this error this afternoon and rom has been crashing. I changed the timing back to the way I had it in bot.lua instead of the /1000 to see if that stops the crashing but left your change in player.lua also.

memorytable 213 attempt to concatenate a nil value

Code: Select all

	-- Get name/plural address
	local nameaddress = memoryReadInt(proc, itemAddress + addresses.nameOffset + pluralOffset)
	if nameaddress == 0 and commandMacro ~= 0 and SlashCommand then
		SlashCommand("/script GetCraftRequestItem(".. itemId ..",-1)")
		local starttime = getTime()
		repeat
			yrest(5)
			nameaddress = memoryReadInt(proc, itemAddress + addresses.nameOffset + pluralOffset)
		until nameaddress ~= 0 or deltaTime(getTime(),starttime) > 200
	end
---------------------  i added this to see what is nil
if (name or proc or nameaddress) == "nil" then
print ("memorytable name =",name,"proc =",proc,"nameaddress =",nameaddress)
end  
---------------------------
213	return name .. memoryReadString(proc, nameaddress)
end

User avatar
Administrator
Site Admin
Posts: 4865
Joined: Sat Jan 05, 2008 4:21 pm

Re: CPU freq.

#36 Post by Administrator » Wed Sep 02, 2015 12:12 pm

That's an unrelated error to the CPU frequency issue you were having. Anyways, try changing this line:
memorytable.lua:213

Code: Select all

return name .. memoryReadString(proc, nameaddress)
to:

Code: Select all

return name .. memoryReadRepeat("string", proc, nameaddress)

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: CPU freq.

#37 Post by beanybabe » Wed Sep 02, 2015 1:44 pm

i set cpu back to 1000 and added that line to memorytable the first char i run i get this again

undefined player.Class1 in settings.lua debug print i added said the player class was at -1
player class was = 8 before entering drill ground something is changing it to -1 some times
if I change the cpu setting so it not 1000 then I don't seem to get this error.

on starting next char half dozen addresses showed up as undefined so I will run Fixaddress and trying it again. is there some way to know when address change? rom seems to update them in the background.

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: CPU freq.

#38 Post by beanybabe » Wed Sep 02, 2015 10:59 pm

This error happened twice I changed the divider for cpu speed back to my numbers now it seems to work Ill run it a little more see if that error come back.

Use MACRO: Executing RoMScript "StaticPopup_OnClick(StaticPopup1, 1);".
The game client did not crash.
2015-09-02 16:51:36 - IGF:\StaticPopup_OnClick(StaticPopup1, 1);\:IGF [string "?"]:1581: attempt to index field '?' (a nil value)

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: CPU freq.

#39 Post by beanybabe » Wed Sep 02, 2015 11:01 pm

This error happened twice

Use MACRO: Executing RoMScript "StaticPopup_OnClick(StaticPopup1, 1);".
The game client did not crash.
2015-09-02 16:51:36 - IGF:\StaticPopup_OnClick(StaticPopup1, 1);\:IGF [string "?"]:1581: attempt to index field '?' (a nil value)

I changed the divider for cpu speed back to my numbers now it seems to work Ill run it a little more see if that error come back. I think they needs to be some kind of adjustment for this number based on the cpu.

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: CPU freq.

#40 Post by beanybabe » Thu Sep 03, 2015 1:15 am

could one of the patches be affecting the other? with both in it is pretty not usable if rom does not crash it gets stuck at portal.


When I change the freq divide to my number I get part of the same error. The char stops in the same place on the portal trying to exit guild castle. note: the nil value part of the error did not occur with the cpu number different. with 1000 at the freq it crashes the bot, with my number it will continue on after I assist char to leave castle.

Use MACRO: Executing RoMScript "StaticPopup_OnClick(StaticPopup1, 1);".

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 4 guests