Modify

Opened 11 years ago

Closed 11 years ago

#625 closed Bug (No Bug)

Page faults caused by Sleep

Reported by: JRSmile Owned by:
Milestone: Component: AutoIt
Version: Other Severity: None
Keywords: 3.2.12.1 Cc:

Description

Hi there,
i noticed in a service that i have written that autoit generates massive page faults when there is a loop in the source code with a sleep more then 250 ms, this is caused by windows moving the memory to the page file while the autoit script sleeps and moves it back when autoit gets awake.

i created a small sleep function that can handle one parameter that will be held in memory due to constant accessing it, but this should not be the solution.

Would a developer have a look if this bad thing can be patched away in the autoit binary functions itself?.

here the function:
Func _sleep($time, $var)

$time *= 4
while $time

Sleep(250)
$time -= 1
if IsArray($var) Then

if $var[0] or 1 = 1 Then ContinueLoop

Else

if $var or 1 = 1 Then ContinueLoop

EndIf

WEnd

EndFunc

maybe you get the clue then :) for me it works.
i use autoit often as service so it will run 24/7 for example in 48 hours it generates 101714852528 page faults, 10000 per second if it is NOT in the 50 second sleep loop.

Attachments (1)

page_faults.jpg (37.7 KB) - added by JRSmile 11 years ago.
screenshot of the bad thing :-)

Download all attachments as: .zip

Change History (6)

Changed 11 years ago by JRSmile

screenshot of the bad thing :-)

comment:1 in reply to: ↑ description Changed 11 years ago by Valik

Replying to JRSmile:

Hi there,
i noticed in a service that i have written that autoit generates massive page faults when there is a loop in the source code with a sleep more then 250 ms,

Oh? This code does not produce page faults:

While True
	Sleep(300)
WEnd

this is caused by windows moving the memory to the page file while the autoit script sleeps and moves it back when autoit gets awake.

Atually, you have it backwards. A page fault occurs when a program tries to access a page of memory that is on disk. However, it also occurs for a few other reasons as well that don't involve the disk at all.

Would a developer have a look if this bad thing can be patched away in the autoit binary functions itself?.

Not until you give me a simple script that reproduces the problem.

i use autoit often as service so it will run 24/7 for example in 48 hours it generates 101714852528 page faults, 10000 per second if it is NOT in the 50 second sleep loop.

You need to explain this statement. Are there multiple different sleep statements? A really long one and then later a few short ones and then the long one is called again?

comment:2 follow-up: Changed 11 years ago by JRSmile

i will just add the code here :-)

#Region includes
#include "includes/mysql.au3"
#include "includes/write_error.au3"
#include "includes/_FaxLog_GetList.au3"
#EndRegion includes
#NoTrayIcon
#Region main function
#include <array.au3>
#cs
$lol = TimerInit()
_sleep(1, $lol)
ConsoleWrite(TimerDiff($lol))
#ce
ConsoleWrite(@AutoItVersion)
exit
#ce

Global $aResult
write_error("Started FaxLogging...")
AdlibEnable("connect", 1000 * 60 * 5)
write_error("scheduling refresh of available FAX devices every 5 minutes.")
connect()
write_error("scheduling rescan of unsend messages every 50 seconds.")
While 1
	Sleep(1)
	if not IsArray($aResult) then ContinueLoop
	write_error("starting up " & $aResult[0] & " threads to check the fax devices, max. 10 threads at a time.")
	For $i = 1 To $aResult[0]
		While 1
			$list = ProcessList("FaxLog_Check.exe")
			If $list[0][0] < 10 Then 
				$list = 0
				ExitLoop
			EndIf
			Sleep(250)
		WEnd
		ShellExecute(@ScriptDir & "\FaxLog_Check.exe", $aResult[$i], @ScriptDir, "open", @SW_SHOW)
		If @error Then write_error("Could not start FaxLog_Check.exe for fax: " & $aResult[$i] & ", maybe the exe has been deleted?")
	Next
	while ProcessExists("FaxLog_Check.exe")
		Sleep(10)
	WEnd
	_sleep(15, $aResult)
	ProcessClose("iexplore.exe")
	;Sleep(1000 * 45)
	_sleep(45, $aResult)
WEnd
#EndRegion main function
#Region helper functions
Func connect()
	write_error("connecting to SQl Server: server...")
	If not Ping("NL00-MYSQL-TEST") Then
		write_error("could not reach " & "server" & ", please check connectivity!!!")
		Return
	EndIf
	$aResult = _fax_array("server", "username", "password", "printers_dev", "fax", "ip")
EndFunc   ;==>connect
#EndRegion helper functions

Func _sleep($time, $var)
	$time = $time * 2
	while $time
		Sleep(500)
		$time -= 1
		if IsArray($var) Then
			if $var[0] or 1 = 1 Then ContinueLoop
		Else
			if $var or 1 = 1 Then ContinueLoop
		EndIf
	WEnd
EndFunc

thats all, what is strange that i don't get as much pagefaults one divverent systems then the production environment its a vmware image running on esx, my testing environment is a centrino Notebook.

Hope this is enough to investigate.

comment:3 in reply to: ↑ 2 Changed 11 years ago by Valik

Replying to JRSmile:

Hope this is enough to investigate.

It's not. You might as well post a picture of a dog for as helpful as that is. First of all, there's nothing there that demonstrates it might actually be Sleep() and not something else since all the Sleep() statements are surrounded by other pieces of code. Second, the code isn't even runnable since most of the files are missing.

See, here's how bug reporting works.

  1. You find an issue.
  2. You show us how to reproduce the issue.
  3. We resolve the issue (fixing a bug or determining the behavior isn't a bug, et cetera).

You're skipping #2.

comment:4 Changed 11 years ago by JRSmile

ok, i investigated further and it seems that im wrong, it was not sleep, i think it was any execute function in autoit, (tested all). Attached you will find my short example, just press pause to toggle page fault generation, which can easily be seen in taskman.exe :-)

HotKeySet("{PAUSE}", "_toggle")

Global $wait = 1, $ok = True

while 1
	$lol = TimerInit()
	if $ok then 
		_sleep($wait, $lol)
	Else
		Sleep(1000 * $wait)
	EndIf
	ConsoleWrite(TimerDiff($lol) & @CRLF)
WEnd


Func _sleep($time, $var)
	$time *= 63
	while $time
		RunWait("ping -n 1 -w 1 127.0.0.1", @ScriptDir, @SW_HIDE) ; suggested page fault, soft page fault if more correct.
		$time -= 1
		if IsArray($var) Then
			if $var[0] or 1 = 1 Then ContinueLoop
		Else
			if $var or 1 = 1 Then ContinueLoop
		EndIf
	WEnd
EndFunc

Func _toggle()
	if not $ok then
		$ok = True
		Beep(2500,250)
	Else
		$ok = False
		Beep(1000,250)
	EndIf
EndFunc

comment:5 Changed 11 years ago by Valik

  • Resolution set to No Bug
  • Status changed from new to closed

Then you haven't found a bug. It's not unexpected that complicated code generates page faults and it doesn't mean there is an issue.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.