Raised This Month: $51 Target: $400
 12% 

Solved Optimizing a repeatable task


Post New Thread Reply   
 
Thread Tools Display Modes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-09-2018 , 11:27   Re: Optimizing a repeatable task
Reply With Quote #11

Yeah, I always use thinking entities personally, but like I said I think the heavy lift with set_task() is the initial creation. Going forward from a looping perspective, performance differences between a task and thinking entity is probably debatable.
__________________
Bugsy is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-09-2018 , 11:43   Re: Optimizing a repeatable task
Reply With Quote #12

Creating tasks is actually as expensive as creating any other handle(Arrays, Tries, Menus...), so I wouldn't worry about it.
AMXX checks every 100ms if any of the tasks should get executed, so it's not bad either. What is bad though is that this means that tasks are accurate to ~100ms window and you shouldn't rely on them if you need precision, but for most use cases that's not an issue.
The engine actually checks every frame if any existing entity should think, so it's not far off from what AMXX does.

We are not in early 2000's, servers are powerful, don't underestimate them. If you don't need precision just go with a task, it's alright. Even 0.1s tasks are totally cool.

Also there's been some talk to improve tasks: https://github.com/alliedmodders/amxmodx/pull/380 but it looks like the author isn't interested in completing it.
__________________

Last edited by klippy; 02-09-2018 at 11:47.
klippy is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-09-2018 , 12:05   Re: Optimizing a repeatable task
Reply With Quote #13

Quote:
Even 0.1s tasks are totally cool.
I would be careful with such statements, because some people out of laziness may use 0.1 for everything. Like they use prethink because they are lazy to figure the proper forward for a certain job.
Yeah, if you REALLY need 0.1 seconds then it's okay, but in most cases 0.1 is too often. There are big chances you will be totally fine with a bigger repeat time.
__________________

Last edited by HamletEagle; 02-09-2018 at 12:05.
HamletEagle is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 02-10-2018 , 05:59   Re: Optimizing a repeatable task
Reply With Quote #14

Quote:
Originally Posted by HamletEagle View Post
I would be careful with such statements, because some people out of laziness may use 0.1 for everything. Like they use prethink because they are lazy to figure the proper forward for a certain job.
Yeah, if you REALLY need 0.1 seconds then it's okay, but in most cases 0.1 is too often. There are big chances you will be totally fine with a bigger repeat time.
Is any possibility that task crashes when the task repeats 10 times a sec? Can tasks even crash?
__________________
Relaxing is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 02-10-2018 , 06:12   Re: Optimizing a repeatable task
Reply With Quote #15

Quote:
Originally Posted by Relaxing View Post
Is any possibility that task crashes when the task repeats 10 times a sec? Can tasks even crash?
The tasks cannot crash. The code inside the task can crash or generate the errors.
__________________
My English is A0
E1_531G is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-10-2018 , 13:40   Re: Optimizing a repeatable task
Reply With Quote #16

Quote:
Originally Posted by Relaxing View Post
Is any possibility that task crashes when the task repeats 10 times a sec? Can tasks even crash?
Why would you execute something 10 times per second that can be executed just fine only one time per second?
You are just wasting resources for no purpose.

About crashes, it depends on the code, as E1_531G said.
__________________

Last edited by HamletEagle; 02-10-2018 at 13:40.
HamletEagle is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-10-2018 , 15:34   Re: Optimizing a repeatable task
Reply With Quote #17

Agree, I would start high at 1.0 seconds and if the delay is noticeable in game, gradually reduce by 0.1 until it looks acceptable. I would not default to always using 0.1.
__________________
Bugsy is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 02-10-2018 , 17:03   Re: Optimizing a repeatable task
Reply With Quote #18

Quote:
Originally Posted by HamletEagle View Post
Why would you execute something 10 times per second that can be executed just fine only one time per second?
You are just wasting resources for no purpose.

About crashes, it depends on the code, as E1_531G said.
I was just trying to find out that if the task repeats more quicker, does the chances of the task being corrupted increases or not.
__________________
Relaxing is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-10-2018 , 17:18   Re: Optimizing a repeatable task
Reply With Quote #19

Quote:
Originally Posted by Relaxing View Post
I was just trying to find out that if the task repeats more quicker, does the chances of the task being corrupted increases or not.
If there's a big array which is not static, maybe.
__________________
HamletEagle is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:56.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode