Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of a space with many postponed tasks #456

Open
tinchodias opened this issue Mar 2, 2024 · 0 comments
Open

Improve performance of a space with many postponed tasks #456

tinchodias opened this issue Mar 2, 2024 · 0 comments

Comments

@tinchodias
Copy link
Collaborator

In #448 I removed BlTastAtQueue. AFAIU, we gained in code comprehension (Bloc is a bit simpler after removing it) but may had lost bit of performance in repeated tasks. Or maybe not, but there is place for improvement here. Example:

space := BlSpace new.
space show.
space root enqueueTask:
	(BlRepeatedTaskAction new
		delay: 500 milliSeconds;
		action: [ space root background: Color random ];
		yourself).

If we had a ton of those tasks waiting to be run (after the delay passed), we may notice it.

The point it that even if for 500ms the host's universe loop could be idle, it won't. It's a quite active wait: These delayed tasks are re-enqueued again and again (via BlSpaceTaskQueue>>#requeue:) on each loop pulse, after BlRepeatedTask>>#run determines if starting delay has not been surpassed yet.

This issue is to look for a better mechanism to postpone the starting of a task with simpler code than the old BlTaskAtQueue.

Additionally, a more "hacky" example, but where the same happens is in animations (subclasses of task):

space := BlSpace new.
space show.
space root addAnimation:	
	(BlNumberTransition new
		from: 0; to: 1;
		duration: 1 milliSecond;
		delay: 500 milliSeconds;
		  onStepDo: [ :t |
			space root background: Color random ];
		  beInfinite;
		  yourself)

In this case, the the animation determines if the starting delay has been surpassed in BlBaseAnimation>>#step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant