issue-#105 background task processing while mouse tracking

Merged to the master branch
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#105 background task processing while mouse tracki

Post by Josef Templ »

Ivan Denisov wrote: Previously I had thought that better to make some documentation for Host modification. Now I understand that we did not make good testing to suggest such solutions. The only way to make such testing is to include this option now and to evaluate this in Beta.
Such changes at the core of the framework are very delicate because it is not sufficient to
test all the code included in the BB distribution. We would have to test all exisiting user code
and that it clearly not realistic. Therefore I see the preferences option as the only way
to support this background task processing. The alternative would be to drop the feature at all.

- Josef
Ivan Denisov
Posts: 1700
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

Re: issue-#105 background task processing while mouse tracki

Post by Ivan Denisov »

Josef, will you make this changes? Or I can do?
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#105 background task processing while mouse tracki

Post by Josef Templ »

If we go for the preferences option, the question is what option to introduce:

a) Task processing while mouse tracking
b) Server Mode

'a' would be an option specifically targeted at task processing while mouse tracking and nothing else.
'b' would be anything that supports operating BlackBox in server mode, which includes task processing while mouse tracking
but could also include other adaptations that make BlackBox a better server.

Currently I tend to favor 'b'.

- Josef
Ivan Denisov
Posts: 1700
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

Re: issue-#105 background task processing while mouse tracki

Post by Ivan Denisov »

I am suggesting to add checkbox "Server Mode" and change now only this mouse tracking problem. Let's keep other changes for later discussions.
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#105 background task processing while mouse tracki

Post by Josef Templ »

OK, I will add it in the next couple of days.

- Josef
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#105 background task processing while mouse tracki

Post by Josef Templ »

Ivan Denisov wrote:Anyway HostWindows patch can be discussed.
http://forum.blackboxframework.org/view ... f=40&t=394


To help servers developers we can write some note in the BlackBox manual: "Services priority and speed". Anyway Services now runs to slow for server needs.

This is easy to check:

Code: Select all

MODULE ToolsServTest;

	IMPORT Log, Services;

	TYPE
		Action = POINTER TO RECORD (Services.Action) END;

	VAR
		time, sum: LONGINT;
		n: INTEGER;

	PROCEDURE (a: Action) Do;
	BEGIN
		IF n < 100 THEN
			sum := sum + (Services.Ticks() - time);
			time := Services.Ticks();
			INC(n);
			Services.DoLater(a, Services.now)
		ELSE
			Log.Real(sum / 100); Log.Ln
		END;
	END Do;

	PROCEDURE Test*;
	VAR a: Action;
	BEGIN
		n := 0;
		sum := 0;
		NEW(a);
		time := Services.Ticks();
		Services.DoLater(a, Services.now)
	END Test;


END ToolsServTest.

^ ToolsServTest.Test
it returns 49 ms. This is huge time for any good server app. HostMenus.Loop should be modified for server.
I tested it and it returned 11 ms for a number of times. Later it returned 62 ms and never came back to 11.
Where does this delay come from? Why is it variable?

- Josef
User avatar
Robert
Posts: 1024
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: issue-#105 background task processing while mouse tracki

Post by Robert »

Josef Templ wrote:Later it returned 62 ms ...
62 ms for me also - Windows XP on a dual core Athlon.
Zinn
Posts: 476
Joined: Tue Mar 25, 2014 5:56 pm
Location: Frankfurt am Main
Contact:

Re: issue-#105 background task processing while mouse tracki

Post by Zinn »

There was a discussion about this topic in the BlackBox mailing list in the year 2005.

- System time in BlackBox started by Wojtek Skulski in April 2005
- UtilTime started by Gérard Meunier in April 2005
- Services.timing started by Douglas G. Danforth in April 2005
- Idle time started by Douglas G. Danforth in April 2005
- Action.Do method call interval by F. Necati Ecevit in July 2005
- Real time & garbage collection started by Douglas G. Danforth in June 2011

Short summary:
Look at source of DevProfiler & UtilTime for more acurate time messurement.

If you do not need to know the absolute time to less than 1 second you can use Dates.GetTime and then from that point use UtilTime for precise relative events.

The service interval of BB task is 50 ms (20 Hz). It is set in HostMenus via the CONST idlePeriod = 50; (* ms *)
They checked to run BlackBox with idlePeriod = 10 and idlePeriod = 1.

Look also at How to: Use the High-Resolution Timer
https://msdn.microsoft.com/en-us/library/aa964692.aspx
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#105 background task processing while mouse tracki

Post by Josef Templ »

Thanks, Helmut.

I can set HostMenus.idlePeriod to 10 if in server mode.
This reduces the delay to about 16 ms, which is 1/3 of the normal delay for actions.
A smaller value did not improve the result in my tests.

- Josef
Ivan Denisov
Posts: 1700
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

Re: issue-#105 background task processing while mouse tracki

Post by Ivan Denisov »

Josef Templ wrote:A smaller value did not improve the result in my tests.
https://msdn.microsoft.com/ru-ru/librar ... 85%29.aspx
If uElapse is less than USER_TIMER_MINIMUM (0x0000000A), the timeout is set to USER_TIMER_MINIMUM.
So less than 10 can not be used.
Josef Templ wrote:I can set HostMenus.idlePeriod to 10 if in server mode.
Seems reasonable.
Post Reply